Merge pull request #232 from tschaub/projection-tests

Projection tests
This commit is contained in:
Tim Schaub
2013-02-27 21:06:54 -08:00
2 changed files with 100 additions and 0 deletions

View File

@@ -266,6 +266,31 @@ ol.Projection.addTransform = function(source, destination, transformFn) {
};
/**
* Unregisters the conversion function to convert coordinates from the source
* projection to the destination projection. This method is used to clean up
* cached transforms during testing.
*
* @param {ol.Projection} source Source projection.
* @param {ol.Projection} destination Destination projection.
* @return {ol.TransformFunction} transformFn The unregistered transform.
*/
ol.Projection.removeTransform = function(source, destination) {
var sourceCode = source.getCode();
var destinationCode = destination.getCode();
var transforms = ol.Projection.transforms_;
goog.asserts.assert(sourceCode in transforms);
goog.asserts.assert(destinationCode in transforms[sourceCode]);
var transform = transforms[sourceCode][destinationCode];
delete transforms[sourceCode][destinationCode];
var keys = goog.object.getKeys(transforms[sourceCode]);
if (keys.length == 0) {
delete transforms[sourceCode];
}
return transform;
};
/**
* @param {string} code Code which is a combination of authority and identifier
* such as “EPSG:4326”.