From dff5fbe0a41776330e88347de10746bf949b9f52 Mon Sep 17 00:00:00 2001 From: fxia Date: Sun, 23 Nov 2014 22:24:03 -0500 Subject: [PATCH 1/2] bbox fix. make sure w long value is less than e long value --- ckanext/spatial/public/js/dataset_map.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ckanext/spatial/public/js/dataset_map.js b/ckanext/spatial/public/js/dataset_map.js index 90c3988..7092a16 100644 --- a/ckanext/spatial/public/js/dataset_map.js +++ b/ckanext/spatial/public/js/dataset_map.js @@ -25,6 +25,19 @@ this.ckan.module('dataset-map', function (jQuery, _) { this.extent = this.el.data('extent'); + // fix bbox when w-long is positive while e-long is negative. + if (this.extent.type == 'Polygon' + && this.extent.coordinates[0].length == 5) { + _coordinates = this.extent.coordinates + s = _coordinates[0][0][1]; + w = _coordinates[0][0][0]; + n = _coordinates[0][2][1]; + e = _coordinates[0][1][0]; + while (w > e) w -=360 + + this.extent.coordinates = [[[w,s],[e,s],[e,n],[w,n],[w,s]]] + }; + // hack to make leaflet use a particular location to look for images L.Icon.Default.imagePath = this.options.site_url + 'js/vendor/leaflet/images'; From 038075461920e2e7e5c6d419d7de03d1669821ba Mon Sep 17 00:00:00 2001 From: fxia Date: Wed, 3 Dec 2014 23:34:33 -0500 Subject: [PATCH 2/2] bbox fix, more --- ckanext/spatial/public/js/dataset_map.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ckanext/spatial/public/js/dataset_map.js b/ckanext/spatial/public/js/dataset_map.js index 7092a16..59164e2 100644 --- a/ckanext/spatial/public/js/dataset_map.js +++ b/ckanext/spatial/public/js/dataset_map.js @@ -28,14 +28,19 @@ this.ckan.module('dataset-map', function (jQuery, _) { // fix bbox when w-long is positive while e-long is negative. if (this.extent.type == 'Polygon' && this.extent.coordinates[0].length == 5) { - _coordinates = this.extent.coordinates - s = _coordinates[0][0][1]; - w = _coordinates[0][0][0]; - n = _coordinates[0][2][1]; - e = _coordinates[0][1][0]; - while (w > e) w -=360 - - this.extent.coordinates = [[[w,s],[e,s],[e,n],[w,n],[w,s]]] + _coordinates = this.extent.coordinates[0] + w = _coordinates[0][0]; + e = _coordinates[2][0]; + if (w > e) { + w_new = w + while (w_new > e) w_new -=360 + for (var i = 0; i < _coordinates.length; i++) { + if (_coordinates[i][0] == w) { + _coordinates[i][0] = w_new + }; + }; + this.extent.coordinates[0] = _coordinates + }; }; // hack to make leaflet use a particular location to look for images