Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with GeoPoint #4389

Closed
eddyLazar opened this issue Nov 26, 2017 · 7 comments
Closed

issue with GeoPoint #4389

eddyLazar opened this issue Nov 26, 2017 · 7 comments

Comments

@eddyLazar
Copy link
Contributor

Issue Description

I used GeoPoint parse field type, as described in documentation but did not succeed trying to use {"$within": {"$box": {[southwestGeoPoint, northeastGeoPoint]}}} for queries, it always return empty results. Then I tried to reproduce everything with mongo shell, and there is a difference between GeoPoint which is created in parse and a way which is described in mongo docs

Output when creating GeoPoint field manually according to mongo docs is

"location" : {
        "coordinates" : [ 
            55.7542146071183, 
            37.6188521534424
        ],
        "type" : "Point"
    },

Output when creating GeoPoint field with parse server as documented "__type": "GeoPoint", "latitude": 40.0, "longitude": -30.0

"location" : [ 
     37.6225, 
     55.7512
],

In first case Geo Queries works, in second does not. I'm new to mongo geo data, so maybe there is some confusion with mongo versions or engine about which i don't know.
Thanks!

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.6.5
    • Operating System: mac os
    • Hardware: macbook air
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: 3.2 and 3.4
    • Localhost or remote server? localhost
@flovilmart
Copy link
Contributor

Can you provide the logs when running with VERBOSE=1 for this query please?

@eddyLazar
Copy link
Contributor Author

eddyLazar commented Nov 28, 2017

used curl example from docs http://docs.parseplatform.org/rest/guide/#geopoint
mongo version 3.4

[3532] parse-server running on http://localhost:1337/parse
verbose: REQUEST for [POST] /parse/classes/PlaceObject: {
  "location": {
    "__type": "GeoPoint",
    "latitude": 40,
    "longitude": -30
  }
} method=POST, url=/parse/classes/PlaceObject, host=localhost:1337, user-agent=curl/7.54.0, accept=*/*, x-parse-application-id=MY_APP_ID, content-type=application/json, content-length=130, __type=GeoPoint, latitude=40, longitude=-30
verbose: RESPONSE from [POST] /parse/classes/PlaceObject: {
  "status": 201,
  "response": {
    "objectId": "r7B0eczmro",
    "createdAt": "2017-11-28T10:15:25.894Z"
  },
  "location": "http://localhost:1337/parse/classes/PlaceObject/r7B0eczmro"
} status=201, objectId=r7B0eczmro, createdAt=2017-11-28T10:15:25.894Z, location=http://localhost:1337/parse/classes/PlaceObject/r7B0eczmro

@flovilmart
Copy link
Contributor

Your curl only shows creating an object with a single point, can you please provide the query logs?

@eddyLazar
Copy link
Contributor Author

[2425] parse-server running on http://localhost:1337/parse
verbose: REQUEST for [GET] /parse/classes/PlaceObject: {} method=GET, url=/parse/classes/PlaceObject, host=localhost:1337, user-agent=curl/7.54.0, accept=*/*, x-parse-application-id=SALONI_KRASOTI_APP, content-type=application/json, 
verbose: RESPONSE from [GET] /parse/classes/PlaceObject: {
  "response": {
    "results": [
      {
        "objectId": "OEBamWthd5",
        "location": {
          "__type": "GeoPoint",
          "latitude": 40,
          "longitude": -30
        },
        "createdAt": "2017-11-28T10:14:52.156Z",
        "updatedAt": "2017-11-28T10:14:52.156Z"
      },
      {
        "objectId": "r7B0eczmro",
        "location": {
          "__type": "GeoPoint",
          "latitude": 40,
          "longitude": -30
        },
        "createdAt": "2017-11-28T10:15:25.894Z",
        "updatedAt": "2017-11-28T10:15:25.894Z"
      }
    ]
  }
} results=[objectId=OEBamWthd5, __type=GeoPoint, latitude=40, longitude=-30, createdAt=2017-11-28T10:14:52.156Z, updatedAt=2017-11-28T10:14:52.156Z, objectId=r7B0eczmro, __type=GeoPoint, latitude=40, longitude=-30, createdAt=2017-11-28T10:15:25.894Z, updatedAt=2017-11-28T10:15:25.894Z]

@flovilmart
Copy link
Contributor

the query you’re sending is not using polygons as constraints. Is that intended?

@eddyLazar
Copy link
Contributor Author

Oh, I'm sorry it was my mistake, the query some how works fine. But still there is a difference in types which actually confused me at first and I thought it was a reason

from parse

"location" : {
        "coordinates" : [ 
            55.7542146071183, 
            37.6188521534424
        ],
        "type" : "Point"
}

from mongo

"location" : [ 
     37.6225, 
     55.7512
]

Is it by design? Anyway issue can be closed. Thanks a lot for your response

@flovilmart
Copy link
Contributor

Yes it’s by design, the way data is stored is not 1-1 from mongo to parse, you’ll see also that ACL’s are split to have a better index performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants