You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just updated parse-server, parse, and parse-dashboard to the latest versions to utilize the Parse.Polygon object, specifically to use the Parse.Query.polygonContains() method. Something is either switching coordinate pairs when it shouldn't be, or not switching coordinate pairs when it should be, somewhere in the flow of creating a Polygon from Parse.GeoPoints, attaching it to an object, then querying that class using polygonContains. I get the expected result when I flop the order of the values within a Polygon object, but that Polygon object was set up with an array of Parse.GeoPoints.
Steps to reproduce
Create a Parse.Polygon from an array of Parse.GeoPoints
Attach Polygon to an object & Save
Create a query on the class you've attached the Polygon to, and use query.polygonContains("polygonKey", geoPoint); where geoPoint is a known coordinate within the polygon
Check results - they will be nil
Use the Parse-Dashboard to go through the Polygon's values and swap the lat / longs. Notice that when creating the Polygon from an array of Parse.GeoPoints that they were put in the [lat,long] order. Change them to be [long,lat].
Run the query again, and you should find the expected object
Expected Results
Querying for a location using polygonContains on a Polygon field created with an array of Parse.GeoPoints should yield the expected object when using a GeoPoint known to be within said polygon
Actual Outcome
The query only returns the expected result if you swap the order of [lat,long] values on the Polygon object.
Environment Setup
Server
parse-server version (Be specific! Don't say 'latest'.) : ~2.7.2
Operating System: OSX 10.12.6
Hardware: 2015 MBP
Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): local / AWS
Database ~~~~Not sure where to find this info, don't see any of the relevant info on mLab~~~~
MongoDB version: [FILL THIS OUT]
Storage engine: [FILL THIS OUT]
Hardware: [FILL THIS OUT]
Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab
Additional Info
I notice that in your unit tests, you use [ [0,0], [0,1], [1,1], [1,0] ], which is likely why this error was missed. Other test polygons include:
These all run into the same issue of being mirrored over a lat = long line.
I could "hack around" this issue by reversing the order of the coordinates I pass into the query, but then again, I don't know if the issue lies within the query method or the storage of Polygon itself. I'm assuming the former, but don't know. I then also don't know if there are other repurcussions to this.
The text was updated successfully, but these errors were encountered:
Issue Description
I've just updated parse-server, parse, and parse-dashboard to the latest versions to utilize the
Parse.Polygon
object, specifically to use theParse.Query.polygonContains()
method. Something is either switching coordinate pairs when it shouldn't be, or not switching coordinate pairs when it should be, somewhere in the flow of creating a Polygon from Parse.GeoPoints, attaching it to an object, then querying that class usingpolygonContains
. I get the expected result when I flop the order of the values within a Polygon object, but that Polygon object was set up with an array of Parse.GeoPoints.Steps to reproduce
query.polygonContains("polygonKey", geoPoint);
wheregeoPoint
is a known coordinate within the polygonExpected Results
Querying for a location using
polygonContains
on a Polygon field created with an array of Parse.GeoPoints should yield the expected object when using a GeoPoint known to be within said polygonActual Outcome
The query only returns the expected result if you swap the order of [lat,long] values on the Polygon object.
Environment Setup
Server
Database ~~~~Not sure where to find this info, don't see any of the relevant info on mLab~~~~
Additional Info
I notice that in your unit tests, you use
[ [0,0], [0,1], [1,1], [1,0] ]
, which is likely why this error was missed. Other test polygons include:These all run into the same issue of being mirrored over a lat = long line.
I could "hack around" this issue by reversing the order of the coordinates I pass into the query, but then again, I don't know if the issue lies within the query method or the storage of Polygon itself. I'm assuming the former, but don't know. I then also don't know if there are other repurcussions to this.
The text was updated successfully, but these errors were encountered: