Skip to content

Commit

Permalink
Merge pull request ROGUE-JCTD#178 from BerryDaniel/mgrs_coord
Browse files Browse the repository at this point in the history
Add mgrs coordinate display
  • Loading branch information
smesdaghi committed Dec 24, 2015
2 parents b342d9a + b8ffeb3 commit 5c91333
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"x2js": "*",
"angular-xeditable": "0.1.8",
"d3": "3.4.11",
"proj4": "2.3.3"
"proj4": "2.3.3",
"mgrs": "git://github.com/proj4js/mgrs.git#0.0.3"
}
}
1 change: 1 addition & 0 deletions build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module.exports = {
'vendor/ol3/ol-debug.js',
'vendor/d3/d3.min.js',
'vendor/proj4/dist/proj4-src.js',
'vendor/mgrs/dist/mgrs.js',

//-- files for image gallery
//'vendor/blueimp-gallery/js/blueimp-gallery.js',
Expand Down
7 changes: 7 additions & 0 deletions src/common/map/MapService.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,13 @@
var precision = settings.DDPrecision;
this.map.getControls().getArray()[index].setCoordinateFormat(ol.coordinate.createStringXY(precision));
} else if (settings.coordinateDisplay === coordinateDisplays.DD) {
var mgrs_precision = settings.MGRSPrecision;
settings.coordinateDisplay = coordinateDisplays.MGRS;
var mgrsFormat = function(coordinate) {
return mgrs.forward(coordinate, mgrs_precision);
};
this.map.getControls().getArray()[index].setCoordinateFormat(mgrsFormat);
} else if (settings.coordinateDisplay === coordinateDisplays.MGRS) {
settings.coordinateDisplay = coordinateDisplays.DMS;
this.map.getControls().getArray()[index].setCoordinateFormat(ol.coordinate.toStringHDMS);
}
Expand Down
2 changes: 2 additions & 0 deletions src/common/utils/Globals.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var coordinateDisplays = {
DMS: 'degree_minute_second',
DD: 'decimal_degrees',
MGRS: 'mgrs',
Other: 'other'
};

var settings = {
coordinateDisplay: coordinateDisplays.DMS,
DDPrecision: 8,
MGRSPrecision: 10,
WFSVersion: '1.1.0',
WMSVersion: '1.1.1',
WPSVersion: '1.0.0'
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/UtilsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@
},
link: function(scope) {
if (scope.geom.projection === 'EPSG:4326') {
scope.coordinateDisplays = [coordinateDisplays.DMS, coordinateDisplays.DD];
scope.coordinateDisplays = [coordinateDisplays.DMS, coordinateDisplays.DD, coordinateDisplays.MGRS];
} else {
scope.coordinateDisplays = [coordinateDisplays.DMS, coordinateDisplays.DD, scope.geom.projection];
scope.coordinateDisplays = [coordinateDisplays.DMS, coordinateDisplays.DD, coordinateDisplays.MGRS, scope.geom.projection];
}

var transformCoords = function(coords, srcPrjName, dstPrjName) {
Expand Down

0 comments on commit 5c91333

Please sign in to comment.