Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [spatial4j-dev] Geo3dSpatialContextFactory


I want to thank you again for your communication and help and apologize for the delay in getting back to you.  One of my daytime jobs got in the way ;)

So you guessed the problem. Points were in clockwise order which appears to be the order they are being generated with leaflet and mapbox.  I guess I will need to do some preprocessing and reorder points for this to work. 

One point of clarification, the default Spatial4J SpatialContextFactory supports rectangle on sphere but when using the WKT and GeoJSON readers it just can't deserialize those shapes?

On Wed, Aug 12, 2020 at 10:51 PM David Smiley <david.w.smiley@xxxxxxxxx> wrote:

On Wed, Aug 12, 2020 at 10:01 AM William LaForest <lacapaneus@xxxxxxxxx> wrote:

In re-reading my email I realize I was rather sloppy, apologies!  I said "I am not implementing" but meant "I am now implementing".  I am pretty sure you deduced that but just to be safe...

Yep; I figured.
In my testing when I do a rectangle with either the WKT or GeoJSON Reader and the default SpatialContextFactory I get the exception "java.text.ParseException: java.lang.UnsupportedOperationException: Unsupported shape of this SpatialContext. Try JTS or Geo3D."  My guess is that I need to configure the factory in some fashion but in looking at the javadocs its not clear to me how.

That exception happens when you try to parse a polygon with the default SpatialContext but will not happen if you use the Jts or Geo3d ones.  Ideally, the default one would parse it to support a rectangular polygon only.
When I use the Geo3dSpatialContextFactory it parses fine but I am getting some inaccurate results from the relate function.

If you can supply a simple example then I could look into it.

BTW one common user-error with Geo3d:
When using Geo3D, the order of polygon points matters! You must follow the so-called "right hand rule": the exterior ring must be counter-clockwise order and the interior holes must be clockwise. If the order is wrong then the interpretation is inverted, thus the polygon will be interpreted as encompassing most of the globe.
~ David
spatial4j-dev mailing list
To unsubscribe from this list, visit

Back to the top