[Mapbender-commits] r1459 - branches/mapbender_sld/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Jun 22 14:24:19 EDT 2007
Author: uli
Date: 2007-06-22 14:24:19 -0400 (Fri, 22 Jun 2007)
New Revision: 1459
Modified:
branches/mapbender_sld/http/javascripts/map.js
Log:
some new methods for the wms-obj
Modified: branches/mapbender_sld/http/javascripts/map.js
===================================================================
--- branches/mapbender_sld/http/javascripts/map.js 2007-06-15 13:13:19 UTC (rev 1458)
+++ branches/mapbender_sld/http/javascripts/map.js 2007-06-22 18:24:19 UTC (rev 1459)
@@ -136,10 +136,19 @@
* @type integer
*/
this.getWidth = function(){
- return this.width;
+ return parseInt(this.width);
};
/**
+ * set the width of the mapObj
+ *
+ * @param {integer} widht the width of the mapObj
+ */
+ this.setWidth = function(width){
+ this.width = parseInt(width);
+ };
+
+ /**
* get the height of the mapObj
*
* @member mb_mapObj_const
@@ -147,10 +156,19 @@
* @type integer
*/
this.getHeight = function(){
- return this.height;
+ return parseInt(this.height);
};
/**
+ * set the height of the mapObj
+ *
+ * @param {integer} height the height of the mapObj
+ */
+ this.setHeight = function(height){
+ this.height = parseInt(height);
+ };
+
+ /**
* get the extent of the mapObj
*
* @member mb_mapObj_const
@@ -164,20 +182,35 @@
/**
* get the extent as minx, maxx, miny, maxy
*
- * @return extent of the mapObj as minx,minx,maxx,maxy
+ * @return extent and additional informations of the mapObj
* @type Object
*/
- this.getExtentAsObj = function(){
- var coordslist = this.getExtent().split(",");
- var coords = new Object();
- coords.minx = parseFloat(coordslist[0]);
- coords.miny = parseFloat(coordslist[1]);
- coords.maxx = parseFloat(coordslist[2]);
- coords.maxy = parseFloat(coordslist[3]);
- return coords;
+ this.getExtentInfos = function(){
+ var ext = new Extent(this.getExtent());
+ return ext;
};
/**
+ * converts the extent of the mapobject so that the maximum extent will be displayed
+ *
+ */
+ this.calculateExtent = function(ext){
+ var relation_px_x = this.getWidth() / this.getHeight();
+ var relation_px_y = this.getHeight() / this.getWidth();
+ var relation_bbox_x = ext.extentx / ext.extenty;
+ if(relation_bbox_x <= relation_px_x){
+ ext.minx = ext.centerx - relation_px_x * ext.extenty / 2;
+ ext.maxx = ext.centerx + relation_px_x * ext.extenty / 2;
+ }
+ if(relation_bbox_x > relation_px_x){
+ ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
+ ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
+ }
+ this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
+ };
+
+
+ /**
* zoom the map with a zoomfactor and optional to x,y coords
*
* @param {boolean} in_ in = true, out = false
@@ -191,7 +224,7 @@
factor = 1 / factor;
}
- var extent = this.getExtentAsObj();
+ var extent = this.getExtentInfos();
var distx = extent.maxx - extent.minx;
var disty = extent.maxy - extent.miny;
@@ -261,9 +294,9 @@
* @return array of all mapRequests of this map-object
* @type string[]
*/
- this.getMapRequests = function(clickPoint){
+ this.getMapRequests = function(){
var allRequests = [];
- //loop through all wms to get the FeatureInfoRequests
+ //loop through all wms to get the MapRequests
for(var i=0; i<this.wms.length; i++){
var currentRequest = this.wms[i].getMapRequest(this);
if(currentRequest){
@@ -1171,27 +1204,37 @@
mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
setMapRequest(frameName);
}
+/*
+ * converts the extent of the mapobject so that the maximum extent will be displayed {@link mb_mapObj_const#calculateExtent}
+ * use: mb_mapObj.calculateExtent
+ * @deprecated
+ *
+ */
function mb_calculateExtent(frameName,minx,miny,maxx,maxy){
- var ind = getMapObjIndexByName(frameName);
-
- var extenty = parseFloat(maxy) - parseFloat(miny);
- var extentx = parseFloat(maxx) - parseFloat(minx);
-
- var relation_px_x = mb_mapObj[ind].width / mb_mapObj[ind].height;
- var relation_px_y = mb_mapObj[ind].height / mb_mapObj[ind].width;
- var relation_bbox_x = extentx / extenty;
- var centerx = parseFloat(minx) + (extentx/2);
- var centery = parseFloat(miny) + (extenty/2);
- if(relation_bbox_x <= relation_px_x){
- minx = centerx - relation_px_x * extenty / 2;
- maxx = centerx + relation_px_x * extenty / 2;
- }
- if(relation_bbox_x > relation_px_x){
- miny = centery - relation_px_y * extentx / 2;
- maxy = centery + relation_px_y * extentx / 2;
- }
- mb_mapObj[ind].extent = minx +","+ miny +","+ maxx +","+ maxy;
+ var map = getMapObjByName(frameName);
+ var extent = new Extent(minx,miny,maxx,maxy);
+ map.calculateExtent(extent);
}
+/*
+ * @class extent
+ * @param {float} minx
+ * @param {float} miny
+ * @param {float} maxx
+ * @param {float} maxy
+ * @return the extent as object
+ * @type Object
+ */
+function Extent(minx,miny,maxx,maxy){
+ this.minx = parseFloat(minx);
+ this.miny = parseFloat(miny);
+ this.maxx = parseFloat(maxx);
+ this.maxy = parseFloat(maxy);
+ this.extentx = this.maxx - this.minx;
+ this.extenty = this.maxy - this.miny;
+ this.centerx = this.minx + this.extentx/2;
+ this.centery = this.miny + this.extenty/2;
+ return this;
+}
function mb_showHighlight(frameName,x,y){
var pos = makeRealWorld2mapPos(frameName,x, y);
@@ -1452,7 +1495,7 @@
var isAppropriate = (typeof(levelIndex)=='number' && levelIndex < indexOfLevel(log_level));
return (isNotOff && isAppropriate);
};
- var throwException = function (message, level) {
+ this.throwException = function (message, level) {
if (isValidLevel(level)) {
if (log_js == "on") {
try {
@@ -1479,7 +1522,7 @@
* @param message the message that is being logged
*/
function Mb_exception(message) {
- var level = "error";
+ var level = "error";
this.throwException(message, level);
}
Mb_exception.prototype = new Mb_log();
More information about the Mapbender_commits
mailing list