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.