[Geoserver-users] WFS query to calculate Area of a polygon?

I have a user who wants to send a shape and have GeoServer calculate the Area.
I see an Area function, which takes one parameter of type Geometry.
http://svn.geotools.org/geotools/branches/2.2.x/module/main/src/org/geotools/filter/function/FilterFunction_area.java
I see in our GetCapabilities that our GeoServer supports the Area function.

I know I don’t have the syntax correct in the request. Can anyone point out what I’m doing wrong?
I’m getting an error message at gml:Polygon “Invalid content was found starting with element gml:Polygon. One of
http:/www.opengis.net/ogc expression is expected”.
And it would seem that don’t need typeName, but it seems to require it…

<wfs:GetFeature xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs http://giswebservices.massgis.state.ma.us/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd

xmlns:gml=“http://www.opengis.net/gml” xmlns:wfs=“http://www.opengis.net/wfs
xmlns:ogc=“http://www.opengis.net/ogc” service=“WFS” version=“1.0.0”>
<wfs:Query typeName=“massgis:GISDATA.SCHOOLS_PT”
xmlns:massgis=“http://massgis.state.ma.us/featuretype”>
<ogc:Filter xmlns=“http://www.opengis.net/ogc”>
ogc:PropertyIsEqualTo
<ogc:Function name=“Area”>
<gml:Polygon srsName=“http://www.opengis.net/gml/srs/epsg.xml#26986”>
gml:outerBoundaryIs
gml:LinearRing
gml:coordinates55482.23359037,932685.310856 51792.79359037,932912.810856
51674.35359037,932515.310856 51544.14359038,932078.310856
49599.28359037,925512.060856 47775.54359037,919372.560856
47449.62359038,918279.440856 45808.45359038,912738.870856
45140.77359037,910497.620856 45004.94359038,910041.620856
45744.48359037,909868.310856 48668.97359037,909195.190856
50438.62359038,917473.120856 50803.29359037,917410.810856
50996.35359037,918202.000856 51108.95359038,918699.620856
55684.83359037,927925.440856 54440.55359038,928210.250856
55318.41359037,931999.120856 55482.23359037,932685.310856</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ogc:Function>
1
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

Aleda Freeman
MassGIS
Office of Geographic and Environmental Information
251 Causeway St. 5th floor
Boston, MA 02114
phone: 617-626-1193
fax: 617-626-1249
http://www.mass.gov/mgis - MassGIS
http://lyceum.massgis.state.ma.us - Webservices Wiki
http://maps.massgis.state.ma.us/biodiversity - EOEEA Biodiversity Days

Hi Aleda,

Unfortunately this kind of thing is not something you can really do with wfs. It falls more into the rhealm of WPS (web processing service) and is something that is not implented in geoserver... although i know there are implementations out there based on geoserver.

The problem with the request is that the "Function" element must contain expressions... for which gml:Polygon is not. You *might* be able to wrap it in a "Literal" element... but i doubt it. Even if you could GeoServer would not really give you an answer back... it would try to use the result to try and Filter the features from your dataset. In this case the area would probably not equal 1 so i would assume you get no features back.

-Justin

Freeman, Aleda (EEA) wrote:

I have a user who wants to send a shape and have GeoServer calculate the Area.
I see an Area function, which takes one parameter of type Geometry.
http://svn.geotools.org/geotools/branches/2.2.x/module/main/src/org/geotools/filter/function/FilterFunction_area.java

I see in our GetCapabilities that our GeoServer supports the Area function.

I know I don't have the syntax correct in the request. Can anyone point out what I'm doing wrong?
I'm getting an error message at gml:Polygon "Invalid content was found starting with element gml:Polygon. One of
http:/www.opengis.net/ogc expression is expected".
And it would seem that don't need typeName, but it seems to require it...

<wfs:GetFeature xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation = "http://www.opengis.net/wfs http://giswebservices.massgis.state.ma.us/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd "

    xmlns:gml = "http://www.opengis.net/gml&quot; xmlns:wfs = "http://www.opengis.net/wfs&quot;
    xmlns:ogc = "http://www.opengis.net/ogc&quot; service = "WFS" version = "1.0.0" >
    <wfs:Query typeName = "massgis:GISDATA.SCHOOLS_PT"
        xmlns:massgis = "http://massgis.state.ma.us/featuretype&quot; >
        <ogc:Filter xmlns = "http://www.opengis.net/ogc&quot; >
            <ogc:PropertyIsEqualTo>
            <ogc:Function name = "Area" >
                <gml:Polygon srsName = "http://www.opengis.net/gml/srs/epsg.xml#26986&quot; >
                    <gml:outerBoundaryIs>
                        <gml:LinearRing>
                            <gml:coordinates> 55482.23359037,932685.310856 51792.79359037,932912.810856
                                51674.35359037,932515.310856 51544.14359038,932078.310856
                                49599.28359037,925512.060856 47775.54359037,919372.560856
                                47449.62359038,918279.440856 45808.45359038,912738.870856
                                45140.77359037,910497.620856 45004.94359038,910041.620856
                                45744.48359037,909868.310856 48668.97359037,909195.190856
                                50438.62359038,917473.120856 50803.29359037,917410.810856
                                50996.35359037,918202.000856 51108.95359038,918699.620856
                                55684.83359037,927925.440856 54440.55359038,928210.250856
                                55318.41359037,931999.120856 55482.23359037,932685.310856 </gml:coordinates>
                        </gml:LinearRing>
                    </gml:outerBoundaryIs>
                </gml:Polygon>
            </ogc:Function>
                <Literal> 1 </Literal>
            </ogc:PropertyIsEqualTo>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

Aleda Freeman
MassGIS
Office of Geographic and Environmental Information
251 Causeway St. 5th floor
Boston, MA 02114
phone: 617-626-1193
fax: 617-626-1249
http://www.mass.gov/mgis - MassGIS
http://lyceum.massgis.state.ma.us - Webservices Wiki
http://maps.massgis.state.ma.us/biodiversity - EOEEA Biodiversity Days

!DSPAM:4007,46aa2d2e319326491211187!

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

!DSPAM:4007,46aa2d2e319326491211187!

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

!DSPAM:4007,46aa2d2e319326491211187!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org