Use in-place transforms where possible

This commit is contained in:
Tim Schaub
2013-03-03 20:53:13 +01:00
parent 40bde4056b
commit e9fa08fccb
3 changed files with 27 additions and 7 deletions

View File

@@ -79,9 +79,10 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
this.transformFn_ = ol.projection.getTransform(
ol.projection.getFromCode('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) {
var output = this.transformFn_([this.position_.x, this.position_.y]);
var vertex = [this.position_.x, this.position_.y];
vertex = this.transformFn_(vertex, vertex, 2);
this.set(ol.GeolocationProperty.POSITION,
new ol.Coordinate(output[0], output[1]));
new ol.Coordinate(vertex[0], vertex[1]));
}
}
};
@@ -109,9 +110,10 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
this.set(ol.GeolocationProperty.HEADING, goog.isNull(coords.heading) ?
undefined : goog.math.toRadians(coords.heading));
this.position_ = new ol.Coordinate(coords.longitude, coords.latitude);
var output = this.transformFn_([coords.longitude, coords.latitude]);
var vertex = [coords.longitude, coords.latitude];
vertex = this.transformFn_(vertex, vertex, 2);
this.set(ol.GeolocationProperty.POSITION,
new ol.Coordinate(output[0], output[1]));
new ol.Coordinate(vertex[0], vertex[1]));
this.set(ol.GeolocationProperty.SPEED,
goog.isNull(coords.speed) ? undefined : coords.speed);
};