You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Krzysztof Jezak <Kr...@everbridge.com> on 2016/05/10 20:18:39 UTC

geospatial queries?

Hi,

I am trying to join data in MongoDB with data in PostGIS.
Everything works great until I will use geospatial queries.
I was hoping that maybe you can help how can I make these queries work:

Test 1
Show geo data: returns null:
SELECT ST_AsText(current_location) FROM postgis.public.device_location ;
+--------+
| EXPR$0 |
+--------+
| null   |
+--------+

The same query funs fine in Postgis:
SELECT ST_AsText(current_location) FROM postgis.public.device_location ;


Test 2:
I am having geospatial query that uses only Postgis database: returns empty set:
SELECT *
FROM postgis.public.device_location
WHERE
   ST_Within(
   current_location,
   ST_GeomFromText( 'POLYGON((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0))', 4326)
);

However, if I run the following query in Postgis, everything is fine (it returns some results):
SELECT *
FROM device_location
WHERE
   ST_Within(
   current_location,
   ST_GeomFromText( 'POLYGON((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0))', 4326)
);

Test 3:
Ideally, I would like to run the following query, but it returns empty set:
SELECT count(*)
FROM mongo.test.contacts c, postgis.public.device d, postgis.public.device_location dl
WHERE c.contact_id = d.contact_id
AND c.name = 'name_99'
AND d.id = dl.device_id
AND ST_Within(
   dl.current_location,
   ST_GeomFromText( 'POLYGON((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0))', 4326) ) ;


Regards,
Krzysztof jezak