summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2013-03-25 11:01:40 -0400
committerDan Pasette <dan@10gen.com>2013-03-28 18:41:26 -0400
commit033f58e7d51c6d3740a22e92c311420ff776e312 (patch)
tree33464668263622b2282dfec2e09b313088e02cd3 /jstests
parentf9289144fce80aee078213c4553015bf49954d91 (diff)
downloadmongo-033f58e7d51c6d3740a22e92c311420ff776e312.tar.gz
SERVER-9062 don't rely on drem to normalize longitude -- explicitly reject OOB values
Diffstat (limited to 'jstests')
-rwxr-xr-xjstests/geo_s2edgecases.js8
-rw-r--r--jstests/geo_s2nearComplex.js18
2 files changed, 18 insertions, 8 deletions
diff --git a/jstests/geo_s2edgecases.js b/jstests/geo_s2edgecases.js
index 02bd17d8b9f..bf46baba744 100755
--- a/jstests/geo_s2edgecases.js
+++ b/jstests/geo_s2edgecases.js
@@ -5,20 +5,20 @@ roundworldpoint = { "type" : "Point", "coordinates": [ 180, 0 ] }
// Opposite the equator
roundworld = { "type" : "Polygon",
- "coordinates" : [ [ [179,1], [181,1], [181,-1], [179,-1], [179,1]]]}
+ "coordinates" : [ [ [179,1], [-179,1], [-179,-1], [179,-1], [179,1]]]}
t.insert({geo : roundworld})
roundworld2 = { "type" : "Polygon",
- "coordinates" : [ [ [179,1], [179,-1], [181,-1], [181,1], [179,1]]]}
+ "coordinates" : [ [ [179,1], [179,-1], [-179,-1], [-179,1], [179,1]]]}
t.insert({geo : roundworld2})
// North pole
santapoint = { "type" : "Point", "coordinates": [ 180, 90 ] }
santa = { "type" : "Polygon",
- "coordinates" : [ [ [179,89], [179,90], [181,90], [181,89], [179,89]]]}
+ "coordinates" : [ [ [179,89], [179,90], [-179,90], [-179,89], [179,89]]]}
t.insert({geo : santa})
santa2 = { "type" : "Polygon",
- "coordinates" : [ [ [179,89], [181,89], [181,90], [179,90], [179,89]]]}
+ "coordinates" : [ [ [179,89], [-179,89], [-179,90], [179,90], [179,89]]]}
t.insert({geo : santa2})
// South pole
diff --git a/jstests/geo_s2nearComplex.js b/jstests/geo_s2nearComplex.js
index 78a055d719b..87dd034ca24 100644
--- a/jstests/geo_s2nearComplex.js
+++ b/jstests/geo_s2nearComplex.js
@@ -59,15 +59,25 @@ function uniformPoints(origin, count, minDist, maxDist){
var pointLat = asin((sin(lat) * cos(distance)) + (cos(lat) * sin(distance) * cos(angle)));
var pointDLng = atan2(sin(angle) * sin(distance) * cos(lat), cos(distance) - sin(lat) * sin(pointLat));
var pointLng = ((lng - pointDLng + PI) % 2*PI) - PI;
+
+ // Latitude must be [-90, 90]
+ var newLat = lat + pointLat;
+ if (newLat > 90) newLat -= 180;
+ if (newLat < -90) newLat += 180;
+
+ // Longitude must be [-180, 180]
+ var newLng = lng + pointLng;
+ if (newLng > 180) newLng -= 360;
+ if (newLng < -180) newLng += 360;
+
var newPoint = {
geo: {
type: "Point",
- coordinates: [lng + pointLng, lat + pointLat]
+ //coordinates: [lng + pointLng, lat + pointLat]
+ coordinates: [newLng, newLat]
}
};
- if(lat + pointLat > 90.0){
- continue;
- }
+
points.push(newPoint);
}
for(i=0; i < points.length; i++){