[OpenLayers-Users] wfs feature geometry based on one attribute value

Lehtonen, Mika mika at digikartta.net
Thu Dec 11 11:49:09 EST 2008


Yep,

that'll I do. I was just wondering whether there would be a clever way 
to do this, but I guess, because I haven't got any features rendered and 
actually extractAttributes is set to false, it's better to stick to that 
GetFeature method. Actually my present need is to fetch a single only 
geometry and to use its bounding box.

Yeah, I believe also so that GeoServer's CQL-filter allows to just state 
attr1=what_you_want, of course in proper syntax.

thanks,
- mika -

Alexandre Dube kirjoitti:
> 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 -
>
>



More information about the Users mailing list