Ticket #1210: 1210.patch
| File 1210.patch, 4.8 kB (added by crschmidt, 1 year ago) |
|---|
-
lib/OpenLayers/Projection.js
old new 93 93 }); 94 94 95 95 /** 96 * APIProperty: transformations 97 * Transformations is an object, with from properties, each of which may 98 * have a to property. This allows you to define projections without 99 * requiring support for proj4js to be included. 100 * 101 * This object has keys which correspond to a 'source' projection object. The 102 * keys should be strings, corresponding to the projection.getCode() value. 103 * Each source projection object should have a set of destination projection 104 * keys included in the object. 105 * 106 * Each value in the destination object should be a transformation function, 107 * where the function is expected to be passed an object with a .x and a .y 108 * property. The function should return the object, with the .x and .y 109 * transformed according to the transformation function. 110 * 111 * For an example of usage, see the OpenLayers.Layer.SphericalMercator file. 112 */ 113 OpenLayers.Projection.transformations = {}; 114 115 /** 96 116 * APIMethod: transform 97 117 * Read data from a string, and return an object whose type depends on the 98 118 * subclass. … … 108 128 OpenLayers.Projection.transform = function(point, source, dest) { 109 129 if (source.proj && dest.proj) { 110 130 point = Proj4js.transform(source.proj, dest.proj, point); 111 } 131 } else if (source && dest && 132 OpenLayers.Projection.transformations[source.getCode()] && 133 OpenLayers.Projection.transformations[source.getCode()][dest.getCode()]) { 134 point = OpenLayers.Projection.transformations[source.getCode()][dest.getCode()](point) 135 } 136 112 137 return point; 113 138 }; -
lib/OpenLayers/Layer/SphericalMercator.js
old new 1 1 /** @requires OpenLayers/Layer.js 2 * @requires OpenLayers/Projection.js 2 3 * 3 4 * Class: OpenLayers.Layer.SphericalMercator 4 5 * A mixin for layers that wraps up the pieces neccesary to have a coordinate … … 101 102 lat = 180/Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2); 102 103 103 104 return new OpenLayers.LonLat(lon, lat); 105 }, 106 107 /** 108 * APIMethod: projectForward 109 * Given an object with x and y properties in EPSG:4326, modify the x,y 110 * properties on the object to be the Spherical Mercator projected 111 * coordinates. 112 * 113 * Parameters: 114 * point - {Object} An object with x and y properties. 115 * 116 * Returns: 117 * {Object} The point, with the x and y properties transformed to spherical 118 * mercator. 119 */ 120 projectForward: function(point) { 121 var lonlat = OpenLayers.Layer.SphericalMercator.forwardMercator(point.x, point.y); 122 point.x = lonlat.lon; 123 point.y = lonlat.lat; 124 return point; 125 }, 126 127 /** 128 * APIMethod: projectForward 129 * Given an object with x and y properties in Spherical Mercator, modify 130 * the x,y properties on the object to be the unprojected coordinates. 131 * 132 * Parameters: 133 * point - {Object} An object with x and y properties. 134 * 135 * Returns: 136 * {Object} The point, with the x and y properties transformed from 137 * spherical mercator to unprojected coordinates.. 138 */ 139 projectInverse: function(point) { 140 var lonlat = OpenLayers.Layer.SphericalMercator.inverseMercator(point.x, point.y); 141 point.x = lonlat.lon; 142 point.y = lonlat.lat; 143 return point; 104 144 } 105 145 106 146 }; 147 148 // Define transforms to/from spherical mercator projection. 149 150 OpenLayers.Projection.transformations['EPSG:4326'] = { 151 'EPSG:900913': OpenLayers.Layer.SphericalMercator.projectForward 152 }; 153 OpenLayers.Projection.transformations['EPSG:900913'] = { 154 'EPSG:4326': OpenLayers.Layer.SphericalMercator.projectInverse 155 } -
lib/OpenLayers.js
old new 78 78 "Rico/Color.js", 79 79 "OpenLayers/Ajax.js", 80 80 "OpenLayers/Events.js", 81 "OpenLayers/Projection.js", 81 82 "OpenLayers/Map.js", 82 83 "OpenLayers/Layer.js", 83 84 "OpenLayers/Icon.js", … … 175 176 "OpenLayers/Layer/WFS.js", 176 177 "OpenLayers/Control/MouseToolbar.js", 177 178 "OpenLayers/Control/NavToolbar.js", 178 "OpenLayers/Control/EditingToolbar.js", 179 "OpenLayers/Projection.js" 179 "OpenLayers/Control/EditingToolbar.js" 180 180 ); // etc. 181 181 182 182
