neo4j-contrib / spatial

Neo4j Spatial is a library of utilities for Neo4j that faciliates the enabling of spatial operations on data. In particular you can add spatial indexes to already located data, and perform spatial operations on the data like searching for data within specified regions or within a specified distance of a point of interest. In addition classes are provided to expose the data to geotools and thereby to geotools enabled applications like geoserver and uDig.

Home Page:http://neo4j-contrib.github.io/spatial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to call procedure `spatial.addNodes(layerName :: STRING?, nodes :: LIST? OF NODE?) :: (node :: NODE?)`: java.lang.String cannot be cast to java.lang.Number

tallavi opened this issue · comments

Hi,

Not exactly a neo4j-spatial issue, but I believe the best solution may lie here.

I'm inserting nodes using spring data neo4j, and the lat/lon properties are being inserted as strings. As it turns out, SDN inserts all properties as string, even the BigDecimals, so the resulting node looks like this:

 "nodes": [
              {
                "id": "9515",
                "labels": [
                  "EndPoint"
                ],
                "properties": {
                  "latitude": "31.843782",
                  "longitude": "35.009181"
                }
              }

Notice the parentheses around latitude and longitude values.

I wasn't able to find a way to insert the values as numerals instead of strings (other than inserting them manually instead of using a repository). So my only option right now is to convert the properties to other properties:

MATCH (e:EndPoint)
WITH e, toFloat(e.longitude) as longitudeDecimal, toFloat(e.latitude) as latitudeDecimal
SET e.longitudeDecimal = longitudeDecimal, e.latitudeDecimal = latitudeDecimal
RETURN count(e)

and use the new ones for indexing.

I believe the best course of action is to do the floating conversion inside the 'addNode'.

Also, I think that a better error message, noting the value that could not be converted + the id of the node should be useful.