Skip to content

issue with GeoPoint #4389

Closed
Closed

Description

@eddyLazar

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

Activity

  1. flovilmart commented on Nov 26, 2017

    @flovilmart
    Contributor

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

  2. eddyLazar commented on Nov 28, 2017

    @eddyLazar
    ContributorAuthor

    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
    
  3. flovilmart commented on Nov 28, 2017

    @flovilmart
    Contributor

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

  4. eddyLazar commented on Nov 29, 2017

    @eddyLazar
    ContributorAuthor
    [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]
    
    
  5. flovilmart commented on Nov 29, 2017

    @flovilmart
    Contributor

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

  6. eddyLazar commented on Nov 29, 2017

    @eddyLazar
    ContributorAuthor

    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

  7. flovilmart commented on Nov 29, 2017

    @flovilmart
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions