Allow transforming geometries, lonlat, and bounds with strings.

This commit is contained in:
tschaub
2011-10-26 16:23:48 -06:00
parent 98d6e74314
commit a606e565d3
5 changed files with 61 additions and 8 deletions

View File

@@ -186,12 +186,19 @@ OpenLayers.Projection.addTransform = function(from, to, method) {
* point - {object} A transformed coordinate. The original point is modified.
*/
OpenLayers.Projection.transform = function(point, source, dest) {
if (source.proj && dest.proj) {
point = Proj4js.transform(source.proj, dest.proj, point);
} else if (source && dest &&
OpenLayers.Projection.transforms[source.getCode()] &&
OpenLayers.Projection.transforms[source.getCode()][dest.getCode()]) {
OpenLayers.Projection.transforms[source.getCode()][dest.getCode()](point);
if (source && dest) {
if (!(source instanceof OpenLayers.Projection)) {
source = new OpenLayers.Projection(source);
}
if (!(dest instanceof OpenLayers.Projection)) {
dest = new OpenLayers.Projection(dest);
}
if (source.proj && dest.proj) {
point = Proj4js.transform(source.proj, dest.proj, point);
} else if (OpenLayers.Projection.transforms[source.getCode()] &&
OpenLayers.Projection.transforms[source.getCode()][dest.getCode()]) {
OpenLayers.Projection.transforms[source.getCode()][dest.getCode()](point);
}
}
return point;
};