[OpenLayers-Users] Difficulties with GetFeatureInfo

Matt Priour mpriour at kestrelcomputer.com
Wed Jul 9 07:12:58 EDT 2008


Yes, I do plan on contributing back to this wonderful OpenLayers development 
effort.
I'll write up a ticket and submit a patch when I have it working properly.

Matt Priour

--------------------------------------------------
From: "Eric Lemoine" <eric.c2c at gmail.com>
Sent: Wednesday, July 09, 2008 1:27 AM
To: "mpriour" <mpriour at kestrelcomputer.com>; <users at openlayers.org>
Subject: Re: [OpenLayers-Users] Difficulties with GetFeatureInfo

> Matt, i had never tried Format.GML with GetFeatureInfo responses. And
> indeed that'd be great to have support for this. Do you plan to
> contribute your work for integration into OpenLayers? Thanks. Eric
>
> 2008/7/9, mpriour <mpriour at kestrelcomputer.com>:
>>
>> I was actually struggling with this same problem this past month.
>> You should use:
>>
>> var xmlResponse = new 
>> OpenLayers.Format.XML().read(response.responseText);
>>
>> this will convert the text into a valid xml object.
>> From there you can do whatever you want to it.
>>
>> I am writing some convience methods that extend OpenLayers.Format.GML to
>> parse the GML GetFeatureInfo response into predictable js objects. The
>> current methods for Format.GML & Format.WFS are not designed to correctly
>> parse the entire GML GetFeatureInfo response. They can parse some 
>> geometry
>> or features from portions of the response.
>>
>> Matt Priour
>> Kestrel Computer Consulting
>> www.kestrelcompter.com - homepage
>> priour.wordpress.com - blog
>>
>>
>> Eric Lemoine-3 wrote:
>>>
>>> Hi. Have you tried using OpenLayers.Format.GML for de-serializing the
>>> response text into feature objects? Eric
>>>
>>> 2008/7/8, Rick Wayne <fewayne at wisc.edu>:
>>>> Hullo all,
>>>>
>>>> I'm using OpenLayers and GeoServer, and am having some trouble with
>>>> getting XML data out of GetFeatureInfo. If I ask GeoServer for
>>>> INFO_FORMAT of application/vnd.ogc.gml, I get a response back, and it
>>>> has the data I desire. But I cannot access those data as XML. I have
>>>> to get them via responseText and parse that looking for angle brackets
>>>> and the like, which is all very boring, not to say fragile as a dried
>>>> leaf.
>>>>
>>>> Of course, I should be able to make use of the responseXML property,
>>>> but that obstinately persists in being NULL, even when the text
>>>> response is fine. In fact, the text response is perfectly good XML. As
>>>> a big honkin' string.
>>>>
>>>> I'm using GeoServer 1.5.3 and, er, whichever OL version came with
>>>> that. :-)
>>>>
>>>> Below are the relevant calls. If anyone can assuage my ignorance, good
>>>> cheer to them!
>>>>
>>>> TIA,
>>>>
>>>> Rick Wayne
>>>> UW Soil Science
>>>>
>>>>          [...]
>>>> map.events.register('click', map, function (e) {
>>>> var url =  map.baseLayer.getFullRequestString({
>>>> REQUEST: "GetFeatureInfo",
>>>> EXCEPTIONS: "application/vnd.ogc.se_xml",
>>>> BBOX: map.getExtent().toBBOX(),
>>>> X: e.xy.x,
>>>> Y: e.xy.y,
>>>> INFO_FORMAT: 'application/vnd.ogc.gml',
>>>> // INFO_FORMAT: 'text/plain',
>>>> QUERY_LAYERS: map.baseLayer.params.LAYERS,
>>>> FEATURE_COUNT: 1,
>>>> srs: 'EPSG:26916',
>>>> styles: '',
>>>> layers: 'mmas:civil',
>>>> WIDTH: map.size.w,
>>>> HEIGHT: map.size.h},
>>>> "/geoserver/wms"
>>>>   );
>>>> OpenLayers.loadURL(url, '', this, zoomToFeature, zoomToFeature);
>>>> Event.stop(e);
>>>> });
>>>>
>>>> function zoomToFeature(response) {
>>>> // lines = response.responseText.split('\n');
>>>> var txt;
>>>> var tag;
>>>> var coord_index;
>>>> var rest;
>>>> var coord_text;
>>>> var coords;
>>>> var coord_pairs,ll,ur;
>>>>
>>>> txt = response.responseText; // here should be xml =
>>>> response.responseXML;
>>>> tag = 'gml:coordinates decimal="." cs="," ts=" ">';
>>>> coord_index = txt.indexOf(tag);
>>>> rest = txt.substr(coord_index + tag.length);
>>>> end_coord_index = rest.indexOf('<');
>>>>          // And so on, too ugly to reveal the rest!
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Difficulties-with-GetFeatureInfo-tp18347813p18353488.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>> 



More information about the Users mailing list