[OpenLayers-Users] wfs feature geometry based on one attribute
value
Alexandre Dube
adube at mapgears.com
Thu Dec 11 11:25:59 EST 2008
Well I guess your CQL_FILTER approach looks ok, so you could just change
it to request a specific feature that has a specific attribute value.
I never used GeoServer but I think the following links could help you
find what you need :
http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters
http://geoserver.org/display/GEOSDOC/WFS+vendor+parameters
And about my solution, I guess it was good for my example of "city
search" because I need all of them, but in your case you only need
what's requested by the user, so it's not really useful to fetch them
all at first.
Best regards,
Alexandre
Lehtonen, Mika wrote:
> Alexandre Dube kirjoitti:
>>>
>>>
>>> I have my data in PostGIS and I mean features that aren't shown in
>>> my map. Or actually they are shown, but through wms. I am already
>>> fetching some attributes after geometry comparison through wfs
>>> GetFeature, but I was wondering whether there would some other ways
>>> to do that.
>>
>> Could you share an example of this ? I would like to see how you do it.
>>
>> Alexandre
> Sure,
> it ain't no rocket science. I'm using GeoServer and PostGIS. I have
> about 3000 polygons in my wfs service and I need to get some
> attributes out of those I choose using wms-layer as a reference. The
> choosing tool is sort of a buffer tool (choose all features which are
> entirely or partially inside the circle). First I do the GetFeature.(
> I'll try to incorporate only the essential parts..)
>
> function buffer(e) { var url =
> wfs.getFullRequestString({
> SERVICE: 'WFS',
> VERSION: '1.0.0',
> REQUEST: 'GetFeature',
> OUTPUTFORMAT: 'json',
> PROPERTYNAME: 'the_geom,attr1',
> MAXFEATURES: 1000,
> TYPENAME: 'ns:layername',
> SRSNAME: 'EPSG:900913',
> CQL_FILTER: 'INTERSECT(the_geom,'+ buffergeometry +')'
> },
> "http://host.domain/geoserver/wfs"
> );
> OpenLayers.loadURL(url,'',this,bufferUpdate);
> Event.stop(e);
> };
>
> Then I dig the attributes I need out of the response:
>
> function bufferUpdate (response) {
> g = new OpenLayers.Format.JSON();
> resp = g.read(response.responseText);
> attrdata = new Array();
> for (i in resp.features) {
> attrdata[i] = resp.features[i].properties.attr1; }
> }
>
> I hope I included all the parts needed. Anyway after this I have an
> array of attributes (attr1) of the chosen geometries. I guess
> CQL_FILTER is Geoserver specific and JSON isn't mandatory format in
> wfs compliant server, but of course there could be used standard
> FILTER and GML output with 'getElementsByTagName' or similar.
>
> - mika -
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list