orientdb-spatial: should I extend OPoint?

53 views
Skip to first unread message

Gregory Mace

unread,
Dec 26, 2016, 1:41:39 PM12/26/16
to OrientDB
I've imported a large number of Objects that have location information in the form of:

POI
    bunch of other fields ...
    geometry:
         type: 'Point',
         coordinates: [ double, double ]   // lon, lat
         dimension:  (int size of coordinates )


I thought I would be able to look at the geometry field as an OPoint and run spatial queries on this  but I get an exception:

com.orientechnologies.orient.core.exception.OValidationException: impossible to convert value of field "geometry", incompatible with OPoint

Is there something I can do to realize this field (geometry) as an OPoint?  I do not really want to have an OPoint embedded in my domain class (in addition to what I have already), also am not quite sure if I can do that. I already have the geo info in my domain class so would rather not go through the extra effort of adding an additional field to the Vertex in order to do my spatial query.  Is there possibly a different way I can accomplish this?





Ivan Mainetti

unread,
Dec 26, 2016, 3:22:46 PM12/26/16
to OrientDB
Hi,
I hope I understood your need, I did the following test:

test data:
insert into POI set prop1="Sorint", geometry={"@class":"Geometry","type":"Point", "coordinates":[45.6474562,9.7055546]}
insert
into POI set prop1="TNT", geometry={"@class":"Geometry","type":"Point", "coordinates":[45.6483712,9.7072927]}

+----+-----+------+------+------------------------------------+
|#   |@RID |@CLASS|prop1 |geometry                            |
+----+-----+------+------+------------------------------------+
|0   |#23:0|POI   |Sorint|Geometry{coordinates:[2],type:Point}|
|1   |#24:0|POI   |TNT   |Geometry{coordinates:[2],type:Point}|
+----+-----+------+------+------------------------------------+


test query to find distance b/w 2 POIs above:
select ST_Distance_Sphere(ST_GEOMFROMTEXT("POINT(".append($a.geom1[0]).append(" ").append($a.geom2[0]).append(")")),ST_GEOMFROMTEXT("POINT(".append($b.geom1[0]).append(" ").append($b.geom2[0]).append(")"))) as distance


let $a
=(
 
select coordinates[0] as geom1, coordinates[1] as geom2 from (
 
select expand(geometry) from POI
 
where prop1 = "Sorint"
 
)
),
$b
=(
 
select coordinates[0] as geom1, coordinates[1] as geom2 from (
 
select expand(geometry) from POI
 
where prop1 = "TNT"
 
)
)


+----+------------------+
|#   |distance          |
+----+------------------+
|0   |217.98214528042894|
+----+------------------+


Gregory Mace

unread,
Dec 26, 2016, 5:18:32 PM12/26/16
to OrientDB

Gregory Mace

unread,
Dec 26, 2016, 5:19:16 PM12/26/16
to OrientDB
This looks like a good start for me. The exception I noted is from the Java API and whereas I can probably set the geometry as you indicated, I suspect I'll continue to get the exception if I don't define the 'geometry' field correctly in my domain class.

Enrico Risa

unread,
Dec 27, 2016, 4:33:04 AM12/27/16
to orient-...@googlegroups.com
Hi Gregory


the spatial module cannot realize that your object is a OPoint. In order to use the spatial functions and the spatial index
you should use directly OPoint as embedded property in your domain as written in the documentation

http://orientdb.com/docs/2.2/Spatial-Index.html

Thanks
Enrico

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages