OrientDB 3.0 ST_Equals behavior
OrientDB Version: 3.0 RC2 with Spatial module
I need to find object by coordinates. Also I need to check if any object with requested coordinates exists.
I`ve inserted one object
{
"@type": "d",
"@rid": "#43:1",
"@version": 1,
"@class": "AddressGeo",
"address": "Some Name",
"coords": {
"@type": "d",
"@version": 0,
"@class": "OPoint",
"coordinates": [
55.786396,
37.58378
]
}
}
Now I am trying to find it
select * from AddressGeo where ST_Equals (coords, 'POINT (55.786396 37.58378)') = true
Why the result is empty?
and in this case
select ST_Equals('POINT (55.786396 37.58378)', 'POINT (55.786396 37.58378)')
These works
select * from AddressGeo where ST_Within(coords, 'POINT (55.786396 37.58378)') = true
select * from AddressGeo where ST_Contains(coords, 'POINT (55.786396 37.58378)') = true
select * from AddressGeo where ST_Intersects(coords, 'POINT (55.786396 37.58378)') = true
but I need to find objects by exactly requested coordinates
Hi @futureglorydev
What you need here is ST_geomFromText() to convert POINT strings to actual points
eg.
select * from AddressGeo where ST_Within(coords, ST_GeomFromText('POINT (55.786396 37.58378)')) = true
see https://orientdb.com/docs/3.0.x/indexing/Spatial-Index.html#stgeomfromtext
Thanks
Luigi
@luigidellaquila Thanks! It works.
But before that I tried to use oPoint object as
select * from AddressGeo where ST_Equals(coords, {"@type":"d","@version":0,"@class":"OPoint","coordinates":[55.786396,37.5837]}) = true
Did nit work...
Is it not the result of ST_geomFromText()?
I'll double-check, maybe there is just a little difference in the syntax
Thanks
Luigi
@luigidellaquila
I still cannot understand why this expression is false...
select ST_Equals(ST_GeomFromText('POINT (55.78639 37.58378)'), ST_GeomFromText('POINT (55.78639 37.58378)'))
I need to find exactly the same Point.. Im trying
select * from AddressGeo where ST_Equals(coords, ST_GeomFromText('POINT (55.78639 37.58378)')) = true
but only ST_Within works
select * from AddressGeo where ST_Within(coords, ST_GeomFromText('POINT (55.78639 37.58378)')) = true
Is it ok to use ST_Within instead of ST_Equals in this case?
Hi @futureglorydev
This is really strange, let me try it
Thanks
Luigi
Hi @futureglorydev
I just pushed a little fix for this, you will find it in the 3.0.1 SNAPSHOT in a few minutes https://oss.sonatype.org/content/repositories/snapshots/com/orientechnologies/orientdb-community/3.0.1-SNAPSHOT/
Thanks
Luigi