Wow that's great! I'll try it out asap. This leads to my next question: how do I update the geometry in a layer, rather than add new? What I am thinking of doing is having a multipoint geometery associated with each of my user nodes which will represent their location history. My plan is to add the geometry to a "world" layer and then associate the returned node with the user. How do I then add new points to that connecter node? Can I just edit the wkt and assume the index will update? Or do you have a better suggestion for doing this? I would rather avoid having each point be a seperate node as I am tracking gps data and getting lots of coordinates, it would be many thousands of nodes per user.
Many thanks! > > > On Sat, Jul 2, 2011 at 6:48 AM, Craig Taverner <[email protected]> wrote: > >> Hi Boris, >> >> Ah! You are using the REST API. That changes a lot, since Neo4j Spatial is >> only recently exposed in REST and we do not expose most of the >> capabilities >> I have discussed in this thread, or indeed in my other answer today. >> >> I did recently add some REST methods that might work for you, specifically >> the addEditableLayer, which makes a WKB layer, and the >> addGeometryWKTToLayer, for adding any kind of Geometry (including >> LineString) to the layer. However, these were only added recently, and I >> have no experience using them myself, so consider this very much prototype >> code. From your other question today, can I assume you are having trouble >> making sense of the data coming back? So we need a better way to return >> the >> results in WKT instead of WKB? One option would be to enhance the >> addEditableLayer method to allow the creation of WKT layers instead of WKB >> layers, so the internal representation is more internet friendly. >> >> I've just added untested support for setting the format to WKT for the >> internal representation of the editable layer in the REST interface. This >> is >> untested (outside of my usual unit tests, that is), and is only in the >> trunk >> of neo4j-spatial, but you are welcome to try it out and see what happens. >> >> Regards, Craig >> >> On Fri, Jul 1, 2011 at 5:29 PM, Boris Kizelshteyn <[email protected]> >> wrote: >> >> > Hi Craig, >> > >> > Thanks so much for this reply. It is very insightful. Is it possible for >> me >> > to implement the LineString geometries and lookups using REST? >> > >> > Many thanks! >> > >> > On Wed, Jun 8, 2011 at 4:58 PM, Craig Taverner <[email protected]> >> wrote: >> > >> > > OK. I understand much better what you want now. >> > > >> > > Your person nodes are not geographic objects, they are persons that >> can >> > be >> > > at many positions and indeed move around. However, the 'path' that >> they >> > > take >> > > is a geographic object and can be placed on the map and analysed >> > > geographically. >> > > >> > > So the question I have is how do you store the path the person takes? >> Is >> > > this a bunch of position nodes connected back to that person? Or >> perhaps >> > a >> > > chain of position-(next)->position-(next)->position, etc? However you >> > have >> > > stored this in the graph, you can express this as a geographic object >> by >> > > implementing the GeometryEncoder interface. See, for example, the 6 >> lines >> > > of >> > > code it takes to traverse a chain of NEXT locations and produce a >> > > LineString >> > > geometry in the SimpleGraphEncoder at >> > > >> > > >> > >> https://github.com/neo4j/neo4j-spatial/blob/master/src/main/java/org/neo4j/gis/spatial/encoders/SimpleGraphEncoder.java#L82 >> > > >> > > < >> > > >> > >> https://github.com/neo4j/neo4j-spatial/blob/master/src/main/java/org/neo4j/gis/spatial/encoders/SimpleGraphEncoder.java#L82 >> > > >If >> > > you do this, you can create a layer that uses your own geometry >> encoder >> > (or >> > > the SimpleGraphEncoder I referenced above, if you use the same graph >> > > structure) and your own domain model will be expressed as LineString >> > > geometries and you can perform spatial operations on them. >> > > >> > > Alternatively, if your data is more static in nature, and you are >> > analysing >> > > only what the person did in the past, and the graph will therefor not >> > > change, perhaps you do not care to store the locations in the graph, >> and >> > > you >> > > can just import them as a LineString directly into a standard layer. >> > > >> > > Whatever route you take, the final action you want to perform is to >> find >> > > points near the LineString (path the person took). I do not think the >> > > bounding box is the right approach for that either. You need to try, >> for >> > > example, the method findClosestEdges in the utilities class at >> > > >> > > >> > >> https://github.com/neo4j/neo4j-spatial/blob/master/src/main/java/org/neo4j/gis/spatial/SpatialTopologyUtils.java#L115 >> > > >> > > < >> > > >> > >> https://github.com/neo4j/neo4j-spatial/blob/master/src/main/java/org/neo4j/gis/spatial/SpatialTopologyUtils.java#L115 >> > > >This >> > > method can find the part of the persons path that it closest to the >> point >> > > of >> > > interest. There also also many other geographic operations you might >> be >> > > interested in trying, once you have a better feel for the types of >> > queries >> > > you want to ask. >> > > >> > > Regards, Craig >> > > >> > > On Wed, Jun 8, 2011 at 2:17 AM, Boris Kizelshteyn <[email protected]> >> > > wrote: >> > > >> > > > Thanks for the detailed response! Here is what I'm trying to do and >> I'm >> > > > still not sure how to accomplish it: >> > > > >> > > > 1. I have a node which is a person >> > > > >> > > > 2. I have geo data as that person moves around the world >> > > > >> > > > 3. I use the geodata to create a bounding box of where that person >> has >> > > been >> > > > today >> > > > >> > > > 4. I want to say, was this person A near location X today? >> > > > >> > > > 5. I do this by seeing if location X is in A's bounding box. >> > > > >> > > > From looking at what you suggest doing, it's not clear how I assign >> the >> > > > node >> > > > person A to a layer? Is it that the bounding box is now in the layer >> > and >> > > > not >> > > > in the node? The issue then becomes, how od I associate the two as >> the >> > > > RTree >> > > > relationship seems to establish itself on the bounding box between >> the >> > > node >> > > > and the layer. >> > > > >> > > > Many thanks for your patience as I learn this challenging material. >> > > > >> > > > On Tue, Jun 7, 2011 at 4:13 PM, Craig Taverner <[email protected]> >> > wrote: >> > > > >> > > > > I think you need to differentiate the bounding boxes of the data >> in >> > the >> > > > > layer (stored in the database), and the bounding box of the search >> > > query. >> > > > > The search query is not stored in the database, and will not be >> seen >> > as >> > > a >> > > > > node or nodes in the database. So if you want to search for data >> > within >> > > > > some >> > > > > bounding box or polygon, then express that in the search query, >> and >> > you >> > > > do >> > > > > not need to care about how your nodes are stored in the database. >> > > > > >> > > > > So when you say you want to make a larger bounding box, I assume >> you >> > > are >> > > > > talking about the query itself. The REST API has the method >> > > > > findGeometriesInLayer, which takes minx, maxx, miny, maxy >> parameters >> > > and >> > > > > you >> > > > > can set those to whatever you want for your query. >> > > > > >> > > > > The REST API also exposes the CQL query language supported by >> > GeoTools. >> > > > > This >> > > > > allows you to perform SQL-like queries on geometries and feature >> > > > > attributes. >> > > > > For example, you can search for all objects within a specific >> polygon >> > > > (not >> > > > > just a rectangular bounding box), as well as conforming to certain >> > > > > attributes. See >> > > > > >> > > > >> > > >> > >> http://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.htmlfor >> > > > > some examples of CQL. >> > > > > >> > > > > However, our current CQL support is not fully integrated with the >> > RTree >> > > > > index. This means that the CQL itself will not benefit from the >> > index, >> > > > but >> > > > > be a raw search. You can, however, still get the benefit of the >> index >> > > by >> > > > > passing in the bounding box separately. So, for example, you want >> to >> > > > search >> > > > > for data in a polygon. Make the polygon object, get it's bounding >> box >> > > and >> > > > > also the CQL query string. Then make a 'dynamic layer' using the >> CQL >> > > > (which >> > > > > is a bit like making a prepared statement). Then perform the same >> > > > > 'findGeometriesInLayer' method mentioned above, using the bounding >> > box >> > > > and >> > > > > the dynamic layer (containing the CQL). This has the effect of >> using >> > > the >> > > > > RTree index for a first approximate search, followed by pure CQL >> for >> > > the >> > > > > final mile. >> > > > > >> > > > > See examples of this in action in the Unit tests in the source >> code. >> > > > > >> > > > > >> > > > >> > > >> > >> https://github.com/neo4j/neo4j-spatial/blob/master/src/test/java/org/neo4j/gis/spatial/ServerPluginTest.java#L109 >> > > > > has >> > > > > examples of CQL queries on the REST API. >> > > > > >> > > > > On Tue, Jun 7, 2011 at 5:48 PM, Boris Kizelshteyn < >> [email protected]> >> > > > > wrote: >> > > > > >> > > > > > Thanks! So it seems you are saying that the bounding box >> represents >> > a >> > > > > > single >> > > > > > point and is the same as the lat/lat lon? What if I make the >> > bounding >> > > > box >> > > > > > bigger? What I am trying to do is geo queries against a bounding >> > box >> > > > made >> > > > > > of >> > > > > > a set of points, rather than individual points. So the query is, >> > find >> > > > the >> > > > > > nodes where the given point falls inside their bounding boxes. >> Can >> > I >> > > do >> > > > > > this >> > > > > > with REST? >> > > > > > >> > > > > > Thanks! >> > > > > > >> > > > > > On Tue, Jun 7, 2011 at 11:34 AM, Craig Taverner < >> [email protected]> >> > > > > wrote: >> > > > > > >> > > > > > > Hi, >> > > > > > > >> > > > > > > The bounding boxes are used by the RTree index, which is a >> > typical >> > > > way >> > > > > to >> > > > > > > index spatial data. For Point data, the lat/long and the >> bounding >> > > box >> > > > > are >> > > > > > > the same thing, but for other shapes (streets/LineString and >> > > > Polygons), >> > > > > > the >> > > > > > > bounding box is quite different to the actual geometry (which >> is >> > > not >> > > > > just >> > > > > > a >> > > > > > > single lat/long, but a set of connected points forming a >> complex >> > > > > shape). >> > > > > > > >> > > > > > > The RTree does not differentiate between points and other >> > > geometries, >> > > > > > > because it cares only about the bounding box, and therefor we >> > > provide >> > > > > > that >> > > > > > > even for something as simple as a Point. >> > > > > > > >> > > > > > > Does that answer the question? >> > > > > > > >> > > > > > > Regards, Craig >> > > > > > > >> > > > > > > On Tue, Jun 7, 2011 at 4:57 PM, Boris Kizelshteyn < >> > > [email protected]> >> > > > > > > wrote: >> > > > > > > >> > > > > > > > Greetings! >> > > > > > > > >> > > > > > > > Perhaps someone using neo4j-spatial can answer this >> seemingly >> > > > simple >> > > > > > > > question. Nodes classified into layers have both lat/lon >> > > properties >> > > > > and >> > > > > > > > bounding boxes, the bounding box seems to be required to >> > > establish >> > > > > the >> > > > > > > > relationship between node and layer, however the node is not >> > > found >> > > > if >> > > > > > the >> > > > > > > > lat/lon does not match the query. Can someone explain the >> > > > > relationship >> > > > > > > > between these two properties on a node? >> > > > > > > > >> > > > > > > > Many thanks! >> > > > > > > > _______________________________________________ >> > > > > > > > Neo4j mailing list >> > > > > > > > [email protected] >> > > > > > > > https://lists.neo4j.org/mailman/listinfo/user >> > > > > > > > >> > > > > > > _______________________________________________ >> > > > > > > Neo4j mailing list >> > > > > > > [email protected] >> > > > > > > https://lists.neo4j.org/mailman/listinfo/user >> > > > > > > >> > > > > > _______________________________________________ >> > > > > > Neo4j mailing list >> > > > > > [email protected] >> > > > > > https://lists.neo4j.org/mailman/listinfo/user >> > > > > > >> > > > > _______________________________________________ >> > > > > Neo4j mailing list >> > > > > [email protected] >> > > > > >> > > > > >> > > > _______________________________________________ >> > > > Neo4j mailing list >> > > > [email protected] >> > > > https://lists.neo4j.org/mailman/listinfo/user >> > > > >> > > _______________________________________________ >> > > Neo4j mailing list >> > > [email protected] >> > > https://lists.neo4j.org/mailman/listinfo/user >> > > >> > _______________________________________________ >> > Neo4j mailing list >> > [email protected] >> > https://lists.neo4j.org/mailman/listinfo/user >> > >> _______________________________________________ >> Neo4j mailing list >> [email protected] >> https://lists.neo4j.org/mailman/listinfo/user >> > _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

