Skip to main content

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

Hello William,

On Mon, Aug 10, 2020 at 11:19 AM William LaForest <lacapaneus@xxxxxxxxx> wrote:
First post here and I'm definitely no geospatial expert!  I have been using Spatial4j for stream processing and its been working great.  

Cool.  Just curious; how did you happen upon Spatial4j?
 
I am not implementing spherical functions and ran into a roadblock with the default SpacialContextFactory.  I know it supports spherical if you use point, circle, or rectangle but of course the trouble is that WKT and GeoJSON don't seem to support those shaes.

and you can BUFFER a point, in effect creating a circle.

And a POLYGON that is rectangular (that was perhaps read from either WKT or GeoJSON) can be auto-converted to the Rectangle Shape.
 
  One option was to detect when a person is passing in a rectangle in the GeoJSON or WKT then construct the shape myself rather than relying on the Spatial4jStringDeserializer. 

I've not heard of Spatial4jStringDeserializer; maybe it's in your codebase.
 
The other option I have been experimenting with is using the lucene extras Geo3d scf.  The later option seemed to work great but I only have rudimentary unit tests currently.  Any feedback on Geo3d or other advice?  

If you truly have a surface-of-sphere (or ellipsoid) requirement for polygons, then Geo3D is definitely what you should use.  But if it's just point-radius (circles), and lat-lon rectangles, then you don't need that.  Also note that some people think they need/want surface-of-sphere but they are working with polygon data that originated out of a system in which the polygon was built in a 2D environment... (e.g. a user was looking at a projected 2D map and plotted a bunch of points). and if that's the case, you should probably stay in 2D.
 

Also do you folks have good examples where euclidean returns a false positive which spherical would give you accurate results?  I was going to devise one but like I said this is not really my area of expertise so I figured someone out there may have some good examples.  Sincerest thanks in advance.

Look at some 4-point rectangle in a lat-lon space somewhat near one of the poles.  In 2D/euclidean, that horizontal line is true (does not curve) but in the real world, it does.  So if you plot a point directly midway on the border but just barely outside the box (towards the pole), then it'll be outside the box in 2D.  But in surface-of-sphere interpretation of that rectangle as a polygon, the point will be inside the shape because the edge curves above it.  For example, take the line of latitude 60 degrees north as the north edge of some rectangle. Let's say this is very wide, like 20 degrees longitude wide.  If you plot a point at like 60.5 North midway on that, in 2D that's clearly outside the rectangle because 60.5 > 60 (the north edge).  But in surface-of-sphere interpretation if these are 4 points of a polygon that is not really a "rectangle", then it'll curve north *above* 60.5.
Disclaimer:  I say all this off the top of my head but ideally I'd do more research and prepare a nice picture, maybe use Google Earth.

~ David

Back to the top