[
https://issues.jboss.org/browse/TEIID-3038?page=com.atlassian.jira.plugin...
]
Ramesh Reddy commented on TEIID-3038:
-------------------------------------
I found two more relevant functions in MongoDB "near" and "nearSphere"
per
http://docs.mongodb.org/manual/reference/operator/query-geospatial/
Also the above seems to targeted only to Polygons, according to GeoJSON format that
(
http://geojson.org/geojson-spec.html#id3) MongoDb supports, you can also support Point,
Line etc. So, I am designing the function signature to be like
{code}
CREATE FOREIGN FUNCTION geoIntersects (columnRef string, type string, coordinates
decimal[][]) RETURNS boolean;
CREATE FOREIGN FUNCTION geoWithin (ccolumnRef string, type string, coordinates
decimal[][]) RETURNS boolean;
CREATE FOREIGN FUNCTION near (ccolumnRef string, coordinates decimal[], maxdistance
integer) RETURNS boolean;
CREATE FOREIGN FUNCTION nearSphere (ccolumnRef string, coordinates decimal[], maxdistance
integer) RETURNS boolean;
{code}
where type can be Point, Polygon etc. Coordinates are defined as array of decimals.
so a sample SQL query looks like
{code}
SELECT * FROM features WHERE mongo.geoIntersects(loc, 'Polygon', ((11.0, 43.0),
(11.0, 42.0), (10.0, 42.0), (10.0, 43.0), (11.0, 43.0) ));
{code}
or
{code}
SELECT * FROM features WHERE mongo.geoIntersects(loc, 'Point', ((11.0, 43.0), ));
{code}
This way we can support all the available query support. The Teiid query to MongoDB looks
like
{code}
db.features.aggregate({$match :{ \"loc\" : { \"$geoIntersects\" : {
\"$geometry\" : { \"type\" : \"Polygon\" ,
\"coordinates\" : [ [ [11.0, 43.0], [11.0, 42.0], [10.0, 42.0], [10.0, 43.0],
[11.0, 43.0] ]]}}}}}
{code}
[~mdfspiff] However, if you think that, what you suggested is more concise form to
represent, then I can easily add an alias to above function like
{code}
CREATE FOREIGN FUNCTION geoPolygonIntersects (ref object, north double, east double, west
double, south double) RETURNS boolean;
{code}
Notice the change in the function name. Also I found no references how to handle a query
like
{code}
SELECT * FROM features WHERE mongo.geoIntersects(loc, 'Polygon', ((11.0, 43.0),
(11.0, 42.0), (10.0, 42.0), (10.0, 43.0), (11.0, 43.0) )) = false;
{code}
where I want find documents that are do not match, I could not find any proper syntax to
issue a "$not" with this. Any insight would be great!
Add spatial query support to the Teiid MongoDB translator
---------------------------------------------------------
Key: TEIID-3038
URL:
https://issues.jboss.org/browse/TEIID-3038
Project: Teiid
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: Misc. Connectors
Affects Versions: 8.8
Reporter: Michael Farwell
Assignee: Ramesh Reddy
Fix For: 8.9
We'd like to be able to issue geoIntersects and geoWithin queries through the MongoDB
translator. See comment below on a proposed approach.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)