[Mapbender-commits] r1265 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Apr 17 06:23:47 EDT 2007
Author: christoph
Date: 2007-04-17 06:23:47 -0400 (Tue, 17 Apr 2007)
New Revision: 1265
Modified:
trunk/mapbender/http/javascripts/point.js
Log:
* float casting for addition; "+" is ambivalent in JS
* refactoring
* added JS exceptions
Modified: trunk/mapbender/http/javascripts/point.js
===================================================================
--- trunk/mapbender/http/javascripts/point.js 2007-04-17 10:21:21 UTC (rev 1264)
+++ trunk/mapbender/http/javascripts/point.js 2007-04-17 10:23:47 UTC (rev 1265)
@@ -20,11 +20,11 @@
return new Point(this.x-p.x, this.y-p.y);
}
Point.prototype.plus = function(p){
- return new Point(this.x+p.x, this.y+p.y);
+ return new Point(parseFloat(this.x)+parseFloat(p.x), parseFloat(this.y)+parseFloat(p.y));
}
Point.prototype.dividedBy = function(c){
if (c != 0) {return new Point(this.x/c, this.y/c);}
- alert("Exception: Division by zero");
+ var e = new Mb_exception("Point.dividedBy: Division by zero");
return false;
}
Point.prototype.times = function(c){
@@ -50,16 +50,28 @@
}
function realToMap(frameName, aPoint) {
var v;
- if (typeof(mb_mapObj) == 'object') v = makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
- else if (typeof(parent.mb_mapObj) == 'object') v = parent.makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
- else alert('where am i?');
+ if (typeof(mb_mapObj) == 'object') {
+ v = makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
+ }
+ else if (typeof(parent.mb_mapObj) == 'object') {
+ v = parent.makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
+ }
+ else {
+ var e = new Mb_exception('Point.realToMap:where am i?');
+ }
return new Point(v[0], v[1]);
}
function mb_calcExtent(frameName, min, max) {
var ind;
- if (typeof(mb_mapObj) == 'object') ind = getMapObjIndexByName(frameName);
- else if (typeof(parent.mb_mapObj) == 'object') ind = parent.getMapObjIndexByName(frameName);
- else alert('function getMapObjIndexByName not found');
+ if (typeof(mb_mapObj) == 'object') {
+ ind = getMapObjIndexByName(frameName);
+ }
+ else if (typeof(parent.mb_mapObj) == 'object') {
+ ind = parent.getMapObjIndexByName(frameName);
+ }
+ else {
+ var e = new Mb_exception('Point.mb_calcExtent: function getMapObjIndexByName not found');
+ }
var extent = max.minus(min);
var center = extent.dividedBy(2).plus(min);
More information about the Mapbender_commits
mailing list