[Mapbender-commits] r6807 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Aug 25 09:25:07 EDT 2010
Author: armin11
Date: 2010-08-25 13:25:07 +0000 (Wed, 25 Aug 2010)
New Revision: 6807
Modified:
trunk/mapbender/http/javascripts/mod_coordsLookup.js
Log:
Fix bugs in coordLookup. It will now zoom to the correct extent in 4326 - coords given also in DMS. Some thing to do cause validation has some problems.
Modified: trunk/mapbender/http/javascripts/mod_coordsLookup.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_coordsLookup.js 2010-08-25 11:16:02 UTC (rev 6806)
+++ trunk/mapbender/http/javascripts/mod_coordsLookup.js 2010-08-25 13:25:07 UTC (rev 6807)
@@ -109,26 +109,46 @@
this.coords.x = this.coordXInput.val().replace(',','.');
this.coords.y = this.coordYInput.val().replace(',','.');
+ //check if deg/minutes/seconds have been inserted
+ //validate
+ this.regexdms = /([0-9.]+)\°([0-9.]+)\'([0-9.]+)\'\'/;
+
this.coords.sourceProjection = (this.projectionSelect.val()) ?
this.projectionSelect.val() : null;
this.coords.targetProjection = Mapbender.modules[options.target].getSRS();
this.coords.perimeter = (this.perimeterSelect.val()) ?
parseFloat(this.perimeterSelect.val()) : null;
-
- if(
- this.coords.x.length === 0 || isNaN(this.coords.x) ||
- this.coords.y.length === 0 || isNaN(this.coords.y)
- ) {
- alert('Invalid coordinates!');
- return;
+ //validate coordinates
+ if(this.coords.x.length === 0 || isNaN(this.coords.x)) {
+ this.regexdms.exec(this.coords.x);
+ //alert(RegExp.$1 + ";" + RegExp.$2 + ";" + RegExp.$3);
+ if (isNaN(RegExp.$1) || isNaN(RegExp.$2) || isNaN(RegExp.$3))
+ {
+ alert('Invalid X coordinate! Must be a float or a DMS value!');
+ return;
+ } else {
+ this.coords.x = parseFloat(RegExp.$1) + parseFloat(RegExp.$2) / 60.0 + parseFloat(RegExp.$2) / 3600.0;
+ }
}
-
+ if(this.coords.y.length === 0 || isNaN(this.coords.y)) {
+ this.regexdms.exec(this.coords.y);
+ //alert(RegExp.$1 + ";" + RegExp.$2 + ";" + RegExp.$3);
+ if (isNaN(RegExp.$1) || isNaN(RegExp.$2) || isNaN(RegExp.$3))
+ {
+ alert('Invalid Y coordinate! Must be a float or a DMS value!');
+ return;
+ } else {
+ this.coords.y = parseFloat(RegExp.$1) + parseFloat(RegExp.$2 / 60.0) + parseFloat(RegExp.$2 / 3600.0);
+ }
+ }
+
if (this.coords.sourceProjection === null) {
alert('Invalid SRS!');
return;
}
- if(this.coords.sourceProjection && (this.coords.sourceProjection != this.coords.targetProjection)) {
+ //if(this.coords.sourceProjection && (this.coords.sourceProjection != this.coords.targetProjection)) {
+ if(this.coords.sourceProjection) {
this.transformProjection();
}
@@ -144,6 +164,24 @@
parameters.y = this.coords.y;
}
else {
+ if (this.coords.sourceProjection == 'EPSG:4326') {
+ this.R = 6371000.0;
+ this.Pi = Math.PI;
+ this.rho = 180.0/this.Pi;
+ this.coords.perimeterlon = 0.0;
+ this.coords.perimeterlat = 0.0;
+ this.coords.perimeterlon = parseFloat(this.coords.perimeter) * this.rho / this.R;
+ this.coords.perimeterlat = parseFloat(this.coords.perimeter) * this.rho / (this.R * Math.cos(parseFloat(this.coords.y) / this.rho));
+ parameters.bbox = (
+ parseFloat(this.coords.x) - parseFloat(this.coords.perimeterlon)
+ ) + "," + (
+ parseFloat(this.coords.y) - parseFloat(this.coords.perimeterlon)
+ ) + "," + (
+ parseFloat(this.coords.x) + parseFloat(this.coords.perimeterlat)
+ ) + "," + (
+ parseFloat(this.coords.y) + parseFloat(this.coords.perimeterlat));
+ }
+ else {
parameters.bbox = (
parseFloat(this.coords.x) - parseFloat(this.coords.perimeter)
) + "," + (
@@ -152,6 +190,7 @@
parseFloat(this.coords.x) + parseFloat(this.coords.perimeter)
) + "," + (
parseFloat(this.coords.y) + parseFloat(this.coords.perimeter));
+ }
}
var req = new Mapbender.Ajax.Request({
url: "../php/mod_coordsLookup_server.php",
@@ -197,4 +236,4 @@
Mapbender.events.init.register(function() {
Mapbender.modules[options.id] = $.extend(new CoordsLookup(),Mapbender.modules[options.id]);
-});
\ No newline at end of file
+});
More information about the Mapbender_commits
mailing list