1

My application uses point queries to find stores based on a user's current location.

public class Store extends AbstractNode {

    @Indexed(indexType = IndexType.POINT, indexName = "ErrandLocation") 
    private String wkt;

   public void setLocation(float lat, float lon) {
      this.wkt = String.format("POINT( %.2f %.2f )",lat,lon);
   }
}

On saving a shop with shop.setLocation (12, 12); and I use the neo4j browser to inspect my nodes, the wkt value changes to POINT( 56.34 -2.80 ).

I do not understand why the value changes to this from POINT (12.00, 12.00).

F.O.O
  • 4,730
  • 4
  • 24
  • 34

1 Answers1

0

When you are calling shop.setLocation you are calling the setLocation method that you have shown in your question, which stores the properly formatted WKT string which is required by the spatial classes.:

public void setLocation(float lat, float lon) {
  this.wkt = String.format("POINT( %.2f %.2f )",lat,lon);
}

If you require access to the raw lat/lon for your own purposes, stick them in different properties and they will be persisted too.

JohnMark13
  • 3,709
  • 1
  • 15
  • 26