Skip to content

Commit

Permalink
Wrap longitude value around dateline.
Browse files Browse the repository at this point in the history
Fixes #45. Solr should handle querying across the dateline, but it
looks like the longitude values have to be within -180 and 180.
  • Loading branch information
Mike Graves committed Sep 22, 2014
1 parent 60b1f2b commit 34a95ef
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions app/assets/javascripts/geoblacklight/geoblacklight.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ GeoBlacklight.prototype = {
self.map = L.map('map');
self.basemap.addTo(self.map);
self.searchControl = L.searchButton(self);

if (self.bounds){
self.map.fitBounds(self.bounds);
}else{
self.map.setZoom(2);
self.map.setView([0,0]);
}
return {
map: self.map,
map: self.map,
basemap: self.basemap,
searchControl: self.searchControl,
params: self.params
Expand Down Expand Up @@ -66,10 +66,25 @@ GeoBlacklight.prototype = {
}
},
boundsToBbox: function(bounds) {
return [L.forNum(bounds._southWest.lng, 6), L.forNum(bounds._southWest.lat, 6), L.forNum(bounds._northEast.lng, 6), L.forNum(bounds._northEast.lat, 6)];
var minx = L.forNum(bounds._southWest.lng, 6),
maxx = L.forNum(bounds._northEast.lng, 6);
minx = GeoBlacklight.wrapLng(minx);
maxx = GeoBlacklight.wrapLng(maxx);

return [minx, L.forNum(bounds._southWest.lat, 6), maxx, L.forNum(bounds._northEast.lat, 6)];
},
boundsToEnvelope: function(bounds){
return [L.forNum(bounds._southWest.lng, 6), L.forNum(bounds._northEast.lng, 6), L.forNum(bounds._northEast.lat, 6), L.forNum(bounds._southWest.lat, 6)].join(',');
},

wrapLng: function(lng) {
while (lng < -180) {
lng += 360;
}
while (lng > 180) {
lng -= 360;
}
return lng;
}
};

Expand Down

0 comments on commit 34a95ef

Please sign in to comment.