[Geoserver-users] WPS: Point in Polygon

I have implemented a custom WPS Process which returns a Geometry object
representing a Point.
What I need to do now is to chain this process with another (built-in one, I
guess) to answer the following question:

Within which polygon/feature (from a known published layer), if any, my
point is?

Unfortunately, I'm having a bad time trying to figure out the process that
will answer that question to me. Could you give me any direction about that?

Thanks

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WPS-Point-in-Polygon-tp5247850.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi,
that has an easy answer, it’s difficult to find a process that does not exist yet :wink:
You will have to implement it, it will be somehow similar to the clip one, that
you can use as a reference:

https://github.com/geotools/geotools/blob/master/modules/unsupported/process-feature/src/main/java/org/geotools/process/vector/ClipProcess.java

Cheers
Andrea

···

On Thu, Jan 28, 2016 at 7:37 PM, carrbrpoa <carrbrpoa@anonymised.com> wrote:

I have implemented a custom WPS Process which returns a Geometry object
representing a Point.
What I need to do now is to chain this process with another (built-in one, I
guess) to answer the following question:

Within which polygon/feature (from a known published layer), if any, my
point is?

Unfortunately, I’m having a bad time trying to figure out the process that
will answer that question to me. Could you give me any direction about that?

Thanks


View this message in context: http://osgeo-org.1560.x6.nabble.com/WPS-Point-in-Polygon-tp5247850.html
Sent from the GeoServer - User mailing list archive at Nabble.com.


Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140


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

==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.


Hello,
I used your link and this one
<http://docs.geotools.org/latest/userguide/tutorial/feature/csv2shp.html&gt;
to figure out how to build a SimpleFeatureCollection and changed my custom
process to output it. Then, I could do what I needed by invoking the
built-in WPS Process vec:InsersectionFeatureCollection.

Thanks for your help!

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WPS-Point-in-Polygon-tp5247850p5247879.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Actually, there is a problem when I choose IntersectionMode = INSERSECTION of
the process I mentioned. See:

In WPS request builder, the "An error occurred while encoding the results of
the process" message appears.

Trace:

2016-01-29 15:01:35,987 INFO [geoserver.filters] - 10.151.6.20 "POST
/geoserver/ows?strict=true" "Java/1.7.0_80" "" " "application/xml"
request-size: 2681 body:
<?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>vec:IntersectionFeatureCollection</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>first feature collection</ows:Identifier>
      <wps:Reference mimeType="text/xml" xlink:href="http://geoserver/wfs&quot;
method="POST">
        <wps:Body>
          <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2"
xmlns:smurb="smurb">
            <wfs:Query typeName="smurb:rops_3857"/>
          </wfs:GetFeature>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>second feature collection</ows:Identifier>
      <wps:Reference mimeType="text/xml" xlink:href="http://geoserver/wps&quot;
method="POST">
        <wps:Body>
          <wps:Execute version="1.0.0" service="WPS">
            <ows:Identifier>gs:GeocoderCodLogrGeom</ows:Identifier>
            <wps:DataInputs>
              <wps:Input>
                <ows:Identifier>codigo</ows:Identifier>
                <wps:Data>
                  <wps:LiteralData>7775026</wps:LiteralData>
                </wps:Data>
              </wps:Input>
              <wps:Input>
                <ows:Identifier>numero</ows:Identifier>
                <wps:Data>
                  <wps:LiteralData>1200</wps:LiteralData>
                </wps:Data>
              </wps:Input>
            </wps:DataInputs>
            <wps:ResponseForm>
              <wps:RawDataOutput mimeType="text/xml;
subtype=wfs-collection/1.0">
                <ows:Identifier>result</ows:Identifier>
              </wps:RawDataOutput>
            </wps:ResponseForm>
          </wps:Execute>
        </wps:Body>
      </wps:Reference>
    </wps:Input>
    <wps:Input>
      <ows:Identifier>intersectionMode</ows:Identifier>
      <wps:Data>
        <wps:LiteralData>INTERSECTION</wps:LiteralData>
      </wps:Data>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="text/xml; subtype=wfs-collection/1.0">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>

