Message from discussion
Spatial Cypher in REST
Received: by 10.50.0.148 with SMTP id 20mr6085479ige.3.1349189879261;
Tue, 02 Oct 2012 07:57:59 -0700 (PDT)
X-BeenThere: neo4j@googlegroups.com
Received: by 10.50.140.40 with SMTP id rd8ls5040293igb.2.canary; Tue, 02 Oct
2012 07:57:57 -0700 (PDT)
Received: by 10.42.80.3 with SMTP id t3mr10161637ick.24.1349189877462;
Tue, 02 Oct 2012 07:57:57 -0700 (PDT)
Received: by 10.42.80.3 with SMTP id t3mr10161632ick.24.1349189877444;
Tue, 02 Oct 2012 07:57:57 -0700 (PDT)
Return-Path: <ver...@gmail.com>
Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182])
by gmr-mx.google.com with ESMTPS id us14si186443igb.3.2012.10.02.07.57.57
(version=TLSv1/SSLv3 cipher=OTHER);
Tue, 02 Oct 2012 07:57:57 -0700 (PDT)
Received-SPF: pass (google.com: domain of ver...@gmail.com designates 209.85.223.182 as permitted sender) client-ip=209.85.223.182;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ver...@gmail.com designates 209.85.223.182 as permitted sender) smtp.mail=ver...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-ie0-f182.google.com with SMTP id k10so13456743iea.13
for <neo4j@googlegroups.com>; Tue, 02 Oct 2012 07:57:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:from:date:message-id:subject:to:content-type;
bh=njieA7svOIwcVEXmG8dWkAgnUyjBJd6OBxKSYB6E4Lc=;
b=UwqsVk8URpTcpvYqshSW0l6fmgVm9qczuPOGXE9kLuCNnkHcJBe5MYVlSduRVljsq+
zyWlwuDFLqjbkIZ1A2935u40rGZoUI+m33lbOHEiT2j1znmRBTy7Od/LfLp8SFtr0C1L
XoIpCsoHKGrEqQKgtOluKIOcHGT/tGt0jaUrQFJfPpy1S72/8mG2a6I0vBPVYZUzxOgc
mRqfYO1vDMBgMsMPm8S4COOfzN+joVHHYE7qh/vYA45hHjbD+DF8h2cLlpla0Yc41n7z
TovMuLE9Kc8Vhoov9VVIUL4XhiTejTf2nKYqlzKMZriTihZEgCUWh1kY8NEeThTjfBVP
WDdA==
Received: by 10.50.236.41 with SMTP id ur9mr9060569igc.7.1349189876884; Tue,
02 Oct 2012 07:57:56 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.50.160.225 with HTTP; Tue, 2 Oct 2012 07:57:26 -0700 (PDT)
From: Javier de la Rosa <ver...@gmail.com>
Date: Tue, 2 Oct 2012 10:57:26 -0400
Message-ID: <CALZ64-4+Xvbxr+8CsMHWeqih-NVS4NCxF=Cj2mQs8x5n=cp...@mail.gmail.com>
Subject: Spatial Cypher in REST
To: neo4j@googlegroups.com
Content-Type: multipart/alternative; boundary=14dae93408fb58a57904cb14bf43
--14dae93408fb58a57904cb14bf43
Content-Type: text/plain; charset=ISO-8859-1
Hi all,
I was starting to do some experiments with Spatial Neo4j when realized that
there is no easy way to make queries using Cypher. All i found is a couple
of threads [1, 2]. So, I was just wondering if there is any way to make
real spatial queries using Cypher, and therefore using REST API.
I was thinking in something like the standard defined by OGC [3], that is
used in spatial extensions like PostGIS or SpatiaLite. With this, we could
have complex geometry classes like Geometry, Point, Curve, LineString,
Surface, Polygon, PolyhedralSurface, GeomCollection, MultiCurve,
MultiLineString, MultiSurface, MultiPolygon, and MultiPoint. And the
corresponding representation in binary, text, GeoJSON or WKT. I like WKT
and it is a very versatile and powerful way to express geometrical objects.
Let's say that we can define those objects using WKT and a prefix, 'ST_',
to denote spatial function
CREATE n = {name : 'Andres', title : 'Developer', place : ST_WKT('POLYGON
((15 56, 15 57, 16 57, 16 56, 15 56))')}
And then, guess we have an index with nodes that represent world
boundaries. In this case, what I would like to have is something like
CREATE n = {label : 'Germany', area : ST_WKT('MULTYPOLYGON((...))')}
START n=node(*), m=node(*), b=node:WORLD_BOUNDARIES("label:Germany") MATCH
n-[r:FRIEND]->m WHERE ST_Contains(b.area, n.place) AND ST_Contains(b.area,
m.place) RETURN ST_Distance(ST_Centroid(n.place), ST_Centroid(m.place))
This query above should return the distance between two friends that live
in Germany.
All functions are already defined in the standard [4] that includes
ST_Equals, ST_Disjoint, ST_Intersects, ST_Touches, ST_Crosses, ST_Within,
ST_Contains, ST_Overlaps, ST_Intersection, ST_Difference, ST_Union,
ST_StartPoint, ST_EndPoint, ST_IsRing, ST_Length, ST_NumPoints, ST_PointN,
ST_Centroid, ST_PointOnSurface, ST_Area and more.
So, is there any plan to support complex spatial queries in Cypher like
this ones? I wish I knew enough Java to give a hand.
Best regards.
[1] http://neo4j.org/nabble/#nabble-td3500531
[2] https://groups.google.com/forum/#!msg/neo4j/7fBtZBLAwSY/zlKNBqteFEwJ
[3] http://www.opengeospatial.org/standards/sfs
[4] http://portal.opengeospatial.org/files/?artifact_id=25354
--
Javier de la Rosa
http://versae.es
--14dae93408fb58a57904cb14bf43
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>Hi all,</div><div><br></div><div>I was starting to do some experiments=
with Spatial Neo4j when realized that there is no easy way to make queries=
using Cypher. All i found is a couple of threads [1, 2]. So, I was just wo=
ndering if there is any way to make real spatial queries using Cypher, and =
therefore using REST API.</div>
<div><br></div><div>I was thinking in something like the standard defined b=
y OGC [3], that is used in spatial extensions like PostGIS or SpatiaLite. W=
ith this, we could have complex geometry classes like Geometry, Point, Curv=
e, LineString, Surface, Polygon, PolyhedralSurface, GeomCollection, MultiCu=
rve, MultiLineString, MultiSurface, MultiPolygon, and MultiPoint. And the c=
orresponding representation in binary, text, GeoJSON or WKT. I like WKT and=
it is a very versatile and powerful way to express geometrical objects.</d=
iv>
<div><br></div><div>Let's say that we can define those objects using WK=
T and a prefix, 'ST_', to denote spatial function</div><div><br></d=
iv><div>CREATE n =3D {name : 'Andres', title : 'Developer',=
place : ST_WKT('POLYGON ((15 56, 15 57, 16 57, 16 56, 15 56))')}</=
div>
<div><br></div><div>And then, guess we have an index with nodes that repres=
ent world boundaries. In this case, what I would like to have is something =
like</div><div><br></div><div>CREATE n =3D {label : 'Germany', area=
: ST_WKT('MULTYPOLYGON((...))')}</div>
<div><br></div><div>START n=3Dnode(*), m=3Dnode(*), b=3Dnode:WORLD_BOUNDARI=
ES("label:Germany") MATCH n-[r:FRIEND]->m WHERE ST_Contains(b.=
area, n.place) AND ST_Contains(b.area, m.place) RETURN ST_Distance(ST_Centr=
oid(n.place), ST_Centroid(m.place))</div>
<div><br></div><div>This query above should return the distance between two=
friends that live in Germany.</div><div><br></div><div>All functions are a=
lready defined in the standard [4] that includes ST_Equals, ST_Disjoint, ST=
_Intersects, ST_Touches, ST_Crosses, ST_Within, ST_Contains, ST_Overlaps, S=
T_Intersection, ST_Difference, ST_Union, ST_StartPoint, ST_EndPoint, ST_IsR=
ing, ST_Length, ST_NumPoints, ST_PointN, ST_Centroid, ST_PointOnSurface, ST=
_Area and more.</div>
<div><br></div><div>So, is there any plan to support complex spatial querie=
s in Cypher like this ones? I wish I knew enough Java to give a hand.</div>=
<div><br></div><div>Best regards.</div><div><br></div><div><br></div><div>
<br></div><div><br></div><div><br></div><div>[1] <a href=3D"http://neo4j.or=
g/nabble/#nabble-td3500531">http://neo4j.org/nabble/#nabble-td3500531</a></=
div><div>[2] <a href=3D"https://groups.google.com/forum/#!msg/neo4j/7fBtZBL=
AwSY/zlKNBqteFEwJ">https://groups.google.com/forum/#!msg/neo4j/7fBtZBLAwSY/=
zlKNBqteFEwJ</a></div>
<div>[3] <a href=3D"http://www.opengeospatial.org/standards/sfs">http://www=
.opengeospatial.org/standards/sfs</a></div><div>[4] <a href=3D"http://porta=
l.opengeospatial.org/files/?artifact_id=3D25354">http://portal.opengeospati=
al.org/files/?artifact_id=3D25354</a></div>
<div><br></div><div><br></div><div>--</div><div>Javier de la Rosa</div><div=
><a href=3D"http://versae.es">http://versae.es</a></div>
--14dae93408fb58a57904cb14bf43--