{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/3648","repository_url":"https://api.github.com/repos/strongloop/loopback","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/3648/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/3648/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/3648/events","html_url":"https://github.com/strongloop/loopback/issues/3648","id":264146220,"number":3648,"title":"Issue with storing GPS in a 2dSphere index","user":{"login":"taxiIDZwaneveld","id":8857462,"avatar_url":"https://avatars2.githubusercontent.com/u/8857462?v=4","gravatar_id":"","url":"https://api.github.com/users/taxiIDZwaneveld","html_url":"https://github.com/taxiIDZwaneveld","followers_url":"https://api.github.com/users/taxiIDZwaneveld/followers","following_url":"https://api.github.com/users/taxiIDZwaneveld/following{/other_user}","gists_url":"https://api.github.com/users/taxiIDZwaneveld/gists{/gist_id}","starred_url":"https://api.github.com/users/taxiIDZwaneveld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taxiIDZwaneveld/subscriptions","organizations_url":"https://api.github.com/users/taxiIDZwaneveld/orgs","repos_url":"https://api.github.com/users/taxiIDZwaneveld/repos","events_url":"https://api.github.com/users/taxiIDZwaneveld/events{/privacy}","received_events_url":"https://api.github.com/users/taxiIDZwaneveld/received_events","type":"User","site_admin":false},"labels":[{"id":484521294,"url":"https://api.github.com/repos/strongloop/loopback/labels/stale","name":"stale","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-10-10T08:48:52Z","updated_at":"2018-03-26T02:20:01Z","closed_at":"2017-12-23T09:08:21Z","author_association":"NONE","body":"# Description/Steps to reproduce\r\n\r\ni have noticed an issue with patching a GeoLocation in a mongoDb with a 2dsphere index.\r\nLoopback seems to try to inject the GPS update as [lat,lng] while the geoPoint standard is [lng,lat]. This means a patch like\r\n\r\n```\r\n{\r\n\"location\": {\r\n       \"gps\": {\r\n                  \"lng\":-122.568646854684,\r\n                  \"lat\": 32.352132456464\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nWil result in a mongoDb error,\r\n```\r\nMongoError: Can't extract geo keys: {location: { gps: { lat: 32.352132456464, lng: -122.568646854684 } } } can't project geometry into spherical CRS: { lat: 32.352132456464, lng: -122.568646854684 }\r\n```\r\n\r\nThis error is generated in MongoChef when you insert the gps in lat,lng but accepts when inserting in lng,lat loopback should not switch this around.\r\n\r\nThe error is a result that the latitude can't be lower then -90 and mongo geopoint sees the first value as the longitude and the second as latitude. I suspect that when Loopback would leave the order of patching alone this would work.\r\n\r\n# Reproduction\r\nWe need a 2dSphere index for distance calculations, just add a location to a collection, add the index to the gps field. And try to patch the index like above.\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/376027893","html_url":"https://github.com/strongloop/loopback/issues/3648#issuecomment-376027893","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/3648","id":376027893,"user":{"login":"tuxity","id":31608,"avatar_url":"https://avatars2.githubusercontent.com/u/31608?v=4","gravatar_id":"","url":"https://api.github.com/users/tuxity","html_url":"https://github.com/tuxity","followers_url":"https://api.github.com/users/tuxity/followers","following_url":"https://api.github.com/users/tuxity/following{/other_user}","gists_url":"https://api.github.com/users/tuxity/gists{/gist_id}","starred_url":"https://api.github.com/users/tuxity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tuxity/subscriptions","organizations_url":"https://api.github.com/users/tuxity/orgs","repos_url":"https://api.github.com/users/tuxity/repos","events_url":"https://api.github.com/users/tuxity/events{/privacy}","received_events_url":"https://api.github.com/users/tuxity/received_events","type":"User","site_admin":false},"created_at":"2018-03-26T02:20:01Z","updated_at":"2018-03-26T02:20:01Z","author_association":"NONE","body":"I have exactly the same problem.\r\nEmpty collections, autoupdate to create mongo indexes, and then I use a POST route on my model and I get the error.\r\n\r\nMy guess ? the mongo connector doesn't handle correctly { \"lat\": xxxx, \"lng\": xxxx } loopback object to GeoPoint object or something like that"}}
{"actor":{"display_login":"tuxity"}}