There are several ways to set the CRS in the Geometry, but this probably wont fix your problem. I just worry that the code is setting your Geometry to the default EPSG and that's why it cant figure it out. Also there are some Geometry limits, like crossing the antemeridian. If you are crossing the antemeridian you can try shifting your polygon from 180, -180 to 0, 360 or break it into 2 pieces.
You can do an EPSG check: geometry.getSRID(). Example 1: create an Envelope and then create the Geometry Envelope impactEnvelope = new ReferencedEnvelope(newMinX, maxx, miny, maxy, CRS.decode("EPSG:4326")); Geometry myGeom = JTS.toGeometry(impactEnvelope).getEnvelope();; example 2: use mathTransform MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false); Geometry targetGeometry = JTS.transform( myGeom, transform); Hope this helps! Dominique Bessette Senior Software Engineer From: Oscar Wu <oscar...@crmltd.ca> Sent: Thursday, March 24, 2022 11:23 AM To: Bessette-Halsema, Dominique E <dominique.besse...@gdit.com>; geoserver-users@lists.sourceforge.net Subject: Re: [EXTERNAL] - RE: WPS gs:Clip Topology Exception [External: Use caution with links & attachments] Hi Dominique, Thank you very much for the suggestion. I tried to explicitly define the EPSG in the getFeature request by adding srsName=EPSG:3005 to the url. The clipping geometry has no place to add SRS as it is only a geometry not a feature. However, I have made sure the coordinates in the clipping geometry are also generated under EPSG:3005. That being said, it unfortunately did not solve the issue. Is there anything else I can try? Thanks! Oscar ________________________________ From: Bessette-Halsema, Dominique E <dominique.besse...@gdit.com<mailto:dominique.besse...@gdit.com>> Sent: March 24, 2022 9:30 AM To: Oscar Wu <oscar...@crmltd.ca<mailto:oscar...@crmltd.ca>>; geoserver-users@lists.sourceforge.net<mailto:geoserver-users@lists.sourceforge.net> <geoserver-users@lists.sourceforge.net<mailto:geoserver-users@lists.sourceforge.net>> Subject: [EXTERNAL] - RE: WPS gs:Clip Topology Exception You may want to try specifying your EPSG in your Polygon and getFeature request Dominique Bessette Senior Software Engineer From: Oscar Wu <oscar...@crmltd.ca<mailto:oscar...@crmltd.ca>> Sent: Wednesday, March 23, 2022 1:02 PM To: geoserver-users@lists.sourceforge.net<mailto:geoserver-users@lists.sourceforge.net> Subject: [Geoserver-users] WPS gs:Clip Topology Exception [External: Use caution with links & attachments] Hi everyone, First time posting here, thank you for your understanding if I am not explaining my situation well. I've been trying to use the built-in gs:Clip to extract some public layers based on a polygon defined by coordinates. The process seemed to work well with a couple of layers until I tried it with one particular layer. Here's the xml in the POST request: <?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance<https://urldefense.us/v3/__http:/www.w3.org/2001/XMLSchema-instance__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlI2ApylXA$>" xmlns="http://www.opengis.net/wps/1.0.0"<https://urldefense.us/v3/__http:/www.opengis.net/wps/1.0.0*22__;JQ!!JRQnnSFuzw7wjAKq6ti6!lWi8-ZpfeBpVXzABGU-5yNnZNU21PJH7Uuw1mhAHL4oaSnQZGvwCFV3FQ_4yHdJ6SAxCew$> xmlns:wfs="http://www.opengis.net/wfs<https://urldefense.us/v3/__http:/www.opengis.net/wfs__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlKp1Xbehw$>" xmlns:wps="http://www.opengis.net/wps/1.0.0<https://urldefense.us/v3/__http:/www.opengis.net/wps/1.0.0__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlIn312I5A$>" xmlns:ows="http://www.opengis.net/ows/1.1<https://urldefense.us/v3/__http:/www.opengis.net/ows/1.1__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlKeD7F_oQ$>" xmlns:gml="http://www.opengis.net/gml<https://urldefense.us/v3/__http:/www.opengis.net/gml__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlK_I__oxQ$>" xmlns:ogc="http://www.opengis.net/ogc<https://urldefense.us/v3/__http:/www.opengis.net/ogc__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlKdc1gmIw$>" xmlns:wcs="http://www.opengis.net/wcs/1.1.1<https://urldefense.us/v3/__http:/www.opengis.net/wcs/1.1.1__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlKB59KQsg$>" xmlns:xlink="http://www.w3.org/1999/xlink<https://urldefense.us/v3/__http:/www.w3.org/1999/xlink__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlJsVIAlgQ$>" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd"><https://urldefense.us/v3/__http:/schemas.opengis.net/wps/1.0.0/wpsAll.xsd*22*3E__;JSU!!JRQnnSFuzw7wjAKq6ti6!lWi8-ZpfeBpVXzABGU-5yNnZNU21PJH7Uuw1mhAHL4oaSnQZGvwCFV3FQ_4yHdLoTCpOtw$> <ows:Identifier>gs:Clip</ows:Identifier> <wps:DataInputs> <wps:Input> <ows:Identifier>features</ows:Identifier> <wps:Reference mimeType="application/json" xlink:href="http://openmaps.gov.bc.ca/geo/pub/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=WHSE_CADASTRE.PMBC_PARCEL_FABRIC_POLY_SVW&outputFormat=json&bbox=715319.37219999917,1028613.3681000005,735025.99269999936,1041407.1950000003<https://urldefense.us/v3/__http:/openmaps.gov.bc.ca/geo/pub/ows?service=WFS&version=2.0.0&request=GetFeature&typeName=WHSE_CADASTRE.PMBC_PARCEL_FABRIC_POLY_SVW&outputFormat=json&bbox=715319.37219999917,1028613.3681000005,735025.99269999936,1041407.1950000003__;!!JRQnnSFuzw7wjAKq6ti6!gDSMzRRYpMIJOdp0JULuHTOMdeDoSlcttXPgVVdrVhMIp52bZxlKBiaq4bqpMlL1jQPNsQ$>" method="GET"/> </wps:Input> <wps:Input> <ows:Identifier>clip</ows:Identifier> <wps:Data> <wps:ComplexData mimeType="application/json"><![CDATA[{"type":"Polygon","coordinates":[[[715354.52820000052,1040603.9793999996],[715319.37219999917,1028613.3681000005],[734339.38680000044,1027297.6436000001],[735025.99269999936,1041407.1950000003],[715354.52820000052,1040603.9793999996]]]}]]></wps:ComplexData> </wps:Data> </wps:Input> </wps:DataInputs> <wps:ResponseForm> <wps:RawDataOutput mimeType="application/json"> <ows:Identifier>result</ows:Identifier> </wps:RawDataOutput> </wps:ResponseForm> </wps:Execute> In this case, a TopologyException was thrown (the stack trace is attached in the email): org.locationtech.jts.geom.TopologyException: found non-noded intersection between LINESTRING ( 737930.4267 1033205.5095, 737925.915 1033208.5901 ) and LINESTRING ( 737933.8941 1033203.0284, 737930.4267 1033205.5095 ) [ (737930.4267, 1033205.5095, NaN) ] I'm using Geoserver 2.20.2, GeoTools 26.2 and WPS 1.0.0. I have searched about this issue and learned that this is caused by invalid geometry which was explained here: https://locationtech.github.io/jts/jts-faq.html#D1<https://urldefense.us/v3/__https:/locationtech.github.io/jts/jts-faq.html*D1__;Iw!!JRQnnSFuzw7wjAKq6ti6!lWi8-ZpfeBpVXzABGU-5yNnZNU21PJH7Uuw1mhAHL4oaSnQZGvwCFV3FQ_4yHdLUVD9nQw$> Then I tried to create a customized WPS that 'clean' the input either using buffer(0) or the GeometryFixer in JTS before sending it to the clip process but neither of them solved the issue. I have exhausted my solutions to this problem and I'm wondering if anyone have encountered a similar issue before? May I have some suggestions about what to look for next? Thank you very much! Regards, Oscar
_______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users