Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-12-2022 09:13 AM
Hi, i have to import the nodes 'Linea', taken from a json file, into the 'spatial' layer i created: but unfortunately, running the script on the prompt, i get this error.
Can you help me?
The nodes not are simple points, but they have a geometry wkt with type MultiLineString and coordinates.
12-12-2022 09:41 AM
What is the error?
12-12-2022 10:12 AM
I don't get it, I put it back in the prompt image.
It tells me "java.lang.NullPointerException" and doesn't execute me "spatial.addNode", not reporting consequently the nodes in the spatial layer.
Thank you very much for helping
12-12-2022 11:44 AM
Which query is causing the NPE? You have three? The NPE must be occurring within one of the method or function calls.
just a few comments:
1) you have a sequence of ‘unwinds’. This will cause the Cartesian product of all the events of all the lists you are unwinding. As a result, I think you are getting the same list of points for each value of property. What does the jso look like? Maybe we can figure out the best way to extract the data
2) the ‘points’ variable will be a list, since it is created by collecting data. You then try to convert it to a string. This should have an issue.
3) in the last query, you are matching to get nodes ‘l’, then collecting into list ‘lines’, then unwinding to ‘n’. All this is unnecessary, since you will end up with the same rows as created from the match. As such, you could just match and pass ‘l’ to the addNodes method.
12-13-2022 01:43 AM
It gives me the NPE when running the third query, the one with spatial.addNode.
The json file looks like this, what could I have done wrong?
this is the example of a node:
12-13-2022 03:49 AM
the NPE must be occurring in the spatial.addNode method. What is the method doing? I suspect it needs data in one or more properties and you are not providing at least one of those properties. When the missing property is accessed it is null, and that is causing a problem in the method’s code.
What is the method doing so we can figure out the issue?
12-13-2022 06:10 AM
The spatial.addNode should add nodes to the spatial layer, created in the above query with the spatial.addWKTLayer('spatial', 'geometry') method.
Maybe it can't access the 'geometry' property, but I don't understand what I could have done wrong with importing the multilinestrings. Seeing the json file, how would you import them?
12-13-2022 10:05 AM
The geometry property is set to the value of pointString, which is set using the apoc method. The issue here is that you are passing a list to convert to a string. The method will convert a list such as [1,2,3] to ‘[1,2,3]’. What is the structure if the data that addWKTLayer expects for the ‘geometry’ property? Is there documentation I can read?
12-13-2022 10:09 AM
The multilinestring data structure I need to import is this:
12-13-2022 10:22 AM
But what does the addNode method expect of the property ‘geometry’?
12-13-2022 10:30 AM
But I don't know, maybe it's related to spatial.addWKTLayer; I've never done such a thing before and took a cue from https://neo4j-contrib.github.io/spatial/0.24-neo4j-3.1/index.html.
Anyway, how would you import multilinestrings, how would you create a 'geometry' property with wkt geometry?
All the sessions of the conference are now available online