Add reprojection support on Geometry classes. Geometries can now be transformed
in place by using .transform(source, dest). r=elemoine (Closes #1037) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5515 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -306,6 +306,27 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
|
|||||||
return equivalent;
|
return equivalent;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: transform
|
||||||
|
* Reproject the components geometry from source to dest.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* source - {<OpenLayers.Projection>}
|
||||||
|
* dest - {<OpenLayers.Projection>}
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {<OpenLayers.Geometry>}
|
||||||
|
*/
|
||||||
|
transform: function(source, dest) {
|
||||||
|
if (source && dest) {
|
||||||
|
for (var i = 0; i < this.components.length; i++) {
|
||||||
|
var component = this.components[i];
|
||||||
|
component.transform(source, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: intersects
|
* APIMethod: intersects
|
||||||
* Determine if the input geometry intersects this one.
|
* Determine if the input geometry intersects this one.
|
||||||
|
|||||||
@@ -152,6 +152,27 @@ OpenLayers.Geometry.LinearRing = OpenLayers.Class(
|
|||||||
this.components[i].resize(scale, origin, ratio);
|
this.components[i].resize(scale, origin, ratio);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: transform
|
||||||
|
* Reproject the components geometry from source to dest.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* source - {<OpenLayers.Projection>}
|
||||||
|
* dest - {<OpenLayers.Projection>}
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {<OpenLayers.Geometry>}
|
||||||
|
*/
|
||||||
|
transform: function(source, dest) {
|
||||||
|
if (source && dest) {
|
||||||
|
for (var i = 0; i < this.components.length - 1; i++) {
|
||||||
|
var component = this.components[i];
|
||||||
|
component.transform(source, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: getArea
|
* APIMethod: getArea
|
||||||
|
|||||||
@@ -188,6 +188,25 @@ OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {
|
|||||||
}
|
}
|
||||||
return intersect;
|
return intersect;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIMethod: transform
|
||||||
|
* Translate the x,y properties of the point from source to dest.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* source - {<OpenLayers.Projection>}
|
||||||
|
* dest - {<OpenLayers.Projection>}
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {<OpenLayers.Geometry>}
|
||||||
|
*/
|
||||||
|
transform: function(source, dest) {
|
||||||
|
if ((source && dest)) {
|
||||||
|
OpenLayers.Projection.transform(
|
||||||
|
this, source, dest);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
CLASS_NAME: "OpenLayers.Geometry.Point"
|
CLASS_NAME: "OpenLayers.Geometry.Point"
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user