Find if a map cords are withing a cycle

This forum contains topics that were moved from Get Satisfaction
Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

Yes I created a new column "CustomerGeoPoint1" of type Geopoint, in order no to mess any of my work done so far.

I went service to test and I put in where the value:
==================
{"$or": [{"Type":"Food"}] } AND {"CustomerGeoPoint1": {"$nearSphere": [23.791376,38002788], "$maxDistanceInMiles": 1}}
==================

The results are (with no errors that I can see), the below.
The problem is that the first record should not appear, as is more than 1 mile away from my (test) location [23.791376,38002788]

Correct ?....
(I want to return only the geopoints that are INSIDE a cycle with radious 1 mile.)

==================
[
{
"id":"544a1ccbe4b0c9bce12428fa",
"Type":"Food",
"
createdAt":"2014-10-24 09:32:59.759",
"updatedAt":"2014-11-03 20:44:08.766",
"Description":"Full meal, one soft drink and one desert per person",
"ValidTo":"2014-10-24 00:13:00.000",
"ValidFrom":"2014-10-24 12:00:00.000",
"CustomerName":"Lucas Food",
"CustomerAddress":"Leoforos Vouliagmenis 234 17343 Athens Greece",
"CustomerGeoPoint":"37.947702, 23.738691",
"CustomerGeoPoint1":[
23.738691,
37.947702
]
},
{
"
id":"545783b0e4b03d005b6291e6",
"Type":"Food",
"createdAt":"2014-11-03 13:31:28.957",
"
updatedAt":"2014-11-03 20:43:31.656",
"Description":"Coffee and cheese pie for 1.50 euro",
"ValidFrom":"2014-11-03 00:00:00.000",
"ValidTo":"2014-11-03 00:00:00.000",
"CustomerName":"Everest",
"CustomerAddress":"Λεωφόρος Μεσογείων 273-275",
"CustomerGeoPoint":"38.004065, 23.793436",
"CustomerGeoPoint1":[
23.793436,
38.004065
]
}
]


Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

I did another test with just the geopoint where part

=================================
{"CustomerGeoPoint1": {"$nearSphere": [23.791376,38002788], "$maxDistanceInMiles": 1}}
=================================

and I get the error

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


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

Find if a map cords are withing a cycle

Post by Bruce Stuart »

You have an index on the customergeopoint field and your query must be long , lat and the data is stored in long, lat format ? ( opposite of goggle right ??

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

Find if a map cords are withing a cycle

Post by Bruce Stuart »

Sorry ... Index on customergeopoint1 field :-)

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

I have created no index.
I have 5 records in the DB, to make my tests.
Yes long, lat format.

I even changed the values
from
{"CustomerGeoPoint1": {"$nearSphere": [23.791376,38002788], "$maxDistanceInMiles": 1}}
to
{"CustomerGeoPoint1": {"$nearSphere": [38002788,23.791376], "$maxDistanceInMiles": 1}}

same error

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

Find if a map cords are withing a cycle

Post by Bruce Stuart »

I believe the mongodb documentation requires an index for the query to work ... Please try that and let me know

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

I created the index on CustomerGeopoint1
Should I recreate the service ?

In test I put
{"CustomerGeoPoint1": {"$nearSphere": [23.791376,38002788], "$maxDistanceInMiles": 1}}

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

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

Takis
Posts: 0
Joined: Wed Oct 22, 2014 5:10 pm

Find if a map cords are withing a cycle

Post by Takis »

I was missing a dot in the cords values

So again....

I created the index on CustomerGeopoint1
Should I recreate the service ?

In test I put
{"CustomerGeoPoint1": {"$nearSphere": [23.791376,38.002788], "$maxDistanceInMiles": 1}}

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

Post Reply