store getfeatureinfo results in variables

7 messages Options
Embed this post
Permalink
stash

store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink
Hello,
with the following code, I get a wms getfeatureinfo request and the information are shown on a window.

map.events.register('click', map, function(e) {
               var url = "http://...:8080/geoserver/wms" + "?REQUEST=GetFeatureInfo" + "&EXCEPTIONS=application/vnd.ogc.se_xml"
               + "&BBOX=" + map.getExtent().toBBOX()
               + "&X=" + e.xy.x
               + "&Y=" + e.xy.y
               + "&INFO_FORMAT=text/html"
               + "&QUERY_LAYERS=MY_LAYER"
               + "&LAYERS=MY_LAYER"
               + "&FEATURE_COUNT=50"
               + "&SRS=EPSG:4326"
               + "&STYLES="
               + "&WIDTH=" + map.size.w
               + "&HEIGHT=" + map.size.h;

 window.open(url, "getfeatureinfo", "location=0,status=0,scrollbars=1,width=800,height=400");

This is working fine so far. But there is one thing, I don't like. I'm talking about the values I get back. Because every time I get a featureinfo I get some abbreviations (for example 'ger' instead of 'germany'). This is because of the values stored in the database.

Because of this I would like to change the values before the window will show them. Is there any possibility to do this. I watched the code in firebug but the only thing i saw was the url (getfeatureinfo request).

Can I store the values I get back in variables (to change it manually) and then show it in a window?

Please help

Regards
stash

Roald de Wit-2

Re: store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink
Hi,

If you follow the path of WFS GetFeature (as suggested in a previous
mail yesterday), you can manipulate the values any way you like, since
they are stored as attributes in the features. WMS GetFEatureInfo
generally only gives you plain text or HTML results. Getting XML back is
sometimes possible too. You could then use the OL XML Format to parse that.

Regards, Roald

stash wrote:

> Hello,
> with the following code, I get a wms getfeatureinfo request and the
> information are shown on a window.
>
> map.events.register('click', map, function(e) {
>                var url = "http://...:8080/geoserver/wms" +
> "?REQUEST=GetFeatureInfo" + "&EXCEPTIONS=application/vnd.ogc.se_xml"
>                + "&BBOX=" + map.getExtent().toBBOX()
>                + "&X=" + e.xy.x
>                + "&Y=" + e.xy.y
>                + "&INFO_FORMAT=text/html"
>                + "&QUERY_LAYERS=MY_LAYER"
>                + "&LAYERS=MY_LAYER"
>                + "&FEATURE_COUNT=50"
>                + "&SRS=EPSG:4326"
>                + "&STYLES="
>                + "&WIDTH=" + map.size.w
>                + "&HEIGHT=" + map.size.h;
>
>  window.open(url, "getfeatureinfo",
> "location=0,status=0,scrollbars=1,width=800,height=400");
>
> This is working fine so far. But there is one thing, I don't like. I'm
> talking about the values I get back. Because every time I get a featureinfo
> I get some abbreviations (for example 'ger' instead of 'germany'). This is
> because of the values stored in the database.
>
> Because of this I would like to change the values before the window will
> show them. Is there any possibility to do this. I watched the code in
> firebug but the only thing i saw was the url (getfeatureinfo request).
>
> Can I store the values I get back in variables (to change it manually) and
> then show it in a window?
>
> Please help
>
> Regards
> stash
>
>
>  

_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
stash

Re: store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink
Roald de Wit-2 wrote:
Hi,

If you follow the path of WFS GetFeature (as suggested in a previous
mail yesterday), you can manipulate the values any way you like, since
they are stored as attributes in the features. WMS GetFEatureInfo
generally only gives you plain text or HTML results. Getting XML back is
sometimes possible too. You could then use the OL XML Format to parse that.

Regards, Roald
Hi Roald,
thanks for your answer. I know it would be much easier if I used a wfs getfeature instead of a wms getfeatureinfo. But the problem is that my proxyhost doesn't work (I don't know why and I spent so much time in solving this problem), therefore I want to solve my problem with a wms.

You wrote that it is sometimes possible to get a xml back even with wms. What do you mean by this?

(Is it possible to parse the html or the plain text to get my values?)

Regards
stash
Roald de Wit-2

Re: store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink
Hi  stash,

stash wrote:
> Hi Roald,
> thanks for your answer. I know it would be much easier if I used a wfs
> getfeature instead of a wms getfeatureinfo. But the problem is that my
> proxyhost doesn't work (I don't know why and I spent so much time in solving
> this problem), therefore I want to solve my problem with a wms.
>
> You wrote that it is sometimes possible to get a xml back even with wms.
> What do you mean by this?
>  
Different WMS servers have different output formats for GetFeaturInfo.
IIRC you are using GeoServer. If that is correct, you can specify the
INFO_FORMAT to be 'application/vnd.ogc.gml', then you could pass the
output to the OL GML reader which looks a bit like this:

var gmlReader = new OpenLayers.Format.GML();

var features = gmlReader.read(data); // assuming the result of the
output is in the variable called data

Then you can loop through the features and change the attribute
information any way you like and visualise it any way you want.

Regards, Roald

_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
stash

Re: store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink

Roald de Wit-2 wrote:
Hi  stash,

stash wrote:
> Hi Roald,
> thanks for your answer. I know it would be much easier if I used a wfs
> getfeature instead of a wms getfeatureinfo. But the problem is that my
> proxyhost doesn't work (I don't know why and I spent so much time in solving
> this problem), therefore I want to solve my problem with a wms.
>
> You wrote that it is sometimes possible to get a xml back even with wms.
> What do you mean by this?
>  
Different WMS servers have different output formats for GetFeaturInfo.
IIRC you are using GeoServer. If that is correct, you can specify the
INFO_FORMAT to be 'application/vnd.ogc.gml', then you could pass the
output to the OL GML reader which looks a bit like this:

var gmlReader = new OpenLayers.Format.GML();

var features = gmlReader.read(data); // assuming the result of the
output is in the variable called data

Then you can loop through the features and change the attribute
information any way you like and visualise it any way you want.

Regards, Roald

_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users
Thanks. That's a good advice. I tried it and I get back a gml with all the features .That's great. But unfortunately I can't read it with my gmlReader. What value do I have to insert at gmlreader.read(data) instead of data so that i can read my output.

Thanks for the help.

Regards
stash
stash

Re: store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink
Roald de Wit-2 wrote:
var features = gmlReader.read(data); // assuming the result of the
output is in the variable called data
Hi,
how do I get the result of my output in a variable just like in the example (data). I searched with firebug but I didn't find my gml (the value for my INFO_FORMAT).

Examples from openlayers work with an xmlhttprequest. This doesn't work in my case because of the not working proxy.

Please help


Regards
stash
Roald de Wit-2

Re: store getfeatureinfo results in variables

Reply Threaded More More options
Print post
Permalink
Hi,

On 06/11/09 01:40, stash wrote:
> Hi,
> how do I get the result of my output in a variable just like in the example
> (data). I searched with firebug but I didn't find my gml (which is my
> info_format).
>
> Examples from openlayers work with an xmlhttprequest. This doesn't work in
> my case because of the not working proxy.
>


Ah, yes, you open a window with a URL that gets HTML back. If you want
the flexibility you were asking for, I think you'll stay stuck until you
overcome the proxy hurdle.

Where do you serve your HTML from? Apache on port 80? And your GeoServer
is on port 8080? If you place your proxy.cgi in your cgi-bin directory,
it should work (make sure its exececutable). Or otherwise, why not setup
Apache to proxy pass all requests to /geoserver/* to
http://localhost:8080/geoserver/*? Then you don't need a proxy script at
all.

Regards, Roald

--
Roald de Wit
Software Engineer
[hidden email]

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/



The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users