Ticket #571: no_more_lonlat.3.patch
| File no_more_lonlat.3.patch, 13.1 kB (added by crschmidt, 2 years ago) |
|---|
-
tests/Geometry/test_Curve.html
old new 96 96 t.eq( curve.components.length, 4, "new point added to array" ); 97 97 t.eq( bounds.bottom, -30, "bottom bound is -30 after 2nd addComponent" ); 98 98 t.eq( bounds.left, -20, "left bound is 20 after 2nd addComponent" ); 99 t.eq( curve.components[1]. lon, -20, "new point.lon is -20 (index worked)" );100 t.eq( curve.components[1]. lat, -30, "new point.lat is -30 (index worked)" );99 t.eq( curve.components[1].x, -20, "new point.lon is -20 (index worked)" ); 100 t.eq( curve.components[1].y, -30, "new point.lat is -30 (index worked)" ); 101 101 } 102 102 103 103 function test_05_Curve_removeComponent (t) { -
tests/Geometry/test_MultiPoint.html
old new 21 21 } 22 22 23 23 function test_02_MultiPoint_move(t) { 24 t.plan( 4);24 t.plan(2); 25 25 26 26 var multipoint = new OpenLayers.Geometry.MultiPoint([point]); 27 27 var x = point.x; … … 32 32 multipoint.move(dx, dy); 33 33 t.eq(multipoint.components[0].x, x + dx, "move() correctly modifies x"); 34 34 t.eq(multipoint.components[0].y, y + dy, "move() correctly modifies y"); 35 t.eq(multipoint.components[0].lon, x + dx, "move() correctly modifies lon");36 t.eq(multipoint.components[0].lat, y + dy, "move() correctly modifies lat");37 35 } 38 36 39 37 function test_MultiPoint_equals(t) { -
tests/Geometry/test_Point.html
old new 20 20 t.eq( point.CLASS_NAME, "OpenLayers.Geometry.Point", "point.CLASS_NAME is set correctly"); 21 21 t.eq( point.x, x, "point.x is set correctly"); 22 22 t.eq( point.y, y, "point.y is set correctly"); 23 t.eq( point.lon, x, "point.lon is set correctly");24 t.eq( point.lat, y, "point.lat is set correctly");23 t.eq( point.lon, null, "point.lon is not set"); 24 t.eq( point.lat, null, "point.lat is not set"); 25 25 } 26 26 27 function test_02_Point_accessors(t) {28 t.plan( 6 )29 30 //valid31 var x = 10;32 var y = 20;33 point = new OpenLayers.Geometry.Point(x, y);34 35 t.eq( point.getX(), x, "point.x is get() correctly");36 t.eq( point.getY(), y, "point.y is get() correctly");37 38 var x1 = 55;39 var y1 = 73;40 41 point.setX(x1);42 point.setY(y1);43 44 t.eq( point.x, x1, "point.x is set() correctly");45 t.eq( point.y, y1, "point.y is set() correctly");46 t.eq( point.lon, x1, "point.lon is set() correctly");47 t.eq( point.lat, y1, "point.lat is set() correctly");48 49 }50 51 27 function test_03_Point_calculateBounds (t) { 52 28 t.plan(4); 53 29 … … 89 65 } 90 66 91 67 function test_06_Point_move(t) { 92 t.plan( 4);68 t.plan(2); 93 69 94 70 var x = 10; 95 71 var y = 20; … … 100 76 point.move(dx, dy); 101 77 t.eq(point.x, x + dx, "move() correctly modifies x"); 102 78 t.eq(point.y, y + dy, "move() correctly modifies y"); 103 t.eq(point.lon, x + dx, "move() correctly modifies lon");104 t.eq(point.lat, y + dy, "move() correctly modifies lat");105 79 } 106 80 107 81 function test_Point_equals(t) { -
tests/BaseTypes/test_Bounds.html
old new 361 361 362 362 bounds.extend(object); 363 363 364 t.ok( ((bounds.left == object. lon) &&365 (bounds.bottom == object. lat) &&364 t.ok( ((bounds.left == object.x) && 365 (bounds.bottom == object.y) && 366 366 (bounds.right == originalBounds.right) && 367 367 (bounds.top == originalBounds.top)), "obj Point to extends correclty modifies left and bottom"); 368 368 … … 375 375 376 376 t.ok( ((bounds.left == originalBounds.left) && 377 377 (bounds.bottom == originalBounds.bottom) && 378 (bounds.right == object. lon) &&379 (bounds.top == object. lat)), "obj Point to extends correclty modifies right and top");378 (bounds.right == object.x) && 379 (bounds.top == object.y)), "obj Point to extends correclty modifies right and top"); 380 380 381 381 } 382 382 -
lib/OpenLayers/Geometry/Point.js
old new 4 4 5 5 /** 6 6 * @class 7 *8 * The Point class is a subclass of Geometry and also a subclass of the9 * non-vector OpenLayers.LonLat class. The basic functionality that this adds10 * is the ability to switch between lon/lat and x/y at will, as well some11 * convenience functions to create a Bounds from a point and measure the12 * distance between two points.13 7 * 14 * getX() and setX() should be used to access the x or lon variables.15 *16 * @requires OpenLayers/BaseTypes.js17 8 * @requires OpenLayers/Geometry.js 18 9 */ 19 10 OpenLayers.Geometry.Point = OpenLayers.Class.create(); 20 11 OpenLayers.Geometry.Point.prototype = 21 OpenLayers.Class.inherit(OpenLayers.Geometry, OpenLayers.LonLat,{12 OpenLayers.Class.inherit(OpenLayers.Geometry, { 22 13 23 14 /** @type float */ 24 15 x: null, … … 34 25 */ 35 26 initialize: function(x, y) { 36 27 OpenLayers.Geometry.prototype.initialize.apply(this, arguments); 37 OpenLayers.LonLat.prototype.initialize.apply(this, arguments);38 28 39 this.x = this.lon;40 this.y = this.lat;29 this.x = parseFloat(x); 30 this.y = parseFloat(y); 41 31 }, 42 32 43 33 /** … … 55 45 return obj; 56 46 }, 57 47 58 /**59 * Sets the x coordinate60 *61 * @param {float} x62 */63 setX: function(x) {64 this.lon = x;65 this.x = x;66 },67 68 /**69 * Sets the y coordinate70 *71 * @param {float} y72 */73 setY: function(y) {74 this.lat = y;75 this.y = y;76 },77 78 /**79 * @type float80 */81 getX: function() {82 return this.lon;83 },84 85 /**86 * @type float87 */88 getY: function() {89 return this.lat;90 },91 92 48 /** Create a new Bounds based on the lon/lat 93 49 * 94 50 */ 95 51 calculateBounds: function () { 96 this.bounds = new OpenLayers.Bounds(this. lon, this.lat,97 this. lon, this.lat);52 this.bounds = new OpenLayers.Bounds(this.x, this.y, 53 this.x, this.y); 98 54 }, 99 55 100 56 /** … … 111 67 } 112 68 return distance; 113 69 }, 70 71 /** 72 * @param {OpenLayers.Geometry} xy 73 * @returns Boolean value indicating whether the passed-in 74 * OpenLayers.Geometryobject has the same components as this 75 * note that if ll passed in is null, returns false 76 * 77 * @type bool 78 */ 79 equals:function(geom) { 80 var equals = false; 81 if (geom != null) { 82 equals = ((this.x == geom.x && this.y == geom.y) || 83 (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y))); 84 } 85 return equals; 86 }, 114 87 115 88 /** 116 89 * @returns the coordinates as a string … … 121 94 }, 122 95 123 96 /** 97 * @return Shortened String representation of Point object. 98 * (ex. <i>"5, 42"</i>) 99 * @type String 100 */ 101 toShortString: function() { 102 return (this.x + ", " + this.y); 103 }, 104 105 /** 124 106 * Moves a point in place 125 107 * @param {Float} x 126 108 * @param {Float} y 127 109 */ 128 110 move: function(x, y) { 129 this. setX(this.x + x);130 this. setY(this.y + y);111 this.x = this.x + x; 112 this.y = this.y + y; 131 113 }, 132 114 133 115 /** @final @type String */ -
lib/OpenLayers/BaseTypes.js
old new 492 492 var bounds = null; 493 493 if (object) { 494 494 switch(object.CLASS_NAME) { 495 case "OpenLayers.Geometry.Point":496 495 case "OpenLayers.LonLat": 497 496 bounds = new OpenLayers.Bounds(object.lon, object.lat, 498 497 object.lon, object.lat); 499 498 break; 499 case "OpenLayers.Geometry.Point": 500 bounds = new OpenLayers.Bounds(object.x, object.y, 501 object.x, object.y); 502 break; 500 503 501 504 case "OpenLayers.Bounds": 502 505 bounds = object; -
lib/OpenLayers/Renderer/VML.js
old new 333 333 334 334 var path = "m"; 335 335 for (var i = 0; i < geometry.components.length; i++) { 336 var x = (geometry.components[i]. getX()/resolution);337 var y = (geometry.components[i]. getY()/resolution);336 var x = (geometry.components[i].x/resolution); 337 var y = (geometry.components[i].y/resolution); 338 338 path += " " + x.toFixed() + "," + y.toFixed() + " l "; 339 339 } 340 340 if (closeLine) { … … 360 360 361 361 path += "m"; 362 362 for (var i = 0; i < linearRing.components.length; i++) { 363 var x = linearRing.components[i]. getX()/ resolution;364 var y = linearRing.components[i]. getY()/ resolution;363 var x = linearRing.components[i].x / resolution; 364 var y = linearRing.components[i].y / resolution; 365 365 path += " " + x.toFixed() + "," + y.toFixed(); 366 366 if (i==0) { 367 367 path += " l"; … … 399 399 400 400 var path = ""; 401 401 for (var i = 0; i < geometry.components.length; i++) { 402 var x = geometry.components[i]. getX()/ resolution;403 var y = geometry.components[i]. getY()/ resolution;402 var x = geometry.components[i].x / resolution; 403 var y = geometry.components[i].y / resolution; 404 404 405 405 if ((i%3)==0 && (i/3)==0) { 406 406 path += "m" … … 426 426 427 427 var path = ""; 428 428 for (var i = 0; i < geometry.components.length; i++) { 429 var x = geometry.components[i]. getX()/ resolution;430 var y = geometry.components[i]. getY()/ resolution;429 var x = geometry.components[i].x / resolution; 430 var y = geometry.components[i].y / resolution; 431 431 if ((i%3)==0 && (i/3)==0) { 432 432 path += "m"; 433 433 } else if ((i%3)==1) { -
lib/OpenLayers/Handler/Point.js
old new 188 188 this.lastDown = evt.xy; 189 189 this.drawing = true; 190 190 var lonlat = this.map.getLonLatFromPixel(evt.xy); 191 this.point. setX(lonlat.lon);192 this.point. setY(lonlat.lat);191 this.point.x = lonlat.lon; 192 this.point.y = lonlat.lat; 193 193 this.drawGeometry(); 194 194 return false; 195 195 }, … … 204 204 mousemove: function (evt) { 205 205 if(this.drawing) { 206 206 var lonlat = this.map.getLonLatFromPixel(evt.xy); 207 this.point. setX(lonlat.lon);208 this.point. setY(lonlat.lat);207 this.point.x = lonlat.lon; 208 this.point.y = lonlat.lat; 209 209 this.drawGeometry(); 210 210 } 211 211 return true; -
lib/OpenLayers/Handler/Path.js
old new 141 141 this.mouseDown = true; 142 142 this.lastDown = evt.xy; 143 143 var lonlat = this.control.map.getLonLatFromPixel(evt.xy); 144 this.point. setX(lonlat.lon);145 this.point. setY(lonlat.lat);144 this.point.x = lonlat.lon; 145 this.point.y = lonlat.lat; 146 146 if((this.lastUp == null) || !this.lastUp.equals(evt.xy)) { 147 147 this.addPoint(); 148 148 } … … 161 161 mousemove: function (evt) { 162 162 if(this.drawing) { 163 163 var lonlat = this.map.getLonLatFromPixel(evt.xy); 164 this.point. setX(lonlat.lon);165 this.point. setY(lonlat.lat);164 this.point.x = lonlat.lon; 165 this.point.y = lonlat.lat; 166 166 if(this.mouseDown && this.freehandMode(evt)) { 167 167 this.addPoint(); 168 168 } else {