2016-01-29 15:01:35,989 INFO [geoserver.wps] -
Request: getServiceInfo
2016-01-29 15:01:36,124 INFO [geoserver.wps] -
Request: execute
    service = WPS
    version = 1.0.0
    baseUrl = http://lpmpa-geo-des3:8080/geoserver/
    identifier:
        value = vec:IntersectionFeatureCollection
    dataInputs:
        input[0]:
            identifier = net.opengis.ows11.impl.CodeTypeImpl@anonymised.com
(value: first feature collection, 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, schema:
null)input[0]:
            identifier = net.opengis.ows11.impl.CodeTypeImpl@anonymised.com
(value: second feature collection, codeSpace: null)
            reference =
net.opengis.wps10.impl.InputReferenceTypeImpl@anonymised.com (body:
net.opengis.wps10.impl.ExecuteTypeImpl@anonymised.com (language: null, service:
WPS, version: 1.0.0, baseUrl: null, extendedProperties: {}), encoding: null,
href: http://geoserver/wps, method: POST, mimeType: text/xml, schema:
null)input[0]:
            identifier = net.opengis.ows11.impl.CodeTypeImpl@anonymised.com
(value: intersectionMode, codeSpace: null)
            data = net.opengis.wps10.impl.DataTypeImpl@anonymised.com
    responseForm:
        rawDataOutput:
            identifier = net.opengis.ows11.impl.CodeTypeImpl@anonymised.com (value:
result, codeSpace: null)
            mimeType = text/xml; subtype=wfs-collection/1.0
2016-01-29 15:01:36,205 ERROR [geoserver.ows] -
org.geoserver.wps.WPSException: An error occurred while encoding the results
of the process
  at
org.geoserver.wps.response.ExecuteProcessResponse.writeComplex(ExecuteProcessResponse.java:229)
  at
org.geoserver.wps.response.ExecuteProcessResponse.write(ExecuteProcessResponse.java:194)
  at org.geoserver.ows.Dispatcher.response(Dispatcher.java:992)
  at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:279)
  at
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
  at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
  at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
  at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
  at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
  at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
  at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
  at
org.mortbay.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:175)
  at
org.mortbay.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:145)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at
org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:28)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at
org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:75)
  at
org.geoserver.wms.animate.AnimatorFilter.doFilter(AnimatorFilter.java:71)
  at
org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:71)
  at
org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:46)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at
org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:50)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
  at
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
  at
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
  at
org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
  at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
  at
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
  at
org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
  at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
  at
org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:54)
  at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
  at
org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
  at
org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
  at
org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:83)
  at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
  at
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
  at
org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:53)
  at
org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
  at
org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
  at
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
  at
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
  at
org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:135)
  at
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
  at
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:83)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:48)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at
org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:48)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:44)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at
org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
  at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
  at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
  at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
  at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
  at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
  at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
  at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
  at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
  at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
  at org.mortbay.jetty.Server.handle(Server.java:324)
  at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
  at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
  at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
  at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
  at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
  at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
  at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: java.lang.NullPointerException
  at
org.geotools.process.vector.IntersectionFeatureCollection$IntersectedFeatureIterator.hasNext(IntersectionFeatureCollection.java:510)
  at
org.geotools.feature.collection.BridgeIterator.hasNext(BridgeIterator.java:26)
  at org.geotools.xml.Encoder.encode(Encoder.java:719)
  at org.geoserver.wps.ppio.WFSPPIO.encode(WFSPPIO.java:215)
  at org.geoserver.wps.XMLEncoderDelegate.encode(XMLEncoderDelegate.java:31)
  at
org.geoserver.wps.response.ExecuteProcessResponse.writeComplex(ExecuteProcessResponse.java:225)
  ... 82 more

Do you have any ideas?

Thanks in advance

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WPS-Point-in-Polygon-tp5247850p5248048.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

I ended up solving this by returning a Polygon instead of a Point in my
custom process. Something like:

(...)
WKTReader wktReader = new WKTReader(new GeometryFactory());
Geometry geom = wktReader.read(pointString);
GeometryBuilder gb = new GeometryBuilder();
Point p = (Point)geom;
Polygon poly = gb.circle(p.getX(), p.getY(), 0.1, 4);

SimpleFeatureCollection collection = createFeatureCollection(poly);

return collection;

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WPS-Point-in-Polygon-tp5247850p5248704.html
Sent from the GeoServer - User mailing list archive at Nabble.com.