Skip to main content
Question

MONGODB querying by spatial predicate

  • February 23, 2017
  • 4 replies
  • 26 views

Hello,

we are having a problem trying to read a MongoDB collection using a FeatureReader. We are reading a large database and only require data which falls within a bounding box. The FeatureReader constriants for MongoDB include a spatial filter - but selecting one creates the following warning:

`MONGODB' does not support querying by spatial predicate, but supports envelope queries.

It also advises that equivilent results will be performed by FME locally, but this does not work. Envelope queries are supported, but it takes a huge amount of time.

If MongoDB does not support spatial queries within FME, can anybody suggest an alternative to the Envelope query, which seems to take much longer than should be necessary.

Thanks

 

4 replies

Forum|alt.badge.img+2
  • February 24, 2017

@m6 The MongoDB reader in the FeatureReader should support a spatial query. If you use Envelope Intersects then FME will send the MBR (minimum bounding rectangle) to the database and return the results. If you use any other spatial predicate (i.e Contains) then the query is carried out in two steps:

- FME sends the MBR to the database and returns the results

- FME uses internal functionality to clean-up the query and clip the data to the original query polygon.

This presumes your MongoDB collection has a spatial index on your locations. Use Robomongo or something similar to check the indices on your collections.

This approach is used for many of the spatial database formats FME supports.

Only the FeatureReader supports the spatial query for MongoDB. The FME MongoDB 'native' reader does not yet support spatial queries and will read the entire dataset and then clip to the spatial envelope.


  • Author
  • March 13, 2017

Thanks Mark - I will give Robomongo a try and respond again.


  • July 9, 2018

Hi Mark,

thank you for your previous reply to this topic, it seemed to do the trick while I was doing some testing. The envelope intersect working well where other spatial filters failed. However, I have since written a very large database to MongoDB and the Feature Reader seems to unable to cope with it.

I have used Studio3T/ Romomongo to re-build the 2D spatial indexes on the collections to make sure that isn't the problem. But in the latest FME build (where envelope intersect has been replaced with bounding box intersect - which I suspect are identical but with a different name) it appears from the log that FME may be attempting to build a temporary FFS of the data to query against. Could this be the case? If so, the size of the database will yield the Mongo Feature reader un-usable here.

Many thanks

Matt


Forum|alt.badge.img+2
m8 wrote:

Hi Mark,

thank you for your previous reply to this topic, it seemed to do the trick while I was doing some testing. The envelope intersect working well where other spatial filters failed. However, I have since written a very large database to MongoDB and the Feature Reader seems to unable to cope with it.

I have used Studio3T/ Romomongo to re-build the 2D spatial indexes on the collections to make sure that isn't the problem. But in the latest FME build (where envelope intersect has been replaced with bounding box intersect - which I suspect are identical but with a different name) it appears from the log that FME may be attempting to build a temporary FFS of the data to query against. Could this be the case? If so, the size of the database will yield the Mongo Feature reader un-usable here.

Many thanks

Matt

Hi Matt:

 

I tested this in FME 2018.1 and I don't see FME caching to an FFS file. FME will cache to an FFS file if you have either:

 

- a data Inspector enabled in the workspace

 

- you have enabled Enable Feature Caching (or Run with Full Inspection in earlier versions of FME)

 

FME 2018 we did change Envelope Intersect with Bounding Boxes Intersect

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings