craigtaverner
released this
18 Sep 10:58
·
2 commits
to master
since this release
This is the first alpha release of Spatial-3D, and so far only supports 2D polygons as a foundation on which to build 3D polygon mesh support.
Currently working procedures are:
- amanzi.polygon(points) - takes a list of Point object and validates that they form a valid polygon, returning the validated list. This there is no Polygon type in Neo4j 3.4, the returned result is currently just a list of points. The only change is might make is to add the first point to the end of the list if it is not already there. Future versions of this might return a map for more complex results including shells and holes.
Currently working user defined functions are:
- amanzi.boundingBoxFor(points) - returns a map with two k/v pairs for 'min' and 'max' points defining the bounding box. This is designed to work with the spatial range queries in Neo4j 3.4.
- amanzi.withinPolygon(point,points) - does a point-in-polygon check returning true or false. Designed to be used as a predicate in Neo4j 3.4, but will not be index backed, which is why you need the bounding box function as well in order to use the existing index-backed bounding box query in Neo4j 3.4
Note: There appears to be a bug in Neo4j 3.4 (tested 3.4.7) where bounds with dependencies (eg. created like above) cannot get index support. This is reported and hopefully fixed in a later version of 3.4.x. In the meantime, you can work around the bug by calculating a center and radius and using the distance function which does not have this bug.
For example, this query using a polygon saved on a node in an OSM dataset:
MATCH (r:OSMRelation) USING INDEX SEEK r:OSMRelation(relation_osm_id)
WHERE r.relation_osm_id=8398124
WITH r.polygon as manhattan, amanzi.boundingBoxFor(r.polygon) as bbox
WITH manhattan, distance(bbox.min,bbox.max)/2.0 AS radius, point({latitude:(bbox.min.y+bbox.max.y)/2.0,longitude:(bbox.min.x+bbox.max.x)/2.0}) as center
MATCH (p:PointOfInterest) USING INDEX SEEK p:PointOfInterest(location)
WHERE distance(p.location,center) < radius
AND amanzi.withinPolygon(p.location,manhattan)
RETURN count(p)