[Mapbender-commits] r1138 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Feb 23 06:56:04 EST 2007
Author: christoph
Date: 2007-02-23 06:56:03 -0500 (Fri, 23 Feb 2007)
New Revision: 1138
Modified:
trunk/mapbender/http/javascripts/point.js
Log:
* separation of public, privileged and private member data
* moved code to geometry.js
Modified: trunk/mapbender/http/javascripts/point.js
===================================================================
--- trunk/mapbender/http/javascripts/point.js 2007-02-23 10:44:49 UTC (rev 1137)
+++ trunk/mapbender/http/javascripts/point.js 2007-02-23 11:56:03 UTC (rev 1138)
@@ -5,37 +5,39 @@
*/
//http://www.mapbender.org/index.php/point.js
function Point(x, y){
- this.dist = function(p){
- return Math.sqrt(Math.pow(this.y-p.y,2) + Math.pow(this.x-p.x,2)) ;
- }
- this.equals = function(p){
- if (this.x == p.x && this.y == p.y) {return true;}
- return false;
- }
- this.minus = function(p){
- return new Point(this.x-p.x, this.y-p.y);
- }
- this.plus = function(p){
- return new Point(this.x+p.x, this.y+p.y);
- }
- this.dividedBy = function(c){
- if (c != 0) {return new Point(this.x/c, this.y/c);}
- alert("Exception: Division by zero");
- return false;
- }
- this.times = function(c){
- return new Point(this.x*c, this.y*c);
- }
- this.round = function(numOfDigits){
- return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
- }
- this.toString = function(){
- return "(" + this.x + ", " + this.y + ")";
- }
this.x = x;
this.y = y;
}
+Point.prototype.dist = function(p){
+ return Math.sqrt(Math.pow(this.y-p.y,2) + Math.pow(this.x-p.x,2)) ;
+}
+Point.prototype.equals = function(p){
+ if (this.x == p.x && this.y == p.y) {return true;}
+ return false;
+}
+Point.prototype.minus = function(p){
+ 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);
+}
+Point.prototype.dividedBy = function(c){
+ if (c != 0) {return new Point(this.x/c, this.y/c);}
+ alert("Exception: Division by zero");
+ return false;
+}
+Point.prototype.times = function(c){
+ return new Point(this.x*c, this.y*c);
+}
+Point.prototype.round = function(numOfDigits){
+ return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
+}
+Point.prototype.toString = function(){
+ return "(" + this.x + ", " + this.y + ")";
+}
+
+
//------------------------------------------------------------------------
// possible improvement: point has flag: map OR real. additional functions: toReal, toMap
@@ -81,13 +83,3 @@
function roundToDigits(aFloat, numberOfDigits) {
return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits)))/Math.pow(10, parseInt(numberOfDigits));
}
-function cloneObject(a){
- var z = [];
-
- for (attr in a) {
- var b = a[attr];
- if (typeof(b) == "object") {z[attr] = cloneObject(b);}
- else z[attr] = b;
- }
- return z;
-}
\ No newline at end of file
More information about the Mapbender_commits
mailing list