Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Appery.io and MongoDB use of database functions to search based on geometry...

I'm creating a golf app that requires the ability to find courses within a geometry and then once in that course (geometry) - be able to use that geometry to find geo-points that app has in the DB within again -a radius.

I've looked through the Mongo db documentation and it supports 2d indexes on a geocoded field - and then there are query statements that can be used to find points in the DB that are within a radius that is passed via the geometry query.

  1. I've loaded the geometry data into my data table for golf courses as a test,(into a geo field per Mongo spec) and used the database UI in appery.io to create an index on that field. I presume that's not sufficent. See below.

  2. I've then tried though the appery builder to query the field when on the 'test' portion of request ( and I've added the appropriate fields to the header to create the request ). When I query the DB with the appropriate query I get a database error 1785 returned to me.

    Question:

    Can I use the mongodb attached to the appery application and related queries native in the db to query my geo data like the DB documentation suggests? The tutorial in the app suggests - by the fact that it's there - that this is generally not possible as it uses a function on the server to do this work - which I assume is NOT as efficient and potentially extra work - since there are nativeDB functions to do this work? Set me straight though on the best way to get geopoints with a radius where the data is loaded appropriately in the DB. ( query pipeline I'm using - { $geoNear: { } } )

    Any help and advice would be greatly appreciated - as this time of code - will form the foundation of my application - and I'd like to do it as efficiently as follows with the best possible solution architecture....

    Bruce

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Appery.io and MongoDB use of database functions to search based on geometry...

Hi Bruce,

You can do it with request to DB.

Please take a look on supported by appery geospherical requests:

http://devcenter.appery.io/documentat...

Regards.

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Appery.io and MongoDB use of database functions to search based on geometry...

Yurri,

Thanks!!! on this topic as well as the other. However, when I issue a command against the DB which is according to spec - with all the field names spelled correctly I get this error (screen shot below):

Query against my table (golf_courses) with a ageo fireld named g_latlong with this as the where clause:

(used the syntax as suggested in the link you provided - and I get the same error I mention in my first post above (the error number should have been 17287 apology).

Where:

{ "g_latlong" : { $nearSphere" : [33.511615,-86.778809], "$maxDistanceInMiles":80 } }

This is the error that comes back consistently:

{
"status":400,
"uri":"https://api.appery.io/rest/1/db/colle...",
"response":{
"code":"DBSQ264",
"description":"Mongo error: error code is '17287'"
}
}

screen print attached:

Image

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Appery.io and MongoDB use of database functions to search based on geometry...

Yurri,

Found the issue with my query - which was my data. Thanks !!! My other issue (the Google Maps issue ) however is still very much open... if you can help with that - it would be great.

Best,

Bruce

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Appery.io and MongoDB use of database functions to search based on geometry...

Hi Bruce,

Glad you got it to work.

Thanks for your update.

We will answer on your maps question on that thread.

Regards.

Bruce Buttles
Posts: 0
Joined: Tue Oct 20, 2015 7:44 pm

Appery.io and MongoDB use of database functions to search based on geometry...

Hello Yurri, I really need this example of geospacial queries. Your note has this URL but that page appears gone: http://devcenter.appery.io/documentat...

Bottom line, I have a Collection with a GeoPoint column, I need to query and get a list of all records in the Collection that are within a certain distance OR would appear on the map given the boundary.

Can you help?

Bruce Buttles
Posts: 0
Joined: Tue Oct 20, 2015 7:44 pm

Appery.io and MongoDB use of database functions to search based on geometry...

Awesome - this works amazingly well! I am shocked how easy and fast it is to create spatial queries ... MondoDB rocks!

Return to “Issues”