[Geoserver-users] Best way to get extent of "selected" features

I have a layer of "lines" that I show on a map using WMS.
The map is used inside items and an item is something with a relation to the properties of the lines (features), say the feature has a property county and the map inside item X should display every line but mark the lines inside county X.
My task is to show the map with an extent that contains lines inside county X, not the max extent of all lines.

I wondered what is the best strategy.

My ideas:

1. First I get the extent of the lines filtered by county=X and I use the resulting bbox in a getMap

2. I use some function that changes the extent of the result of the getMap call inside the sld (I don't know if thi is possible)

3. other

Thank you

   maxx

Il 11/28/2014 07:42 PM, emmexx scrisse:

1. First I get the extent of the lines filtered by county=X and I use
the resulting bbox in a getMap

I found an old post of Andrea Aime that suggested to use WPS and the gs:Bounds function:
https://www.mail-archive.com/geoserver-users@lists.sourceforge.net/msg06097.html

I installed WPS and tried to use it to no avail. I get the bbox of all the features in the layer, not only the filtered ones.

The following is the xml file I POST using curl.
What am I doing wrong?

Thank you
   maxx

<?xml version="1.0" encoding="UTF-8"?>
<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xmlns="http://www.opengis.net/wps/1.0.0&quot; xmlns:wfs="http://www.opengis.net/wfs&quot; xmlns:wps="http://www.opengis.net/wps/1.0.0&quot; xmlns:ows="http://www.opengis.net/ows/1.1&quot; xmlns:gml="http://www.opengis.net/gml&quot; xmlns:ogc="http://www.opengis.net/ogc&quot; xmlns:wcs="http://www.opengis.net/wcs/1.1.1&quot; xmlns:xlink="http://www.w3.org/1999/xlink&quot; xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd&quot;&gt;
   <ows:Identifier>gs:Bounds</ows:Identifier>
   <wps:DataInputs>
     <wps:Input>
       <ows:Identifier>features</ows:Identifier>
    <wps:Reference mimeType="text/xml; subtype=wfs-collection/1.0" xlink:href="http://geoserver/wfs&quot; method="POST">
         <wps:Body>
           <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:mywks="http://mysite.org">
             <wfs:Query typeName="mywks:mylayer"/>
               <ogc:Filter>
    <ogc:PropertyIsEqualTo>
     <ogc:PropertyName>tags</ogc:PropertyName> <ogc:Literal>53</ogc:Literal>
  </ogc:PropertyIsEqualTo>
               </ogc:Filter>
           </wfs:GetFeature>
         </wps:Body>
       </wps:Reference>
     </wps:Input>
   </wps:DataInputs>
   <wps:ResponseForm>
     <wps:RawDataOutput>
       <ows:Identifier>bounds</ows:Identifier>
     </wps:RawDataOutput>
   </wps:ResponseForm>
</wps:Execute>

Il 11/29/2014 04:02 PM, emmexx scrisse:

I installed WPS and tried to use it to no avail. I get the bbox of all
the features in the layer, not only the filtered ones.

I made other tests using other wps functions but the result is the same: no filtering. (I used vec:Query, vec:Bounds)

Is there some special setting of the WPS service to enable?

Thank you
   maxx

Hi,

I would spend some time with studying what happens with the WFS request that is feeding data for the WPS process. I can imagine that if the filter used for filtering WFS is not accepted then it will be ignored and WFS returns the whole featuretype. In this case the WPS process would always report the full BBOX as bounds.

On the other hand, if WFS returns only the right features and the WPS process still computes wrong extents then there must be something badly wrong with the code of the process. Because all the processes you have tried behave similarly as if the results from WFS were not filtered at all I would suspect even stronger that it is the truth and WFS filters are ignored.

-Jukka Rahkonen-

________________________________________
emmexx wrote:

Il 11/29/2014 04:02 PM, emmexx scrisse:

I installed WPS and tried to use it to no avail. I get the bbox of all
the features in the layer, not only the filtered ones.

I made other tests using other wps functions but the result is the same:
no filtering. (I used vec:Query, vec:Bounds)

Is there some special setting of the WPS service to enable?

Thank you
   maxx

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Il 11/30/2014 06:36 PM, Rahkonen Jukka (Tike) scrisse:

I would spend some time with studying what happens with the WFS
request that is feeding data for the WPS process. I can imagine that
if the filter used for filtering WFS is not accepted then it will be
ignored and WFS returns the whole featuretype. In this case the WPS
process would always report the full BBOX as bounds.

Hi Jukka,

I'm a little bit confused by the results of my tests and by my limited knowledge of geoserver and its parts.

I followed your suggestion and used the Demo requests to retrieve the filtered data.
I get the expected results:
- if I filter by geometry looking for Points I get null (my fetaures are lines)
- if I filter by propertyName I get only the features whose attribute has the value I entered in the filter.

So wfs alone works.

On the other hand, if WFS returns only the right features and the WPS
process still computes wrong extents then there must be something
badly wrong with the code of the process. Because all the processes
you have tried behave similarly as if the results from WFS were not
filtered at all I would suspect even stronger that it is the truth
and WFS filters are ignored.

I tried the vec.Query function using a CQL filter and it works.

I tried it using the WPS request builder but I don't know the syntax and the wfs syntax doesn't work.
I cose vec:Query, VECTOR_LAYER and my layer. As filter type I chose TEXT and entered in the textbox:
<ogc:Filter>
    <ogc:PropertyIsEqualTo>
<ogc:PropertyName>tags</ogc:PropertyName>
<ogc:Literal>53</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
Executing I got:
<wps:ProcessFailed><ows:ExceptionReport version="1.1.0"><ows:Exception exceptionCode="NoApplicableCode"><ows:ExceptionText>Process failed during execution
Process execution c023f90b-b4d4-4c2f-bad2-12ffbdd34e77 failed
Failed to retrieve value for input filter
The prefix &quot;ogc&quot; for element &quot;ogc:Filter&quot; is not bound.</ows:ExceptionText></ows:Exception></ows:ExceptionReport></wps:ProcessFailed>

In the geoserver log the error is more specific:
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 13; The prefix "ogc" for element "ogc:Filter" is not bound.

I don't know the meaning of not bound in this context (sorry).

I don't know if this is related to the problem in my original post.

If I try to execute the wps in my original post, the geoserver log reports:

2014-11-30 17:05:09,441 INFO [geoserver.wps] -
Request: execute
     service = WPS
     version = 1.0.0
     baseUrl = http://localhost:8080/geoserver/
     identifier:
         value = gs:Bounds
     dataInputs:
         input[0]:
             identifier = net.opengis.ows11.impl.CodeTypeImpl@anonymised.com (value: features, codeSpace: null)
             reference = net.opengis.wps10.impl.InputReferenceTypeImpl@anonymised.com (body: net.opengis.wfs.impl.GetFeatureTypeImpl@anonymised.com (handle: null, service: WFS, version: 1.0.0, baseUrl: null, providedVersion: null, extendedProperties: {}) (maxFeatures: null, outputFormat: GML2, resultType: <unset>, traverseXlinkDepth: null, traverseXlinkExpiry: null, formatOptions: null, metadata: null, startIndex: null, viewParams: null), encoding: null, href: http://geoserver/wfs, method: POST, mimeType: text/xml; subtype=wfs-collection/1.0, schema: null)
     responseForm:
         rawDataOutput:
             identifier = net.opengis.ows11.impl.CodeTypeImpl@anonymised.com (value: bounds, codeSpace: null)

I hope all these infos can help some of you to address me in the right direction.

Thank you
   maxx
        

Il 11/30/2014 11:04 PM, emmexx scrisse:

I don't know if this is related to the problem in my original post.

If I try to execute the wps in my original post, the geoserver log reports:

I found out the problem, my fault of course, and my bad. :frowning:

In my xml request I dumb-copied Andrea's code:

<wfs:Query typeName="mywks:mylayer"/>

But by adding a filter it should be:
<wfs:Query typeName="mywks:mylayer"> (notice the missing closing slash)
<ogc:Filter>
...

bye
  maxx