2

I'd like to test whether a geometry (A) is located within another geometry (B). Geometry B already exists as a layer in my GeoServer instance. The WPS process parameters are:

<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>JTS:within</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>a</ows:Identifier>
      <wps:Data>
        <wps:ComplexData mimeType="application/json"><![CDATA[{
        "type": "Polygon",
        "coordinates": [
          [
            [
              6.9378662109375,
              51.50532341149335
            ],
            [
              7.5750732421875,
              51.50532341149335
            ],
            [
              7.5750732421875,
              51.70660846336452
            ],
            [
              6.9378662109375,
              51.70660846336452
            ],
            [
              6.9378662109375,
              51.50532341149335
            ]
          ]
        ]
      }]]></wps:ComplexData>
      </wps:Data>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>b</ows:Identifier>
      <wps:Reference mimeType="text/xml; subtype=wfs-collection/1.0" xlink:href="http://geoserver/wfs" method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2">
            <wfs:Query typeName="borders"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput>
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

Parameter b is a feature located in the borders layer. In borders only one feature exists.

After execution of this request, the following error occurs:

<?xml version="1.0" encoding="UTF-8"?>
<wps:ExecuteResponse
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:ows="http://www.opengis.net/ows/1.1"
  xmlns:wps="http://www.opengis.net/wps/1.0.0"
  xmlns:xlink="http://www.w3.org/1999/xlink" xml:lang="en" service="WPS" serviceInstance="http://localhost:8080/geoserver/ows?" version="1.0.0">
  <wps:Process wps:processVersion="1.0.0">
    <ows:Identifier>JTS:within</ows:Identifier>
    <ows:Title>Within Test</ows:Title>
    <ows:Abstract>Tests if the first geometry is contained in the second geometry.</ows:Abstract>
  </wps:Process>
  <wps:Status creationTime="2018-12-19T13:40:17.849Z">
    <wps:ProcessFailed>
      <ows:ExceptionReport version="1.1.0">
        <ows:Exception exceptionCode="NoApplicableCode">
          <ows:ExceptionText>Process failed during execution
Could not convert net.opengis.wfs.impl.FeatureCollectionTypeImpl@9a5a1f9 (lockId: null, timeStamp: java.util.GregorianCalendar[time=1545226817853,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id=&amp;quot;GMT&amp;quot;,offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=11,WEEK_OF_YEAR=51,WEEK_OF_MONTH=4,DAY_OF_MONTH=19,DAY_OF_YEAR=353,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=40,SECOND=17,MILLISECOND=853,ZONE_OFFSET=0,DST_OFFSET=0], numberOfFeatures: 0, feature: [org.geoserver.wfs.TypeInfoCollectionWrapper$Simple@6d97082]) to target type org.locationtech.jts.geom.Geometry</ows:ExceptionText>
        </ows:Exception>
      </ows:ExceptionReport>
    </wps:ProcessFailed>
  </wps:Status>
</wps:ExecuteResponse>

How do I convert the geometry B to the correct type? How do I check whether a polygon is located within a feature of a WFS layer?

1

You can use the vec:CollectGeometries process to extract the default geometry from each feature in the collection (in your case just the one feature) and returns them as a GeometryCollection, which jts:within should be able to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.