Skip to main content

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

On Tue, Aug 25, 2020 at 10:59 AM William LaForest <lacapaneus@xxxxxxxxx> wrote:
David,

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 ;)
 
NP.
 
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. 

It'd be nice if Geo3D had an option for this :-/. Feel free to file a feature-request sort of Lucene issue.  It's a common problem for anyone trying Geo3D.
 
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?

It can't deserialize polygons, even if the polygon happens to be a simple rectangle.  Furthermore, rectangles use a special ENVELOPE syntax this is semi-standard for WKT; I don't recall if JSON has any analog.  There is no circle shape in WKT or GeoJSON, but at least Spatial4j's WKT supports a custom "buffered point" to accomplish this meaning.

~ David
 


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.
 
Cheers,
~ David
_______________________________________________
spatial4j-dev mailing list
spatial4j-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/spatial4j-dev
_______________________________________________
spatial4j-dev mailing list
spatial4j-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/spatial4j-dev

Back to the top