[Mapbender-commits] r4693 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Sep 25 06:47:39 EDT 2009
Author: christoph
Date: 2009-09-25 06:47:39 -0400 (Fri, 25 Sep 2009)
New Revision: 4693
Modified:
trunk/mapbender/http/javascripts/geometry.js
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/mod_changeEPSG.js
trunk/mapbender/http/javascripts/mod_setBBOX1.php
Log:
Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js 2009-09-25 10:45:42 UTC (rev 4692)
+++ trunk/mapbender/http/javascripts/geometry.js 2009-09-25 10:47:39 UTC (rev 4693)
@@ -115,7 +115,17 @@
* @param {GeometryArray} geom GeometryArray
*/
GeometryArray.prototype.union = function(geom){
- return this.importGeoJSON(geom.toString());
+ var oldLen = this.count();
+ this.importGeoJSON(geom.toString());
+ var j = 0;
+ for (var i = oldLen; i < this.count(); i++) {
+ if (typeof geom.get(j).wfs_conf !== "undefined") {
+ this.get(i).wfs_conf = geom.get(j).wfs_conf;
+ }
+ j++;
+ }
+ return this;
+
};
/**
@@ -360,6 +370,19 @@
this.close();
};
+GeometryArray.prototype.importMultiPoint = function(currentGeometry, featureEpsg){
+ var coordinates = currentGeometry.coordinates;
+
+ this.addMember(geomType.point);
+ for (var m = 0; m < coordinates.length; m++) {
+ this.get(-1).addGeometry();
+ var currentPoint = coordinates[m];
+ this.getGeometry(-1,-1).addPointByCoordinates(currentPoint[0], currentPoint[1], currentPoint[2]);
+ this.getGeometry(-1,-1).setEpsg(featureEpsg);
+ }
+ this.close();
+};
+
GeometryArray.prototype.importPolygon = function(currentGeometry, featureEpsg){
var coordinates = currentGeometry.coordinates;
@@ -429,6 +452,10 @@
this.importPoint(currentGeometry, featureEpsg);
break;
+ case "MultiPoint":
+ this.importMultiPoint(currentGeometry, featureEpsg);
+ break;
+
case "LineString":
this.importLine(currentGeometry, featureEpsg);
break;
Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js 2009-09-25 10:45:42 UTC (rev 4692)
+++ trunk/mapbender/http/javascripts/map_obj.js 2009-09-25 10:47:39 UTC (rev 4693)
@@ -237,45 +237,47 @@
new Mb_exception("Mapbender.Map.setSrs: Extent is not a Mapbender.Extent: " + options.extent);
return null;
}
-
- // check which WMS support the new SRS
- undoIgnoreWms();
- for (var i = 0; i < this.wms.length; i++) {
- var found = false;
- for (var j = 0; j < this.wms[i].gui_epsg.length; j++) {
- if (options.srs === this.wms[i].gui_epsg[j] && this.wms[i].gui_epsg_supported[j]) {
- found = true;
- break;
+ if (this.epsg !== options.srs) {
+ // check which WMS support the new SRS
+ undoIgnoreWms();
+ for (var i = 0; i < this.wms.length; i++) {
+ var found = false;
+ for (var j = 0; j < this.wms[i].gui_epsg.length; j++) {
+ if (options.srs === this.wms[i].gui_epsg[j] && this.wms[i].gui_epsg_supported[j]) {
+ found = true;
+ break;
+ }
}
+ if (!found) {
+ ignoreWms(this.wms[i]);
+ }
}
- if (!found) {
- ignoreWms(this.wms[i]);
+ var ignoredWms = getIgnoredWms();
+
+ // ...and optionally display a message
+ if (options.displayWarning && ignoredWms.length > 0) {
+
+ var msg = "The following WMS do not support the current SRS: <br><br>";
+
+ for (var key in ignoredWms) {
+ msg += "<b>" + ignoredWms[key].title + "</b><br>";
+ }
+ try {
+ Mapbender.modules.dialogManager.openDialog({
+ content: msg,
+ modal: false,
+ effectShow: 'puff'
+ });
+ }
+ catch (e) {
+ new Mb_warning(e.message + ". " + msg);
+ }
}
+
+ // actually set the new values and return extent
+ this.epsg = options.srs;
+
}
- var ignoredWms = getIgnoredWms();
-
- // ...and optionally display a message
- if (options.displayWarning && ignoredWms.length > 0) {
-
- var msg = "The following WMS do not support the current SRS: <br><br>";
-
- for (var key in ignoredWms) {
- msg += "<b>" + ignoredWms[key].title + "</b><br>";
- }
- try {
- Mapbender.modules.dialogManager.openDialog({
- content: msg,
- modal: false,
- effectShow: 'puff'
- });
- }
- catch (e) {
- new Mb_warning(e.message + ". " + msg);
- }
- }
-
- // actually set the new values and return extent
- this.epsg = options.srs;
return this.calculateExtent(options.extent);
};
@@ -507,6 +509,11 @@
var distx = extent.maxx - extent.minx;
var disty = extent.maxy - extent.miny;
+ if (typeof x === "object" && x.constructor === Mapbender.Point) {
+ y = x.y;
+ x = x.x;
+ }
+
if (x && y) {
var centerx = parseFloat(x);
var centery = parseFloat(y);
Modified: trunk/mapbender/http/javascripts/mod_changeEPSG.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_changeEPSG.js 2009-09-25 10:45:42 UTC (rev 4692)
+++ trunk/mapbender/http/javascripts/mod_changeEPSG.js 2009-09-25 10:47:39 UTC (rev 4693)
@@ -81,38 +81,70 @@
new Mb_exception("setSrs: must specify an SRS.");
return;
}
+ var recalculateExtentOnly;
+ if (typeof options === "object" && typeof options.recalculateExtentOnly === "object") {
+ recalculateExtentOnly = options.recalculateExtentOnly;
+ if (typeof recalculateExtentOnly.target !== "string") {
+ new Mb_exception("setSrs: must specify a target if recalculateExtentOnly is set.");
+ return;
+ }
+ if (typeof recalculateExtentOnly.extent !== "object") {
+ new Mb_exception("setSrs: must specify an extent if recalculateExtentOnly is set.");
+ return;
+ }
+ }
var srsArray = [];
- //
- // calculate extents for all maps...
- //
- for (var i = 0; i < mb_mapObj.length; i++) {
+ if (recalculateExtentOnly) {
+ recalculateExtentOnly.map = Mapbender.modules[recalculateExtentOnly.target];
+ if (typeof recalculateExtentOnly.map !== "object" || recalculateExtentOnly.map === null) {
+ new Mb_exception("setSrs: invalid target set for recalculateExtentOnly.");
+ return;
+ }
var currentSrs = {
- "frameName" : mb_mapObj[i].elementName,
- "epsg" : mb_mapObj[i].epsg,
- "extent" : mb_mapObj[i].extent.toString(),
- "width" : mb_mapObj[i].width,
- "height" : mb_mapObj[i].height
+ "frameName": recalculateExtentOnly.map.elementName,
+ "epsg": srsValue,
+ "extent": recalculateExtentOnly.extent.toString(),
+ "width": recalculateExtentOnly.map.width,
+ "height": recalculateExtentOnly.map.height
};
srsArray.push(currentSrs);
}
//
- // ... and all WMS.
+ // calculate extents for all maps...
//
- for (var i = 0; i < wms.length; i++) {
- var ext = wms[i].getBoundingBoxBySrs(mb_mapObj[0].epsg);
- if (ext === null) {
- continue;
+ else {
+ for (var i = 0; i < mb_mapObj.length; i++) {
+ var currentSrs = {
+ "frameName": mb_mapObj[i].elementName,
+ "epsg": mb_mapObj[i].epsg,
+ "extent": mb_mapObj[i].extent.toString(),
+ "width": mb_mapObj[i].width,
+ "height": mb_mapObj[i].height
+ };
+ srsArray.push(currentSrs);
}
- var currentSrs = {
- "wms" : wms[i].wms_id,
- "epsg" : mb_mapObj[0].epsg,
- "extent" : ext.toString(),
- "width" : mb_mapObj[0].width,
- "height" : mb_mapObj[0].height
- };
- srsArray.push(currentSrs);
}
+ //
+ // ... and all WMS.
+ //
+ if (!recalculateExtentOnly) {
+ for (var i = 0; i < wms.length; i++) {
+ var ext = wms[i].getBoundingBoxBySrs(mb_mapObj[0].epsg);
+ if (ext === null) {
+ continue;
+ }
+ var currentSrs = {
+ "wms" : wms[i].wms_id,
+ "epsg" : mb_mapObj[0].epsg,
+ "extent" : ext.toString(),
+ "width" : mb_mapObj[0].width,
+ "height" : mb_mapObj[0].height
+ };
+ srsArray.push(currentSrs);
+ }
+
+ }
//
// perform transformation
@@ -122,7 +154,7 @@
method: "changeEpsg",
parameters: {
srs: srsArray,
- newSrs: srsValue
+ newSrs: recalculateExtentOnly ? recalculateExtentOnly.map.epsg : srsValue
},
callback: function (obj, success, message) {
if (!success) {
@@ -133,7 +165,7 @@
var newExtent = obj;
for (var i = 0; i < newExtent.length; i++) {
- if (newExtent[i].wms) {
+ if (newExtent[i].wms && !recalculateExtentOnly) {
for (var j = 0; j < wms.length; j++) {
if (parseInt(wms[j].wms_id, 10) === parseInt(newExtent[i].wms, 10)) {
wms[j].setBoundingBoxBySrs(
@@ -154,7 +186,7 @@
//
// use the previous extent of the overview
//
- if(newExtent[i].frameName == options.target){
+ if(!recalculateExtentOnly && newExtent[i].frameName == options.target){
var map = Mapbender.modules[options.target];
Modified: trunk/mapbender/http/javascripts/mod_setBBOX1.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_setBBOX1.php 2009-09-25 10:45:42 UTC (rev 4692)
+++ trunk/mapbender/http/javascripts/mod_setBBOX1.php 2009-09-25 10:47:39 UTC (rev 4693)
@@ -24,23 +24,51 @@
var targetArray = targetString.split(",");
var bboxString = "<?php echo Mapbender::session()->get("mb_myBBOX") ?>";
var srs = "<?php echo Mapbender::session()->get("mb_myBBOXEpsg") ?>";
+ var performTransformation =
+ ("<?php
+ echo Mapbender::session()->get("mb_myBBOXEpsg_transform")
+ ?>" === "1") ? true : false;
+
+
//
// the user wants to set an SRS that is different from the
// application's SRS!
+ // OR
+ // the user wants to set a bounding box specified in
+ // another SRS to be displayed in the current SRS
//
if (typeof Mapbender.modules[targetArray[0]] === "object"
&& srs !== "" && srs !== Mapbender.modules[targetArray[0]].epsg) {
+
if (typeof Mapbender.modules.changeEPSG !== "object") {
new Mb_exception("setBBOX requires changeEPSG!");
return;
}
- Mapbender.modules.changeEPSG.setSrs({
- srs: srs,
- callback: function () {
- setBbox(targetArray, bboxString);
- }
- });
+ if (performTransformation || bboxString === "") {
+ Mapbender.modules.changeEPSG.setSrs({
+ srs: srs,
+ callback: function () {
+ setBbox(targetArray, bboxString);
+ }
+ });
+ }
+ else {
+ var bboxArray = bboxString.split(",");
+ Mapbender.modules.changeEPSG.setSrs({
+ srs: srs,
+ recalculateExtentOnly : {
+ target : targetArray[0],
+ extent : new Mapbender.Extent(
+ bboxArray[0],
+ bboxArray[1],
+ bboxArray[2],
+ bboxArray[3]
+ )
+ }
+ });
+
+ }
}
//
// the user doesn't want to change the SRS.
More information about the Mapbender_commits
mailing list