feat: liveQuery support for unsorted distance queries (#8221)
This commit is contained in:
@@ -344,9 +344,25 @@ function matchesKeyConstraints(object, key, constraints) {
|
||||
return true;
|
||||
}
|
||||
case '$geoWithin': {
|
||||
const points = compareTo.$polygon.map(geoPoint => [geoPoint.latitude, geoPoint.longitude]);
|
||||
const polygon = new Parse.Polygon(points);
|
||||
return polygon.containsPoint(object[key]);
|
||||
if (compareTo.$polygon) {
|
||||
const points = compareTo.$polygon.map(geoPoint => [
|
||||
geoPoint.latitude,
|
||||
geoPoint.longitude,
|
||||
]);
|
||||
const polygon = new Parse.Polygon(points);
|
||||
return polygon.containsPoint(object[key]);
|
||||
}
|
||||
if (compareTo.$centerSphere) {
|
||||
const [WGS84Point, maxDistance] = compareTo.$centerSphere;
|
||||
const centerPoint = new Parse.GeoPoint({
|
||||
latitude: WGS84Point[1],
|
||||
longitude: WGS84Point[0],
|
||||
});
|
||||
const point = new Parse.GeoPoint(object[key]);
|
||||
const distance = point.radiansTo(centerPoint);
|
||||
return distance <= maxDistance;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '$geoIntersects': {
|
||||
const polygon = new Parse.Polygon(object[key].coordinates);
|
||||
|
||||
Reference in New Issue
Block a user