split WMS GetFeatureInfo results

9 messages Options
Embed this post
Permalink
stash

split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
hello,

I have the following code, which shows me featureinfo of a map:

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/plain"
                            + "&QUERY_LAYERS=topp_mylayer"
                            + "&LAYERS=topp:topp_mylayer"
                            + "&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 dont like. With this code I get every feature of the clicked entry on the map (every entry in my database like id, name, date, coordinates...).

Is it possible, that I only get back a certain value like only the name of the clicked entry or only the coordinates?

Furthermore is it possible, that i can store the getfeatureinfo request in a variable?

Thanks for your help.

Regards
stash
 
Barend Kobben

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
That's probably  more a question to ask the underlying WMS (in your case
geoserver?) ; Eg. I know that when using Mapserver as a WMS, I would change
the
&INFO_FORMAT=text/plain
To
&INFO_FORMAT=text/html

And then make sure I have HTML templates that provide only the attributes I
want, layed out and styled like I want...


--
Barend Köbben
International Institute for Geo-Information
Sciences and Earth Observation (ITC)
PO Box 6, 7500AA Enschede, The Netherlands
+31 (0)53 4874253


On 02-11-09 15:30, "stash" <[hidden email]> wrote:

>
>
> hello,
>
> I have the following code, which shows me featureinfo of a map:
>
> 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/plain"
>                             + "&QUERY_LAYERS=topp_mylayer"
>                             + "&LAYERS=topp:topp_mylayer"
>                             + "&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 dont like. With this
> code I get every feature of the clicked entry on the map (every entry in my
> database like id, name, date, coordinates...).
>
> Is it possible, that I only get back a certain value like only the name of
> the clicked entry or only the coordinates?
>
> Furthermore is it possible, that i can store the getfeatureinfo request in a
> variable?
>
> Thanks for your help.
>
> Regards
> stash
>
> --
> View this message in context:
> http://n2.nabble.com/split-WMS-GetFeatureInfo-results-tp3932043p3932043.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/users

International Institute for Geo-Information Science and Earth Observation (ITC)
Chamber of Commerce: 410 27 560

E-mail disclaimer
The information in this e-mail, including any attachments, is intended for the addressee only. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or action in relation to the content of this information is strictly prohibited. If you have received this e-mail by mistake, please delete the message and any attachment and inform the sender by return e-mail. ITC accepts no liability for any error or omission in the message content or for damage of any kind that may arise as a result of e-mail transmission.
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
stash

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink

Barend Kobben wrote:
That's probably  more a question to ask the underlying WMS (in your case
geoserver?) ; Eg. I know that when using Mapserver as a WMS, I would change
the
&INFO_FORMAT=text/plain
To
&INFO_FORMAT=text/html

And then make sure I have HTML templates that provide only the attributes I
want, layed out and styled like I want...


--
Barend Köbben
International Institute for Geo-Information
Sciences and Earth Observation (ITC)
PO Box 6, 7500AA Enschede, The Netherlands
+31 (0)53 4874253

Hello,
thanks for your answer. In fact, you can build templates in geoserver to show only the results you want with a getfeatureinfo request. Thanks for the hint.

But now I have an other problem. Is it possible to define more templates for one layer?

For example, if the user wants output1 --> template 1 will be used by geoserver to show the results
                  if the user wants output2 --> template 2 will be used by geoserver to show the results

Is this possible?

Regards
stash


Roald de Wit-2

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
Hi,

If you want more control *and* if your WMS server supports WFS (like
MapServer and GeoServer), you could also consider sending a WFS
GetFeature request and tell the service exactly what attributes you want
to have returned. You can retrieve them as GML or GeoJSON for example
(or KML, etc) and display them in your application the way you want it.
I use my own html templates with variables representing the attributes
and have those replaced with their value for example.

Regards,

Roald

stash wrote:

>
> Barend Kobben wrote:
>  
>> That's probably  more a question to ask the underlying WMS (in your case
>> geoserver?) ; Eg. I know that when using Mapserver as a WMS, I would
>> change
>> the
>> &INFO_FORMAT=text/plain
>> To
>> &INFO_FORMAT=text/html
>>
>> And then make sure I have HTML templates that provide only the attributes
>> I
>> want, layed out and styled like I want...
>>
>>
>> --
>> Barend Köbben
>> International Institute for Geo-Information
>> Sciences and Earth Observation (ITC)
>> PO Box 6, 7500AA Enschede, The Netherlands
>> +31 (0)53 4874253
>>
>>
>>    
>
>
> Hello,
> thanks for your answer. In fact, you can build templates in geoserver to
> show only the results you want with a getfeatureinfo request. Thanks for the
> hint.
>
> But now I have an other problem. Is it possible to define more templates for
> one layer?
>
> For example, if the user wants output1 --> template 1 will be used by
> geoserver to show the results
>                   if the user wants output2 --> template 2 will be used by
> geoserver to show the results
>
> Is this possible?
>
> Regards
> stash
>
>
>
>  

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

Re: split WMS GetFeatureInfo results

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

If you want more control *and* if your WMS server supports WFS (like
MapServer and GeoServer), you could also consider sending a WFS
GetFeature request and tell the service exactly what attributes you want
to have returned. You can retrieve them as GML or GeoJSON for example
(or KML, etc) and display them in your application the way you want it.
I use my own html templates with variables representing the attributes
and have those replaced with their value for example.

Regards,

Roald

Hello,
thanks for your answer. I use geoserver and therefore I could use WFS too. But with a WFS you get only a xml (gml) I thought and i want to display the featureinfo. is this possible with wfs, too?

Could you show me an example of how to integrate such an wfs (getfeature) in openlayers to show the clicked value(like the example in my first message in this topic). I know that I can use a filter with wfs, but I don't know how to use it with openlayers.

I'm sorry, but I'm new in openlayers and unfortunately I'm not a pro with geoserver.

Thanks for your help.

Regards
stash
Roald de Wit-2

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
Hi stash,

stash wrote:
> Hello,
> thanks for your answer. I use geoserver and therefore I could use WFS too.
> But with a WFS you get only a xml (gml) I thought and i want to display the
> featureinfo. is this possible with wfs, too?
>
> Could you show me an example of how to integrate such an wfs (getfeature) in
> openlayers to show the clicked value on my map. I know that I can use a
> filter with wfs, but I don't know how to use it with openlayers.
>  
I'm realising now that I answered a bit too quickly: you would need to
perform some tricks to do a GetFeature request, including transforming
the click coordinates to lon/lat values etc. As a punishment for myself
I created an example [1] based on the standard getfeatureinfo.html
example. It's not perfect, but it works :-)

A few things to look out for:
- use 'ows' in your url instead of 'wms' or 'wfs'. OWS captures both,
you just need to specify the service explicitly
- make sure that if your geoserver runs on another port or another
machine that you have a proxy script
- look at the 'propertyName' parameter. That one tells the WFS service
what attributes to return.

[1] http://pastebin.com/f10237f96

Good luck!

Roald


_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Roald de Wit-2

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
One more addition: you can also use a GetFeature control with the new
OpenLayers.Protocol.WFS.fromWMSLayer protocol.
That's probably a cleaner way, but you'd have to find out how to add
extra paramaters like 'propertyName' and you'd still need to loop
through the attributes and show them.
Here is a standard GetFeature example using WFS:
http://www.openlayers.org/dev/examples/getfeature-wfs.html

Roald de Wit wrote:

> Hi stash,
>
> stash wrote:
>  
>> Hello,
>> thanks for your answer. I use geoserver and therefore I could use WFS too.
>> But with a WFS you get only a xml (gml) I thought and i want to display the
>> featureinfo. is this possible with wfs, too?
>>
>> Could you show me an example of how to integrate such an wfs (getfeature) in
>> openlayers to show the clicked value on my map. I know that I can use a
>> filter with wfs, but I don't know how to use it with openlayers.
>>  
>>    
> I'm realising now that I answered a bit too quickly: you would need to
> perform some tricks to do a GetFeature request, including transforming
> the click coordinates to lon/lat values etc. As a punishment for myself
> I created an example [1] based on the standard getfeatureinfo.html
> example. It's not perfect, but it works :-)
>
> A few things to look out for:
> - use 'ows' in your url instead of 'wms' or 'wfs'. OWS captures both,
> you just need to specify the service explicitly
> - make sure that if your geoserver runs on another port or another
> machine that you have a proxy script
> - look at the 'propertyName' parameter. That one tells the WFS service
> what attributes to return.
>
> [1] http://pastebin.com/f10237f96
>
> Good luck!
>
> Roald
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/users
>  

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

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
Hi,
thanks for the example. But when I try to click on the map I get following error:

Unhandled request return Not Found

I'm nearly sure this is because of my proxyhost settings. I don't know what I'm doing wrong, but my proxyhost doesn't work. (I already downloaded the proxy.cgi and copied it on the server, ...)

Nevertheless thanks for your example. If my proxyhost will work I can try it again.

Regards
stash
Roald de Wit-2

Re: split WMS GetFeatureInfo results

Reply Threaded More More options
Print post
Permalink
Hi,

Yes, your proxy script it probably not in the right location. Is it in
the same directory as your example html? If not, change either the
location of your proxy script or the path pointing to it in the example.
You also need to make sure that your web server can run that script.

Good luck,

Roald

stash wrote:

> Hi,
> thanks for the example. But when I try to click on the map I get following
> error:
>
> Unhandled request return Not Found
>
> I'm nearly sure this is because of my proxyhost settings. I don't know what
> I'm doing wrong, but my proxyhost doesn't work. (I already downloaded the
> proxy.cgi and copied it on the server, ...)
>
> Nevertheless thanks for your example. If my proxyhost will work I can try it
> again.
>
> Regards
> stash
>  

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