Search code examples
playframeworkneo4jneo4j-spatial

Add NodeEntity directly into Neo4j-Spatial layer?


I have a class NodeA, annotated with @NodeEntity. It has many fields, including:

@Indexed
public Double lat;

@Indexed
public Double lon;

Note that NodeA is already capable of storing enough location information via lat and lon fields. I want to add nodes of type NodeA into a spatial layer, so that I can run spatial queries using GeoPipeline.

  1. How can I add NodeA objects directly into a spatial layer? Currently, I can only add Points such as new Coordinate(13.766, 55.566) into a spatial layer. (If there is no solution, how can I associate a NodeA node with its corresponding Coordinate node?)
  2. Do I need to add the nodes into a spatial Index separately?

I am using:

  • Java in Play!Framework 2.2.2 (Can be updated)
  • Embedded Neo4j-Spatial 0.13-neo4j-2.0.1 (Can be updated)

Edit: When I connect an already existing node of type NodeA to the RTREE_ROOT, GeoPipeline complains about missing bbox property of the NodeA node. (Sure enough, there is no bbox property in NodeA, but it is present in other nodes of type Coordinate).


Solution

  • The blog Find Van Gogh’s artworks next to you, with Neo4j Spatial and Spring Data Neo4j 3.0.1

    http://inserpio.wordpress.com/2014/04/03/artworks-spatial-search/

    does exactly what I was looking for. @NodeEntity contains a wkt property, and Nodes are added to a SpatialRepository.