diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2014-07-21 14:36:17 -0400 |
---|---|---|
committer | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2014-08-12 17:04:40 -0400 |
commit | cd5c001c43b295ad601b0004f9c31f9d454f5d04 (patch) | |
tree | 72e6279b18ebb7272eac033af74a822ba8e8dd76 /src/mongo/db/geo/shapes.cpp | |
parent | 712768556e72d1756995c6a7b020b875fb9d6ea9 (diff) | |
download | mongo-cd5c001c43b295ad601b0004f9c31f9d454f5d04.tar.gz |
SERVER-14510 Custom CRS for strict winding order enforcement
Add big polygon parsing and query.
Diffstat (limited to 'src/mongo/db/geo/shapes.cpp')
-rw-r--r-- | src/mongo/db/geo/shapes.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/mongo/db/geo/shapes.cpp b/src/mongo/db/geo/shapes.cpp index 14a4fa3de04..562e35a46fc 100644 --- a/src/mongo/db/geo/shapes.cpp +++ b/src/mongo/db/geo/shapes.cpp @@ -759,6 +759,11 @@ namespace mongo { return isValidLngLat(point.oldPoint.x, point.oldPoint.y); } + bool ShapeProjection::supportsProject(const PolygonWithCRS& polygon, const CRS crs) { + return polygon.crs == crs + || (polygon.crs == STRICT_SPHERE && crs == SPHERE); + } + void ShapeProjection::projectInto(PointWithCRS* point, CRS crs) { dassert(supportsProject(*point, crs)); @@ -766,6 +771,7 @@ namespace mongo { return; if (FLAT == point->crs) { + // Prohibit projection to STRICT_SPHERE CRS invariant(SPHERE == crs); // Note that it's (lat, lng) for S2 but (lng, lat) for MongoDB. @@ -775,16 +781,23 @@ namespace mongo { point->point = latLng.ToPoint(); point->cell = S2Cell(point->point); point->crs = SPHERE; + return; } - else { - invariant(SPHERE == point->crs); - invariant(FLAT == crs); - // Just remove the additional spherical information - point->point = S2Point(); - point->cell = S2Cell(); - point->crs = FLAT; - } + // Prohibit projection to STRICT_SPHERE CRS + invariant(SPHERE == point->crs && FLAT == crs); + // Just remove the additional spherical information + point->point = S2Point(); + point->cell = S2Cell(); + point->crs = FLAT; + } + + void ShapeProjection::projectInto(PolygonWithCRS* polygon, CRS crs) { + if (polygon->crs == crs) return; + + // Only project from STRICT_SPHERE to SPHERE + invariant(STRICT_SPHERE == polygon->crs && SPHERE == crs); + polygon->crs = SPHERE; } } // namespace mongo |