Merge branch 'master' of github.com:openlayers/ol3 into vector
This commit is contained in:
@@ -8,6 +8,7 @@ goog.require('goog.dom');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.CoordinateFormatType');
|
||||
goog.require('ol.MapEvent');
|
||||
goog.require('ol.MapEventType');
|
||||
@@ -177,7 +178,9 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
|
||||
var map = this.getMap();
|
||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
||||
if (!goog.isNull(coordinate)) {
|
||||
coordinate = this.transform_(coordinate);
|
||||
var vertex = [coordinate.x, coordinate.y];
|
||||
vertex = this.transform_(vertex, vertex);
|
||||
coordinate = new ol.Coordinate(vertex[0], vertex[1]);
|
||||
if (goog.isDef(this.coordinateFormat_)) {
|
||||
html = this.coordinateFormat_(coordinate);
|
||||
} else {
|
||||
|
||||
9
src/ol/control/scaleline.exports
Normal file
9
src/ol/control/scaleline.exports
Normal file
@@ -0,0 +1,9 @@
|
||||
@exportClass ol.control.ScaleLine ol.control.ScaleLineOptions
|
||||
@exportProperty ol.control.ScaleLine.prototype.setMap
|
||||
|
||||
@exportSymbol ol.control.ScaleLineUnits
|
||||
@exportProperty ol.control.ScaleLineUnits.DEGREES
|
||||
@exportProperty ol.control.ScaleLineUnits.IMPERIAL
|
||||
@exportProperty ol.control.ScaleLineUnits.NAUTICAL
|
||||
@exportProperty ol.control.ScaleLineUnits.METRIC
|
||||
@exportProperty ol.control.ScaleLineUnits.US
|
||||
277
src/ol/control/scalelinecontrol.js
Normal file
277
src/ol/control/scalelinecontrol.js
Normal file
@@ -0,0 +1,277 @@
|
||||
goog.provide('ol.control.ScaleLine');
|
||||
goog.provide('ol.control.ScaleLineUnits');
|
||||
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol.FrameState');
|
||||
goog.require('ol.MapEvent');
|
||||
goog.require('ol.MapEventType');
|
||||
goog.require('ol.ProjectionUnits');
|
||||
goog.require('ol.TransformFunction');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.projection');
|
||||
goog.require('ol.sphere.NORMAL');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.control.ScaleLineUnits = {
|
||||
DEGREES: 'degrees',
|
||||
IMPERIAL: 'imperial',
|
||||
NAUTICAL: 'nautical',
|
||||
METRIC: 'metric',
|
||||
US: 'us'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.control.Control}
|
||||
* @param {ol.control.ScaleLineOptions=} opt_options Options.
|
||||
*/
|
||||
ol.control.ScaleLine = function(opt_options) {
|
||||
|
||||
var options = opt_options || {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
this.innerElement_ = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-scale-line-inner'
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
this.element_ = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-scale-line ol-unselectable'
|
||||
}, this.innerElement_);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.minWidth_ = goog.isDef(options.minWidth) ? options.minWidth : 64;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.control.ScaleLineUnits}
|
||||
*/
|
||||
this.units_ = goog.isDef(options.units) ?
|
||||
options.units : ol.control.ScaleLineUnits.METRIC;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<?number>}
|
||||
*/
|
||||
this.listenerKeys_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.renderedVisible_ = false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.renderedWidth_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.renderedHTML_ = '';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?ol.TransformFunction}
|
||||
*/
|
||||
this.toEPSG4326_ = null;
|
||||
|
||||
goog.base(this, {
|
||||
element: this.element_,
|
||||
map: options.map,
|
||||
target: options.target
|
||||
});
|
||||
|
||||
};
|
||||
goog.inherits(ol.control.ScaleLine, ol.control.Control);
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
ol.control.ScaleLine.LEADING_DIGITS = [1, 2, 5];
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapEvent} mapEvent Map event.
|
||||
*/
|
||||
ol.control.ScaleLine.prototype.handleMapPostrender = function(mapEvent) {
|
||||
var frameState = mapEvent.frameState;
|
||||
this.updateElement_(mapEvent.frameState);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.control.ScaleLine.prototype.setMap = function(map) {
|
||||
if (!goog.isNull(this.listenerKeys_)) {
|
||||
goog.array.forEach(this.listenerKeys_, goog.events.unlistenByKey);
|
||||
this.listenerKeys_ = null;
|
||||
}
|
||||
goog.base(this, 'setMap', map);
|
||||
if (!goog.isNull(map)) {
|
||||
this.listenerKeys_ = [
|
||||
goog.events.listen(map, ol.MapEventType.POSTRENDER,
|
||||
this.handleMapPostrender, false, this)
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {?ol.FrameState} frameState Frame state.
|
||||
* @private
|
||||
*/
|
||||
ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
|
||||
|
||||
if (goog.isNull(frameState)) {
|
||||
if (this.renderedVisible_) {
|
||||
goog.style.showElement(this.element_, false);
|
||||
this.renderedVisible_ = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var view2DState = frameState.view2DState;
|
||||
var center = view2DState.center;
|
||||
var projection = view2DState.projection;
|
||||
var pointResolution =
|
||||
projection.getPointResolution(view2DState.resolution, center);
|
||||
var projectionUnits = projection.getUnits();
|
||||
|
||||
var cosLatitude;
|
||||
if (projectionUnits == ol.ProjectionUnits.DEGREES &&
|
||||
(this.units_ == ol.control.ScaleLineUnits.METRIC ||
|
||||
this.units_ == ol.control.ScaleLineUnits.IMPERIAL)) {
|
||||
|
||||
// Convert pointResolution from degrees to meters
|
||||
this.toEPSG4326_ = null;
|
||||
cosLatitude = Math.cos(goog.math.toRadians(center.y));
|
||||
pointResolution *= Math.PI * cosLatitude * ol.sphere.NORMAL.radius / 180;
|
||||
|
||||
} else if (projectionUnits == ol.ProjectionUnits.METERS &&
|
||||
this.units_ == ol.control.ScaleLineUnits.DEGREES) {
|
||||
|
||||
// Convert pointResolution from meters to degrees
|
||||
if (goog.isNull(this.toEPSG4326_)) {
|
||||
this.toEPSG4326_ = ol.projection.getTransform(
|
||||
projection, ol.projection.getFromCode('EPSG:4326'));
|
||||
}
|
||||
var vertex = [center.x, center.y];
|
||||
vertex = this.toEPSG4326_(vertex, vertex, 2);
|
||||
cosLatitude = Math.cos(goog.math.toRadians(vertex[1]));
|
||||
pointResolution *= 180 / (Math.PI * cosLatitude * ol.sphere.NORMAL.radius);
|
||||
|
||||
} else {
|
||||
|
||||
this.toEPSG4326_ = null;
|
||||
goog.asserts.assert(
|
||||
((this.units_ == ol.control.ScaleLineUnits.METRIC ||
|
||||
this.units_ == ol.control.ScaleLineUnits.IMPERIAL) &&
|
||||
projectionUnits == ol.ProjectionUnits.METERS) ||
|
||||
(this.units_ == ol.control.ScaleLineUnits.DEGREES &&
|
||||
projectionUnits == ol.ProjectionUnits.DEGREES));
|
||||
|
||||
}
|
||||
|
||||
var nominalCount = this.minWidth_ * pointResolution;
|
||||
var suffix = '';
|
||||
if (this.units_ == ol.control.ScaleLineUnits.DEGREES) {
|
||||
if (nominalCount < 1 / 60) {
|
||||
suffix = '\u2033'; // seconds
|
||||
pointResolution *= 3600;
|
||||
} else if (nominalCount < 1) {
|
||||
suffix = '\u2032'; // minutes
|
||||
pointResolution *= 60;
|
||||
} else {
|
||||
suffix = '\u00b0'; // degrees
|
||||
}
|
||||
} else if (this.units_ == ol.control.ScaleLineUnits.IMPERIAL) {
|
||||
if (nominalCount < 0.9144) {
|
||||
suffix = 'in';
|
||||
pointResolution /= 0.0254;
|
||||
} else if (nominalCount < 1609.344) {
|
||||
suffix = 'ft';
|
||||
pointResolution /= 0.3048;
|
||||
} else {
|
||||
suffix = 'mi';
|
||||
pointResolution /= 1609.344;
|
||||
}
|
||||
} else if (this.units_ == ol.control.ScaleLineUnits.NAUTICAL) {
|
||||
pointResolution /= 1852;
|
||||
suffix = 'nm';
|
||||
} else if (this.units_ == ol.control.ScaleLineUnits.METRIC) {
|
||||
if (nominalCount < 1) {
|
||||
suffix = 'mm';
|
||||
pointResolution *= 1000;
|
||||
} else if (nominalCount < 1000) {
|
||||
suffix = 'm';
|
||||
} else {
|
||||
suffix = 'km';
|
||||
pointResolution /= 1000;
|
||||
}
|
||||
} else if (this.units_ == ol.control.ScaleLineUnits.US) {
|
||||
if (nominalCount < 0.9144) {
|
||||
suffix = 'in';
|
||||
pointResolution *= 39.37;
|
||||
} else if (nominalCount < 1609.344) {
|
||||
suffix = 'ft';
|
||||
pointResolution /= 0.30480061;
|
||||
} else {
|
||||
suffix = 'mi';
|
||||
pointResolution /= 1609.3472;
|
||||
}
|
||||
} else {
|
||||
goog.asserts.assert(false);
|
||||
}
|
||||
|
||||
var i = 3 * Math.floor(
|
||||
Math.log(this.minWidth_ * pointResolution) / Math.log(10));
|
||||
var count, width;
|
||||
while (true) {
|
||||
count = ol.control.ScaleLine.LEADING_DIGITS[i % 3] *
|
||||
Math.pow(10, Math.floor(i / 3));
|
||||
width = Math.round(count / pointResolution);
|
||||
if (width >= this.minWidth_) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
var html = count + suffix;
|
||||
if (this.renderedHTML_ != html) {
|
||||
this.innerElement_.innerHTML = html;
|
||||
this.renderedHTML_ = html;
|
||||
}
|
||||
|
||||
if (this.renderedWidth_ != width) {
|
||||
this.innerElement_.style.width = width + 'px';
|
||||
this.renderedWidth_ = width;
|
||||
}
|
||||
|
||||
if (!this.renderedVisible_) {
|
||||
goog.style.showElement(this.element_, true);
|
||||
this.renderedVisible_ = true;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -6,7 +6,6 @@ goog.require('goog.dom');
|
||||
goog.require('goog.dom.TagName');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('ol.BrowserFeature');
|
||||
goog.require('ol.control.Control');
|
||||
|
||||
|
||||
@@ -24,20 +23,23 @@ ol.control.ZOOM_DURATION = 250;
|
||||
*/
|
||||
ol.control.Zoom = function(zoomOptions) {
|
||||
|
||||
var eventType = ol.BrowserFeature.HAS_TOUCH ?
|
||||
goog.events.EventType.TOUCHEND : goog.events.EventType.CLICK;
|
||||
|
||||
var inElement = goog.dom.createDom(goog.dom.TagName.A, {
|
||||
'href': '#zoomIn',
|
||||
'class': 'ol-zoom-in'
|
||||
});
|
||||
goog.events.listen(inElement, eventType, this.handleIn_, false, this);
|
||||
goog.events.listen(inElement, [
|
||||
goog.events.EventType.TOUCHEND,
|
||||
goog.events.EventType.CLICK
|
||||
], this.handleIn_, false, this);
|
||||
|
||||
var outElement = goog.dom.createDom(goog.dom.TagName.A, {
|
||||
'href': '#zoomOut',
|
||||
'class': 'ol-zoom-out'
|
||||
});
|
||||
goog.events.listen(outElement, eventType, this.handleOut_, false, this);
|
||||
goog.events.listen(outElement, [
|
||||
goog.events.EventType.TOUCHEND,
|
||||
goog.events.EventType.CLICK
|
||||
], this.handleOut_, false, this);
|
||||
|
||||
var element = goog.dom.createDom(
|
||||
goog.dom.TagName.DIV, 'ol-zoom ol-unselectable', inElement, outElement);
|
||||
|
||||
@@ -108,8 +108,10 @@ ol.Extent.prototype.getTopRight = function() {
|
||||
* @return {ol.Extent} Extent.
|
||||
*/
|
||||
ol.Extent.prototype.transform = function(transformFn) {
|
||||
var a = transformFn(new ol.Coordinate(this.minX, this.minY));
|
||||
var b = transformFn(new ol.Coordinate(this.maxX, this.maxY));
|
||||
return new ol.Extent(Math.min(a.x, b.x), Math.min(a.y, b.y),
|
||||
Math.max(a.x, b.x), Math.max(a.y, b.y));
|
||||
var input = [this.minX, this.minY, this.maxX, this.maxY];
|
||||
input = transformFn(input, input, 2);
|
||||
return new ol.Extent(Math.min(input[0], input[2]),
|
||||
Math.min(input[1], input[3]),
|
||||
Math.max(input[0], input[2]),
|
||||
Math.max(input[1], input[3]));
|
||||
};
|
||||
|
||||
@@ -76,11 +76,13 @@ ol.Geolocation.prototype.disposeInternal = function() {
|
||||
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
|
||||
var projection = this.getProjection();
|
||||
if (goog.isDefAndNotNull(projection)) {
|
||||
this.transformCoords_ = ol.projection.getTransform(
|
||||
this.transformFn_ = ol.projection.getTransform(
|
||||
ol.projection.getFromCode('EPSG:4326'), projection);
|
||||
if (!goog.isNull(this.position_)) {
|
||||
var vertex = [this.position_.x, this.position_.y];
|
||||
vertex = this.transformFn_(vertex, vertex, 2);
|
||||
this.set(ol.GeolocationProperty.POSITION,
|
||||
this.transformCoords_(this.position_));
|
||||
new ol.Coordinate(vertex[0], vertex[1]));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -108,8 +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 vertex = [coords.longitude, coords.latitude];
|
||||
vertex = this.transformFn_(vertex, vertex, 2);
|
||||
this.set(ol.GeolocationProperty.POSITION,
|
||||
this.transformCoords_(this.position_));
|
||||
new ol.Coordinate(vertex[0], vertex[1]));
|
||||
this.set(ol.GeolocationProperty.SPEED,
|
||||
goog.isNull(coords.speed) ? undefined : coords.speed);
|
||||
};
|
||||
@@ -230,7 +234,9 @@ goog.exportProperty(
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
* @param {Array.<number>} input Input coordinate values.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
* @param {number=} opt_dimension Dimension (default is 2).
|
||||
* @return {Array.<number>} Output coordinate values.
|
||||
*/
|
||||
ol.Geolocation.prototype.transformCoords_ = goog.functions.identity;
|
||||
ol.Geolocation.prototype.transformFn_ = goog.functions.identity;
|
||||
|
||||
@@ -80,7 +80,7 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
|
||||
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
view.setHint(ol.ViewHint.PANNING, -1);
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
|
||||
if (this.kinetic_ && this.kinetic_.end()) {
|
||||
var distance = this.kinetic_.getDistance();
|
||||
@@ -111,7 +111,7 @@ ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
|
||||
}
|
||||
var map = mapBrowserEvent.map;
|
||||
map.requestRenderFrame();
|
||||
map.getView().setHint(ol.ViewHint.PANNING, 1);
|
||||
map.getView().setHint(ol.ViewHint.INTERACTING, 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -31,6 +31,7 @@ ol.interaction.Touch = function() {
|
||||
|
||||
/**
|
||||
* @type {Array.<Object>}
|
||||
* @protected
|
||||
*/
|
||||
this.targetTouches = [];
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// FIXME works for View2D only
|
||||
// FIXME opt_kinetic param
|
||||
goog.provide('ol.interaction.TouchPan');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
@@ -16,16 +15,17 @@ goog.require('ol.interaction.Touch');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Touch}
|
||||
* @param {ol.Kinetic=} opt_kinetic Kinetic object.
|
||||
*/
|
||||
ol.interaction.TouchPan = function() {
|
||||
ol.interaction.TouchPan = function(opt_kinetic) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Kinetic}
|
||||
* @type {ol.Kinetic|undefined}
|
||||
*/
|
||||
this.kinetic_ = new ol.Kinetic(-0.005, 0.05, 100);
|
||||
this.kinetic_ = opt_kinetic;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -49,7 +49,9 @@ ol.interaction.TouchPan.prototype.handleTouchMove = function(mapBrowserEvent) {
|
||||
goog.asserts.assert(this.targetTouches.length >= 1);
|
||||
var centroid = ol.interaction.Touch.centroid(this.targetTouches);
|
||||
if (!goog.isNull(this.lastCentroid)) {
|
||||
this.kinetic_.update(centroid.x, centroid.y);
|
||||
if (this.kinetic_) {
|
||||
this.kinetic_.update(centroid.x, centroid.y);
|
||||
}
|
||||
var deltaX = this.lastCentroid.x - centroid.x;
|
||||
var deltaY = centroid.y - this.lastCentroid.y;
|
||||
var view = mapBrowserEvent.map.getView();
|
||||
@@ -71,8 +73,8 @@ ol.interaction.TouchPan.prototype.handleTouchEnd =
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
if (this.targetTouches.length == 0) {
|
||||
view.setHint(ol.ViewHint.PANNING, -1);
|
||||
if (this.kinetic_.end()) {
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
if (this.kinetic_ && this.kinetic_.end()) {
|
||||
var distance = this.kinetic_.getDistance();
|
||||
var angle = this.kinetic_.getAngle();
|
||||
var center = view.getCenter();
|
||||
@@ -87,6 +89,7 @@ ol.interaction.TouchPan.prototype.handleTouchEnd =
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
this.lastCentroid = null;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -107,8 +110,10 @@ ol.interaction.TouchPan.prototype.handleTouchStart =
|
||||
view.setCenter(mapBrowserEvent.frameState.view2DState.center);
|
||||
this.kineticPreRenderFn_ = null;
|
||||
}
|
||||
this.kinetic_.begin();
|
||||
view.setHint(ol.ViewHint.PANNING, 1);
|
||||
if (this.kinetic_) {
|
||||
this.kinetic_.begin();
|
||||
}
|
||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// FIXME works for View2D only
|
||||
|
||||
goog.provide('ol.interaction.TouchRotateAndZoom');
|
||||
goog.provide('ol.interaction.TouchRotate');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.View');
|
||||
@@ -12,8 +12,10 @@ goog.require('ol.interaction.Touch');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Touch}
|
||||
* @param {number=} opt_threshold Minimal angle to start a rotation.
|
||||
* Default to 0.3 (radian).
|
||||
*/
|
||||
ol.interaction.TouchRotateAndZoom = function() {
|
||||
ol.interaction.TouchRotate = function(opt_threshold) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
@@ -23,12 +25,6 @@ ol.interaction.TouchRotateAndZoom = function() {
|
||||
*/
|
||||
this.lastAngle_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.lastDistance_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
@@ -45,23 +41,20 @@ ol.interaction.TouchRotateAndZoom = function() {
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.rotationThreshold_ = 0.3;
|
||||
this.threshold_ = goog.isDef(opt_threshold) ? opt_threshold : 0.3;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.TouchRotateAndZoom, ol.interaction.Touch);
|
||||
goog.inherits(ol.interaction.TouchRotate, ol.interaction.Touch);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.TouchRotateAndZoom.prototype.handleTouchMove =
|
||||
ol.interaction.TouchRotate.prototype.handleTouchMove =
|
||||
function(mapBrowserEvent) {
|
||||
goog.asserts.assert(this.targetTouches.length >= 2);
|
||||
var scaleDelta = 1.0;
|
||||
var rotationDelta = 0.0;
|
||||
|
||||
var centroid = ol.interaction.Touch.centroid(this.targetTouches);
|
||||
|
||||
var touch0 = this.targetTouches[0];
|
||||
var touch1 = this.targetTouches[1];
|
||||
var dx = touch0.clientX - touch1.clientX;
|
||||
@@ -72,19 +65,11 @@ ol.interaction.TouchRotateAndZoom.prototype.handleTouchMove =
|
||||
touch1.clientY - touch0.clientY,
|
||||
touch1.clientX - touch0.clientX);
|
||||
|
||||
// distance between touches
|
||||
var distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (goog.isDef(this.lastDistance_)) {
|
||||
scaleDelta = this.lastDistance_ / distance;
|
||||
}
|
||||
this.lastDistance_ = distance;
|
||||
|
||||
if (goog.isDef(this.lastAngle_)) {
|
||||
var delta = angle - this.lastAngle_;
|
||||
this.rotationDelta_ += delta;
|
||||
if (!this.rotating_ &&
|
||||
Math.abs(this.rotationDelta_) > this.rotationThreshold_) {
|
||||
Math.abs(this.rotationDelta_) > this.threshold_) {
|
||||
this.rotating_ = true;
|
||||
}
|
||||
rotationDelta = delta;
|
||||
@@ -94,17 +79,15 @@ ol.interaction.TouchRotateAndZoom.prototype.handleTouchMove =
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
|
||||
// rotate / scale anchor point.
|
||||
// rotate anchor point.
|
||||
// FIXME: should be the intersection point between the lines:
|
||||
// touch0,touch1 and previousTouch0,previousTouch1
|
||||
var viewportPosition = goog.style.getClientPosition(map.getViewport());
|
||||
var centroid = ol.interaction.Touch.centroid(this.targetTouches);
|
||||
centroid.x -= viewportPosition.x;
|
||||
centroid.y -= viewportPosition.y;
|
||||
var anchor = map.getCoordinateFromPixel(centroid);
|
||||
|
||||
// scale, bypass the resolution constraint
|
||||
view.zoom_(map, view.getResolution() * scaleDelta, anchor);
|
||||
|
||||
// rotate
|
||||
if (this.rotating_) {
|
||||
view.rotate(map, view.getRotation() + rotationDelta, anchor);
|
||||
@@ -115,14 +98,12 @@ ol.interaction.TouchRotateAndZoom.prototype.handleTouchMove =
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.TouchRotateAndZoom.prototype.handleTouchEnd =
|
||||
ol.interaction.TouchRotate.prototype.handleTouchEnd =
|
||||
function(mapBrowserEvent) {
|
||||
if (this.targetTouches.length < 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
// take the resolution constraint into account
|
||||
view.zoomToResolution(map, view.getResolution());
|
||||
view.setHint(ol.ViewHint.PANNING, -1);
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -133,15 +114,14 @@ ol.interaction.TouchRotateAndZoom.prototype.handleTouchEnd =
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.TouchRotateAndZoom.prototype.handleTouchStart =
|
||||
ol.interaction.TouchRotate.prototype.handleTouchStart =
|
||||
function(mapBrowserEvent) {
|
||||
if (this.targetTouches.length >= 2) {
|
||||
var view = mapBrowserEvent.map.getView();
|
||||
this.lastDistance_ = undefined;
|
||||
this.lastAngle_ = undefined;
|
||||
this.rotating_ = false;
|
||||
this.rotationDelta_ = 0.0;
|
||||
view.setHint(ol.ViewHint.PANNING, 1);
|
||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
98
src/ol/interaction/touchzoominteraction.js
Normal file
98
src/ol/interaction/touchzoominteraction.js
Normal file
@@ -0,0 +1,98 @@
|
||||
// FIXME works for View2D only
|
||||
|
||||
goog.provide('ol.interaction.TouchZoom');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.interaction.Touch');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Touch}
|
||||
*/
|
||||
ol.interaction.TouchZoom = function() {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.lastDistance_;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.TouchZoom, ol.interaction.Touch);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.TouchZoom.prototype.handleTouchMove =
|
||||
function(mapBrowserEvent) {
|
||||
goog.asserts.assert(this.targetTouches.length >= 2);
|
||||
var scaleDelta = 1.0;
|
||||
|
||||
var touch0 = this.targetTouches[0];
|
||||
var touch1 = this.targetTouches[1];
|
||||
var dx = touch0.clientX - touch1.clientX;
|
||||
var dy = touch0.clientY - touch1.clientY;
|
||||
|
||||
// distance between touches
|
||||
var distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (goog.isDef(this.lastDistance_)) {
|
||||
scaleDelta = this.lastDistance_ / distance;
|
||||
}
|
||||
this.lastDistance_ = distance;
|
||||
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
|
||||
// scale anchor point.
|
||||
var viewportPosition = goog.style.getClientPosition(map.getViewport());
|
||||
var centroid = ol.interaction.Touch.centroid(this.targetTouches);
|
||||
centroid.x -= viewportPosition.x;
|
||||
centroid.y -= viewportPosition.y;
|
||||
var anchor = map.getCoordinateFromPixel(centroid);
|
||||
|
||||
// scale, bypass the resolution constraint
|
||||
view.zoom_(map, view.getResolution() * scaleDelta, anchor);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.TouchZoom.prototype.handleTouchEnd =
|
||||
function(mapBrowserEvent) {
|
||||
if (this.targetTouches.length < 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
// take the resolution constraint into account
|
||||
view.zoomToResolution(map, view.getResolution());
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.TouchZoom.prototype.handleTouchStart =
|
||||
function(mapBrowserEvent) {
|
||||
if (this.targetTouches.length >= 2) {
|
||||
var view = mapBrowserEvent.map.getView();
|
||||
this.lastDistance_ = undefined;
|
||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -45,6 +45,7 @@ goog.require('ol.View');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.control.Attribution');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.control.ScaleLine');
|
||||
goog.require('ol.control.Zoom');
|
||||
goog.require('ol.interaction.DblClickZoom');
|
||||
goog.require('ol.interaction.DragPan');
|
||||
@@ -55,7 +56,8 @@ goog.require('ol.interaction.KeyboardPan');
|
||||
goog.require('ol.interaction.KeyboardZoom');
|
||||
goog.require('ol.interaction.MouseWheelZoom');
|
||||
goog.require('ol.interaction.TouchPan');
|
||||
goog.require('ol.interaction.TouchRotateAndZoom');
|
||||
goog.require('ol.interaction.TouchRotate');
|
||||
goog.require('ol.interaction.TouchZoom');
|
||||
goog.require('ol.interaction.condition');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.projection');
|
||||
@@ -925,6 +927,16 @@ ol.Map.createControls_ = function(mapOptions) {
|
||||
controls.push(new ol.control.Attribution({}));
|
||||
}
|
||||
|
||||
var scaleLineControl = goog.isDef(mapOptions.scaleLineControl) ?
|
||||
mapOptions.scaleLineControl : false;
|
||||
if (scaleLineControl) {
|
||||
var scaleLineUnits = goog.isDef(mapOptions.scaleLineUnits) ?
|
||||
mapOptions.scaleLineUnits : undefined;
|
||||
controls.push(new ol.control.ScaleLine({
|
||||
units: scaleLineUnits
|
||||
}));
|
||||
}
|
||||
|
||||
var zoomControl = goog.isDef(mapOptions.zoomControl) ?
|
||||
mapOptions.zoomControl : true;
|
||||
if (zoomControl) {
|
||||
@@ -966,13 +978,20 @@ ol.Map.createInteractions_ = function(mapOptions) {
|
||||
var touchPan = goog.isDef(mapOptions.touchPan) ?
|
||||
mapOptions.touchPan : true;
|
||||
if (touchPan) {
|
||||
interactions.push(new ol.interaction.TouchPan());
|
||||
interactions.push(new ol.interaction.TouchPan(
|
||||
new ol.Kinetic(-0.005, 0.05, 100)));
|
||||
}
|
||||
|
||||
var touchRotateZoom = goog.isDef(mapOptions.touchRotateZoom) ?
|
||||
mapOptions.touchRotateZoom : true;
|
||||
if (touchRotateZoom) {
|
||||
interactions.push(new ol.interaction.TouchRotateAndZoom());
|
||||
var touchRotate = goog.isDef(mapOptions.touchRotate) ?
|
||||
mapOptions.touchRotate : true;
|
||||
if (touchRotate) {
|
||||
interactions.push(new ol.interaction.TouchRotate());
|
||||
}
|
||||
|
||||
var touchZoom = goog.isDef(mapOptions.touchZoom) ?
|
||||
mapOptions.touchZoom : true;
|
||||
if (touchZoom) {
|
||||
interactions.push(new ol.interaction.TouchZoom());
|
||||
}
|
||||
|
||||
var dragPan = goog.isDef(mapOptions.dragPan) ?
|
||||
|
||||
@@ -201,7 +201,7 @@ ol.MapBrowserEventHandler.prototype.click_ = function(browserEvent) {
|
||||
newEvent = new ol.MapBrowserEvent(
|
||||
ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, browserEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
} else if (type == goog.events.EventType.CLICK) {
|
||||
} else {
|
||||
newEvent = new ol.MapBrowserEvent(
|
||||
ol.MapBrowserEvent.EventType.CLICK, this.map_, browserEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
|
||||
@@ -94,17 +94,19 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
|
||||
obj['matrixHeight'] = parseInt(this.getChildValue(node), 10);
|
||||
},
|
||||
'ResourceURL': function(node, obj) {
|
||||
obj['resourceUrl'] = obj['resourceUrl'] || {};
|
||||
var resourceType = node.getAttribute('resourceType');
|
||||
var format = node.getAttribute('format');
|
||||
var template = node.getAttribute('template');
|
||||
if (!obj['resourceUrls']) {
|
||||
obj['resourceUrls'] = [];
|
||||
obj['resourceUrls'] = {};
|
||||
}
|
||||
var resourceUrl = obj['resourceUrl'][resourceType] = {
|
||||
'format': node.getAttribute('format'),
|
||||
'template': node.getAttribute('template'),
|
||||
'resourceType': resourceType
|
||||
};
|
||||
obj['resourceUrls'].push(resourceUrl);
|
||||
if (!obj['resourceUrls'][resourceType]) {
|
||||
obj['resourceUrls'][resourceType] = {};
|
||||
}
|
||||
if (!obj['resourceUrls'][resourceType][format]) {
|
||||
obj['resourceUrls'][resourceType][format] = [];
|
||||
}
|
||||
obj['resourceUrls'][resourceType][format].push(template);
|
||||
},
|
||||
'WSDL': function(node, obj) {
|
||||
obj['wsdl'] = {};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
@exportProperty ol.Projection.prototype.getAxisOrientation
|
||||
@exportProperty ol.Projection.prototype.getCode
|
||||
@exportProperty ol.Projection.prototype.getExtent
|
||||
@exportProperty ol.Projection.prototype.getPointResolution
|
||||
@exportProperty ol.Projection.prototype.getUnits
|
||||
|
||||
@exportSymbol ol.ProjectionUnits
|
||||
|
||||
@@ -8,6 +8,7 @@ goog.require('goog.object');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.TransformFunction');
|
||||
goog.require('ol.sphere.NORMAL');
|
||||
|
||||
|
||||
/**
|
||||
@@ -85,6 +86,14 @@ ol.Projection.prototype.getExtent = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} resolution Resolution.
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @return {number} Point resolution.
|
||||
*/
|
||||
ol.Projection.prototype.getPointResolution = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.ProjectionUnits} Units.
|
||||
*/
|
||||
@@ -121,10 +130,49 @@ ol.Proj4jsProjection_ = function(code, proj4jsProj) {
|
||||
*/
|
||||
this.proj4jsProj_ = proj4jsProj;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {?ol.TransformFunction}
|
||||
*/
|
||||
this.toEPSG4326_ = null;
|
||||
|
||||
};
|
||||
goog.inherits(ol.Proj4jsProjection_, ol.Projection);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.Proj4jsProjection_.prototype.getPointResolution =
|
||||
function(resolution, point) {
|
||||
if (this.getUnits() == ol.ProjectionUnits.DEGREES) {
|
||||
return resolution;
|
||||
} else {
|
||||
// Estimate point resolution by transforming the center pixel to EPSG:4326,
|
||||
// measuring its width and height on the normal sphere, and taking the
|
||||
// average of the width and height.
|
||||
if (goog.isNull(this.toEPSG4326_)) {
|
||||
this.toEPSG4326_ = ol.projection.getTransform(
|
||||
this, ol.projection.getProj4jsProjectionFromCode_('EPSG:4326'));
|
||||
}
|
||||
var vertices = [
|
||||
point.x - resolution / 2, point.y,
|
||||
point.x + resolution / 2, point.y,
|
||||
point.x, point.y - resolution / 2,
|
||||
point.x, point.y + resolution / 2
|
||||
];
|
||||
vertices = this.toEPSG4326_(vertices, vertices, 2);
|
||||
var width = ol.sphere.NORMAL.haversineDistance(
|
||||
new ol.Coordinate(vertices[0], vertices[1]),
|
||||
new ol.Coordinate(vertices[2], vertices[3]));
|
||||
var height = ol.sphere.NORMAL.haversineDistance(
|
||||
new ol.Coordinate(vertices[4], vertices[5]),
|
||||
new ol.Coordinate(vertices[6], vertices[7]));
|
||||
return (width + height) / 2;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {Proj4js.Proj} Proj4js projection.
|
||||
*/
|
||||
@@ -397,14 +445,33 @@ ol.projection.getTransform = function(source, destination) {
|
||||
var destinationProj4jsProj = proj4jsDestination.getProj4jsProj();
|
||||
transform =
|
||||
/**
|
||||
* @param {ol.Coordinate} coordinate Coordinate.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
* @param {Array.<number>} input Input coordinate values.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinates.
|
||||
* @param {number=} opt_dimension Dimension.
|
||||
* @return {Array.<number>} Output coordinate values.
|
||||
*/
|
||||
function(coordinate) {
|
||||
var proj4jsPoint = new Proj4js.Point(coordinate.x, coordinate.y);
|
||||
proj4jsPoint = Proj4js.transform(
|
||||
sourceProj4jsProj, destinationProj4jsProj, proj4jsPoint);
|
||||
return new ol.Coordinate(proj4jsPoint.x, proj4jsPoint.y);
|
||||
function(input, opt_output, opt_dimension) {
|
||||
var length = input.length,
|
||||
dimension = opt_dimension > 1 ? opt_dimension : 2,
|
||||
output = opt_output;
|
||||
if (!goog.isDef(output)) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
output = input.slice();
|
||||
} else {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(output.length % dimension === 0);
|
||||
var proj4jsPoint;
|
||||
for (var i = 0; i < length; i += dimension) {
|
||||
proj4jsPoint = new Proj4js.Point(input[i], input[i + 1]);
|
||||
proj4jsPoint = Proj4js.transform(
|
||||
sourceProj4jsProj, destinationProj4jsProj, proj4jsPoint);
|
||||
output[i] = proj4jsPoint.x;
|
||||
output[i + 1] = proj4jsPoint.y;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
ol.projection.addTransform(source, destination, transform);
|
||||
}
|
||||
@@ -418,7 +485,7 @@ ol.projection.getTransform = function(source, destination) {
|
||||
|
||||
/**
|
||||
* Given the projection codes this method searches for a transformation function
|
||||
* to convert coordinate from the source projection to the destination
|
||||
* to convert a coordinates array from the source projection to the destination
|
||||
* projection.
|
||||
*
|
||||
* @param {string} sourceCode Source code.
|
||||
@@ -433,20 +500,42 @@ ol.projection.getTransformFromCodes = function(sourceCode, destinationCode) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @return {ol.Coordinate} Unaltered point (same reference).
|
||||
* @param {Array.<number>} input Input coordinate array.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
* @param {number=} opt_dimension Dimension.
|
||||
* @return {Array.<number>} Input coordinate array (same array as input).
|
||||
*/
|
||||
ol.projection.identityTransform = function(point) {
|
||||
return point;
|
||||
ol.projection.identityTransform = function(input, opt_output, opt_dimension) {
|
||||
if (goog.isDef(opt_output) && input !== opt_output) {
|
||||
// TODO: consider making this a warning instead
|
||||
goog.asserts.assert(false, 'This should not be used internally.');
|
||||
for (var i = 0, ii = input.length; i < ii; ++i) {
|
||||
opt_output[i] = input[i];
|
||||
}
|
||||
input = opt_output;
|
||||
}
|
||||
return input;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @return {ol.Coordinate} Equal point (different reference).
|
||||
* @param {Array.<number>} input Input coordinate array.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
* @param {number=} opt_dimension Dimension.
|
||||
* @return {Array.<number>} Output coordinate array (new array, same coordinate
|
||||
* values).
|
||||
*/
|
||||
ol.projection.cloneTransform = function(point) {
|
||||
return new ol.Coordinate(point.x, point.y);
|
||||
ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
|
||||
var output;
|
||||
if (goog.isDef(opt_output)) {
|
||||
for (var i = 0, ii = input.length; i < ii; ++i) {
|
||||
opt_output[i] = input[i];
|
||||
}
|
||||
output = opt_output;
|
||||
} else {
|
||||
output = input.slice();
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
@@ -460,7 +549,9 @@ ol.projection.cloneTransform = function(point) {
|
||||
*/
|
||||
ol.projection.transform = function(point, source, destination) {
|
||||
var transformFn = ol.projection.getTransform(source, destination);
|
||||
return transformFn(point);
|
||||
var vertex = [point.x, point.y];
|
||||
vertex = transformFn(vertex, vertex, 2);
|
||||
return new ol.Coordinate(vertex[0], vertex[1]);
|
||||
};
|
||||
|
||||
|
||||
@@ -474,5 +565,7 @@ ol.projection.transformWithCodes =
|
||||
function(point, sourceCode, destinationCode) {
|
||||
var transformFn = ol.projection.getTransformFromCodes(
|
||||
sourceCode, destinationCode);
|
||||
return transformFn(point);
|
||||
var vertex = [point.x, point.y];
|
||||
vertex = transformFn(vertex, vertex, 2);
|
||||
return new ol.Coordinate(vertex[0], vertex[1]);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
goog.provide('ol.projection.EPSG3857');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.ProjectionUnits');
|
||||
goog.require('ol.math');
|
||||
goog.require('ol.projection');
|
||||
|
||||
|
||||
@@ -73,26 +73,68 @@ ol.projection.EPSG3857.PROJECTIONS = goog.array.map(
|
||||
/**
|
||||
* Transformation from EPSG:4326 to EPSG:3857.
|
||||
*
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @return {ol.Coordinate} Point.
|
||||
* @param {Array.<number>} input Input array of coordinate values.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
* @param {number=} opt_dimension Dimension (default is 2).
|
||||
* @return {Array.<number>} Output array of coordinate values.
|
||||
*/
|
||||
ol.projection.EPSG3857.fromEPSG4326 = function(point) {
|
||||
var x = ol.projection.EPSG3857.RADIUS * Math.PI * point.x / 180;
|
||||
var y = ol.projection.EPSG3857.RADIUS *
|
||||
Math.log(Math.tan(Math.PI * (point.y + 90) / 360));
|
||||
return new ol.Coordinate(x, y);
|
||||
ol.projection.EPSG3857.fromEPSG4326 = function(
|
||||
input, opt_output, opt_dimension) {
|
||||
var length = input.length,
|
||||
dimension = opt_dimension > 1 ? opt_dimension : 2,
|
||||
output = opt_output;
|
||||
if (!goog.isDef(output)) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
output = input.slice();
|
||||
} else {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(output.length % dimension === 0);
|
||||
for (var i = 0; i < length; i += dimension) {
|
||||
output[i] = ol.projection.EPSG3857.RADIUS * Math.PI * input[i] / 180;
|
||||
output[i + 1] = ol.projection.EPSG3857.RADIUS *
|
||||
Math.log(Math.tan(Math.PI * (input[i + 1] + 90) / 360));
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Transformation from EPSG:3857 to EPSG:4326.
|
||||
*
|
||||
* @param {ol.Coordinate} point Point.
|
||||
* @return {ol.Coordinate} Point.
|
||||
* @param {Array.<number>} input Input array of coordinate values.
|
||||
* @param {Array.<number>=} opt_output Output array of coordinate values.
|
||||
* @param {number=} opt_dimension Dimension (default is 2).
|
||||
* @return {Array.<number>} Output array of coordinate values.
|
||||
*/
|
||||
ol.projection.EPSG3857.toEPSG4326 = function(point) {
|
||||
var x = 180 * point.x / (ol.projection.EPSG3857.RADIUS * Math.PI);
|
||||
var y = 360 * Math.atan(
|
||||
Math.exp(point.y / ol.projection.EPSG3857.RADIUS)) / Math.PI - 90;
|
||||
return new ol.Coordinate(x, y);
|
||||
ol.projection.EPSG3857.toEPSG4326 = function(input, opt_output, opt_dimension) {
|
||||
var length = input.length,
|
||||
dimension = opt_dimension > 1 ? opt_dimension : 2,
|
||||
output = opt_output;
|
||||
if (!goog.isDef(output)) {
|
||||
if (dimension > 2) {
|
||||
// preserve values beyond second dimension
|
||||
output = input.slice();
|
||||
} else {
|
||||
output = new Array(length);
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(output.length % dimension === 0);
|
||||
for (var i = 0; i < length; i += dimension) {
|
||||
output[i] = 180 * input[i] / (ol.projection.EPSG3857.RADIUS * Math.PI);
|
||||
output[i + 1] = 360 * Math.atan(
|
||||
Math.exp(input[i + 1] / ol.projection.EPSG3857.RADIUS)) / Math.PI - 90;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.projection.EPSG3857.prototype.getPointResolution =
|
||||
function(resolution, point) {
|
||||
return resolution / ol.math.cosh(point.y / ol.projection.EPSG3857.RADIUS);
|
||||
};
|
||||
|
||||
@@ -41,3 +41,12 @@ ol.projection.EPSG4326.PROJECTIONS = [
|
||||
new ol.projection.EPSG4326('urn:ogc:def:crs:EPSG:6.6:4326', 'neu'),
|
||||
new ol.projection.EPSG4326('urn:ogc:def:crs:OGC:1.3:CRS84')
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.projection.EPSG4326.prototype.getPointResolution =
|
||||
function(resolution, point) {
|
||||
return resolution;
|
||||
};
|
||||
|
||||
@@ -78,7 +78,7 @@ ol.renderer.canvas.ImageLayer.prototype.renderFrame =
|
||||
|
||||
var hints = frameState.viewHints;
|
||||
|
||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.PANNING]) {
|
||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) {
|
||||
image = imageSource.getImage(frameState.extent, viewResolution);
|
||||
if (!goog.isNull(image)) {
|
||||
var imageState = image.getState();
|
||||
|
||||
@@ -91,8 +91,8 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
var tileSource = tileLayer.getTileSource();
|
||||
var tileSourceKey = goog.getUid(tileSource).toString();
|
||||
var tileGrid = tileSource.getTileGrid();
|
||||
var tileSize = tileGrid.getTileSize();
|
||||
var z = tileGrid.getZForResolution(view2DState.resolution);
|
||||
var tileSize = tileGrid.getTileSize(z);
|
||||
var tileResolution = tileGrid.getResolution(z);
|
||||
var tileRange = tileGrid.getTileRangeForExtentAndResolution(
|
||||
frameState.extent, tileResolution);
|
||||
@@ -174,6 +174,7 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
|
||||
var currentZ, i, scale, tileCoordKey, tileExtent, tilesToDraw;
|
||||
for (i = 0; i < zs.length; ++i) {
|
||||
currentZ = zs[i];
|
||||
tileSize = tileGrid.getTileSize(currentZ);
|
||||
tilesToDraw = tilesToDrawByZ[currentZ];
|
||||
if (currentZ == z) {
|
||||
for (tileCoordKey in tilesToDraw) {
|
||||
|
||||
@@ -66,7 +66,7 @@ ol.renderer.dom.ImageLayer.prototype.renderFrame =
|
||||
|
||||
var hints = frameState.viewHints;
|
||||
|
||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.PANNING]) {
|
||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) {
|
||||
var image_ = imageSource.getImage(frameState.extent, viewResolution);
|
||||
if (!goog.isNull(image_)) {
|
||||
var imageState = image_.getState();
|
||||
|
||||
@@ -138,7 +138,6 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
/** @type {Object.<number, boolean>} */
|
||||
var newTileLayerZKeys = {};
|
||||
|
||||
var tileSize = tileGrid.getTileSize();
|
||||
var iz, tileCoordKey, tileCoordOrigin, tileLayerZ, tileLayerZKey, tilesToDraw;
|
||||
for (iz = 0; iz < zs.length; ++iz) {
|
||||
tileLayerZKey = zs[iz];
|
||||
@@ -200,7 +199,7 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
|
||||
}
|
||||
} else {
|
||||
if (!frameState.viewHints[ol.ViewHint.ANIMATING] &&
|
||||
!frameState.viewHints[ol.ViewHint.PANNING]) {
|
||||
!frameState.viewHints[ol.ViewHint.INTERACTING]) {
|
||||
tileLayerZ.removeTilesOutsideExtent(frameState.extent);
|
||||
}
|
||||
}
|
||||
@@ -293,7 +292,7 @@ ol.renderer.dom.TileLayerZ_.prototype.addTile = function(tile) {
|
||||
if (tileCoordKey in this.tiles_) {
|
||||
return;
|
||||
}
|
||||
var tileSize = this.tileGrid_.getTileSize();
|
||||
var tileSize = this.tileGrid_.getTileSize(tileCoord.z);
|
||||
var image = tile.getImage(this);
|
||||
var style = image.style;
|
||||
style.position = 'absolute';
|
||||
|
||||
@@ -119,7 +119,9 @@ ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
|
||||
* @protected
|
||||
* @return {ol.renderer.Layer} layerRenderer Layer renderer.
|
||||
*/
|
||||
ol.renderer.Map.prototype.createLayerRenderer = goog.functions.NULL;
|
||||
ol.renderer.Map.prototype.createLayerRenderer = function(layer) {
|
||||
return new ol.renderer.Layer(this, layer);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) {
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.vertexCoordMatrix_ = goog.vec.Mat4.createNumber();
|
||||
this.projectionMatrix_ = goog.vec.Mat4.createNumber();
|
||||
|
||||
};
|
||||
goog.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer);
|
||||
@@ -118,8 +118,8 @@ ol.renderer.webgl.ImageLayer.prototype.getTexture = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.ImageLayer.prototype.getVertexCoordMatrix = function() {
|
||||
return this.vertexCoordMatrix_;
|
||||
ol.renderer.webgl.ImageLayer.prototype.getProjectionMatrix = function() {
|
||||
return this.projectionMatrix_;
|
||||
};
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ ol.renderer.webgl.ImageLayer.prototype.renderFrame =
|
||||
|
||||
var hints = frameState.viewHints;
|
||||
|
||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.PANNING]) {
|
||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) {
|
||||
var image_ = imageSource.getImage(frameState.extent, viewResolution);
|
||||
if (!goog.isNull(image_)) {
|
||||
var imageState = image_.getState();
|
||||
@@ -187,7 +187,7 @@ ol.renderer.webgl.ImageLayer.prototype.renderFrame =
|
||||
|
||||
var canvas = this.getMapRenderer().getCanvas();
|
||||
|
||||
this.updateVertexCoordMatrix_(canvas.width, canvas.height,
|
||||
this.updateProjectionMatrix_(canvas.width, canvas.height,
|
||||
viewCenter, viewResolution, viewRotation, image.getExtent());
|
||||
|
||||
// Translate and scale to flip the Y coord.
|
||||
@@ -213,24 +213,24 @@ ol.renderer.webgl.ImageLayer.prototype.renderFrame =
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @param {ol.Extent} imageExtent Image extent.
|
||||
*/
|
||||
ol.renderer.webgl.ImageLayer.prototype.updateVertexCoordMatrix_ =
|
||||
ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
|
||||
function(canvasWidth, canvasHeight, viewCenter,
|
||||
viewResolution, viewRotation, imageExtent) {
|
||||
|
||||
var canvasExtentWidth = canvasWidth * viewResolution;
|
||||
var canvasExtentHeight = canvasHeight * viewResolution;
|
||||
|
||||
var vertexCoordMatrix = this.vertexCoordMatrix_;
|
||||
goog.vec.Mat4.makeIdentity(vertexCoordMatrix);
|
||||
goog.vec.Mat4.scale(vertexCoordMatrix,
|
||||
var projectionMatrix = this.projectionMatrix_;
|
||||
goog.vec.Mat4.makeIdentity(projectionMatrix);
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
2 / canvasExtentWidth, 2 / canvasExtentHeight, 1);
|
||||
goog.vec.Mat4.rotateZ(vertexCoordMatrix, -viewRotation);
|
||||
goog.vec.Mat4.translate(vertexCoordMatrix,
|
||||
goog.vec.Mat4.rotateZ(projectionMatrix, -viewRotation);
|
||||
goog.vec.Mat4.translate(projectionMatrix,
|
||||
imageExtent.minX - viewCenter.x,
|
||||
imageExtent.minY - viewCenter.y,
|
||||
0);
|
||||
goog.vec.Mat4.scale(vertexCoordMatrix,
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
imageExtent.getWidth() / 2, imageExtent.getHeight() / 2, 1);
|
||||
goog.vec.Mat4.translate(vertexCoordMatrix, 1, 1, 0);
|
||||
goog.vec.Mat4.translate(projectionMatrix, 1, 1, 0);
|
||||
|
||||
};
|
||||
|
||||
@@ -100,7 +100,7 @@ ol.renderer.webgl.Layer.prototype.getTexture = goog.abstractMethod;
|
||||
/**
|
||||
* @return {!goog.vec.Mat4.Number} Matrix.
|
||||
*/
|
||||
ol.renderer.webgl.Layer.prototype.getVertexCoordMatrix = goog.abstractMethod;
|
||||
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,17 +48,17 @@ ol.renderer.webgl.map.shader.Fragment = function() {
|
||||
goog.base(this, [
|
||||
'precision mediump float;',
|
||||
'',
|
||||
'uniform mat4 uColorMatrix;',
|
||||
'uniform float uOpacity;',
|
||||
'uniform sampler2D uTexture;',
|
||||
'uniform mat4 u_colorMatrix;',
|
||||
'uniform float u_opacity;',
|
||||
'uniform sampler2D u_texture;',
|
||||
'',
|
||||
'varying vec2 vTexCoord;',
|
||||
'varying vec2 v_texCoord;',
|
||||
'',
|
||||
'void main(void) {',
|
||||
'',
|
||||
' vec4 texColor = texture2D(uTexture, vTexCoord);',
|
||||
' vec4 color = uColorMatrix * vec4(texColor.rgb, 1.);',
|
||||
' color.a = texColor.a * uOpacity;',
|
||||
' vec4 texColor = texture2D(u_texture, v_texCoord);',
|
||||
' vec4 color = u_colorMatrix * vec4(texColor.rgb, 1.);',
|
||||
' color.a = texColor.a * u_opacity;',
|
||||
'',
|
||||
' gl_FragColor = color;',
|
||||
'',
|
||||
@@ -77,17 +77,17 @@ goog.addSingletonGetter(ol.renderer.webgl.map.shader.Fragment);
|
||||
*/
|
||||
ol.renderer.webgl.map.shader.Vertex = function() {
|
||||
goog.base(this, [
|
||||
'attribute vec2 aPosition;',
|
||||
'attribute vec2 aTexCoord;',
|
||||
'attribute vec2 a_position;',
|
||||
'attribute vec2 a_texCoord;',
|
||||
'',
|
||||
'uniform mat4 uTexCoordMatrix;',
|
||||
'uniform mat4 uVertexCoordMatrix;',
|
||||
'uniform mat4 u_texCoordMatrix;',
|
||||
'uniform mat4 u_projectionMatrix;',
|
||||
'',
|
||||
'varying vec2 vTexCoord;',
|
||||
'varying vec2 v_texCoord;',
|
||||
'',
|
||||
'void main(void) {',
|
||||
' gl_Position = uVertexCoordMatrix * vec4(aPosition, 0., 1.);',
|
||||
' vTexCoord = (uTexCoordMatrix * vec4(aTexCoord, 0., 1.)).st;',
|
||||
' gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);',
|
||||
' v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;',
|
||||
'}'
|
||||
].join('\n'));
|
||||
};
|
||||
@@ -157,13 +157,13 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {{aPosition: number,
|
||||
* aTexCoord: number,
|
||||
* uColorMatrix: WebGLUniformLocation,
|
||||
* uOpacity: WebGLUniformLocation,
|
||||
* uTexture: WebGLUniformLocation,
|
||||
* uTexCoordMatrix: WebGLUniformLocation,
|
||||
* uVertexCoordMatrix: WebGLUniformLocation}|null}
|
||||
* @type {{a_position: number,
|
||||
* a_texCoord: number,
|
||||
* u_colorMatrix: WebGLUniformLocation,
|
||||
* u_opacity: WebGLUniformLocation,
|
||||
* u_texture: WebGLUniformLocation,
|
||||
* u_texCoordMatrix: WebGLUniformLocation,
|
||||
* u_projectionMatrix: WebGLUniformLocation}|null}
|
||||
*/
|
||||
this.locations_ = null;
|
||||
|
||||
@@ -522,13 +522,13 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
||||
gl.useProgram(program);
|
||||
if (goog.isNull(this.locations_)) {
|
||||
this.locations_ = {
|
||||
aPosition: gl.getAttribLocation(program, 'aPosition'),
|
||||
aTexCoord: gl.getAttribLocation(program, 'aTexCoord'),
|
||||
uColorMatrix: gl.getUniformLocation(program, 'uColorMatrix'),
|
||||
uTexCoordMatrix: gl.getUniformLocation(program, 'uTexCoordMatrix'),
|
||||
uVertexCoordMatrix: gl.getUniformLocation(program, 'uVertexCoordMatrix'),
|
||||
uOpacity: gl.getUniformLocation(program, 'uOpacity'),
|
||||
uTexture: gl.getUniformLocation(program, 'uTexture')
|
||||
a_position: gl.getAttribLocation(program, 'a_position'),
|
||||
a_texCoord: gl.getAttribLocation(program, 'a_texCoord'),
|
||||
u_colorMatrix: gl.getUniformLocation(program, 'u_colorMatrix'),
|
||||
u_texCoordMatrix: gl.getUniformLocation(program, 'u_texCoordMatrix'),
|
||||
u_projectionMatrix: gl.getUniformLocation(program, 'u_projectionMatrix'),
|
||||
u_opacity: gl.getUniformLocation(program, 'u_opacity'),
|
||||
u_texture: gl.getUniformLocation(program, 'u_texture')
|
||||
};
|
||||
}
|
||||
|
||||
@@ -546,13 +546,13 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
||||
gl.bindBuffer(goog.webgl.ARRAY_BUFFER, this.arrayBuffer_);
|
||||
}
|
||||
|
||||
gl.enableVertexAttribArray(this.locations_.aPosition);
|
||||
gl.enableVertexAttribArray(this.locations_.a_position);
|
||||
gl.vertexAttribPointer(
|
||||
this.locations_.aPosition, 2, goog.webgl.FLOAT, false, 16, 0);
|
||||
gl.enableVertexAttribArray(this.locations_.aTexCoord);
|
||||
this.locations_.a_position, 2, goog.webgl.FLOAT, false, 16, 0);
|
||||
gl.enableVertexAttribArray(this.locations_.a_texCoord);
|
||||
gl.vertexAttribPointer(
|
||||
this.locations_.aTexCoord, 2, goog.webgl.FLOAT, false, 16, 8);
|
||||
gl.uniform1i(this.locations_.uTexture, 0);
|
||||
this.locations_.a_texCoord, 2, goog.webgl.FLOAT, false, 16, 8);
|
||||
gl.uniform1i(this.locations_.u_texture, 0);
|
||||
|
||||
goog.array.forEach(frameState.layersArray, function(layer) {
|
||||
var layerState = frameState.layerStates[goog.getUid(layer)];
|
||||
@@ -561,14 +561,14 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
||||
}
|
||||
var layerRenderer = this.getLayerRenderer(layer);
|
||||
gl.uniformMatrix4fv(
|
||||
this.locations_.uTexCoordMatrix, false,
|
||||
this.locations_.u_texCoordMatrix, false,
|
||||
layerRenderer.getTexCoordMatrix());
|
||||
gl.uniformMatrix4fv(
|
||||
this.locations_.uVertexCoordMatrix, false,
|
||||
layerRenderer.getVertexCoordMatrix());
|
||||
this.locations_.u_projectionMatrix, false,
|
||||
layerRenderer.getProjectionMatrix());
|
||||
gl.uniformMatrix4fv(
|
||||
this.locations_.uColorMatrix, false, layerRenderer.getColorMatrix());
|
||||
gl.uniform1f(this.locations_.uOpacity, layer.getOpacity());
|
||||
this.locations_.u_colorMatrix, false, layerRenderer.getColorMatrix());
|
||||
gl.uniform1f(this.locations_.u_opacity, layer.getOpacity());
|
||||
gl.bindTexture(goog.webgl.TEXTURE_2D, layerRenderer.getTexture());
|
||||
gl.drawArrays(goog.webgl.TRIANGLE_STRIP, 0, 4);
|
||||
}, this);
|
||||
|
||||
@@ -145,7 +145,7 @@ ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) {
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.vertexCoordMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
this.projectionMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -246,8 +246,8 @@ ol.renderer.webgl.TileLayer.prototype.getTexture = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.TileLayer.prototype.getVertexCoordMatrix = function() {
|
||||
return this.vertexCoordMatrix_;
|
||||
ol.renderer.webgl.TileLayer.prototype.getProjectionMatrix = function() {
|
||||
return this.projectionMatrix_;
|
||||
};
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
} else {
|
||||
|
||||
var tileRangeSize = tileRange.getSize();
|
||||
var tileSize = tileGrid.getTileSize();
|
||||
var tileSize = tileGrid.getTileSize(z);
|
||||
|
||||
var maxDimension = Math.max(
|
||||
tileRangeSize.width * tileSize.width,
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
@exportSymbol ol.source.BingMaps
|
||||
@exportSymbol ol.BingMapsStyle
|
||||
@exportProperty ol.BingMapsStyle.AERIAL
|
||||
@exportProperty ol.BingMapsStyle.AERIAL_WITH_LABELS
|
||||
@exportProperty ol.BingMapsStyle.ROAD
|
||||
@exportProperty ol.BingMapsStyle.ORDNANCE_SURVEY
|
||||
@exportProperty ol.BingMapsStyle.COLLINS_BART
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
goog.provide('ol.BingMapsStyle');
|
||||
goog.provide('ol.source.BingMaps');
|
||||
|
||||
goog.require('goog.Uri');
|
||||
@@ -15,18 +14,6 @@ goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.tilegrid.XYZ');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.BingMapsStyle = {
|
||||
AERIAL: 'Aerial',
|
||||
AERIAL_WITH_LABELS: 'AerialWithLabels',
|
||||
ROAD: 'Road',
|
||||
ORDNANCE_SURVEY: 'OrdnanceSurvey',
|
||||
COLLINS_BART: 'CollinsBart'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
||||
@@ -33,7 +33,7 @@ ol.DebugTile_ = function(tileCoord, tileGrid) {
|
||||
* @private
|
||||
* @type {ol.Size}
|
||||
*/
|
||||
this.tileSize_ = tileGrid.getTileSize();
|
||||
this.tileSize_ = tileGrid.getTileSize(tileCoord.z);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -46,9 +46,6 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
||||
'FORMAT': 'image/png',
|
||||
'TRANSPARENT': true
|
||||
};
|
||||
var tileSize = tileGrid.getTileSize();
|
||||
baseParams['WIDTH'] = tileSize.width;
|
||||
baseParams['HEIGHT'] = tileSize.height;
|
||||
baseParams[version >= '1.3' ? 'CRS' : 'SRS'] = projection.getCode();
|
||||
goog.object.extend(baseParams, tiledWMSOptions.params);
|
||||
|
||||
|
||||
10
src/ol/sphere/normal.js
Normal file
10
src/ol/sphere/normal.js
Normal file
@@ -0,0 +1,10 @@
|
||||
goog.provide('ol.sphere.NORMAL');
|
||||
|
||||
goog.require('ol.Sphere');
|
||||
|
||||
|
||||
/**
|
||||
* The normal sphere.
|
||||
* @const {ol.Sphere}
|
||||
*/
|
||||
ol.sphere.NORMAL = new ol.Sphere(6370997);
|
||||
10
src/ol/sphere/wgs84.js
Normal file
10
src/ol/sphere/wgs84.js
Normal file
@@ -0,0 +1,10 @@
|
||||
goog.provide('ol.sphere.WGS84');
|
||||
|
||||
goog.require('ol.Sphere');
|
||||
|
||||
|
||||
/**
|
||||
* A sphere with radius equal to the semi-major axis of the WGS84 ellipsoid.
|
||||
* @const {ol.Sphere}
|
||||
*/
|
||||
ol.sphere.WGS84 = new ol.Sphere(6378137);
|
||||
@@ -58,6 +58,19 @@ ol.tilegrid.TileGrid = function(tileGridOptions) {
|
||||
this.origins_ = tileGridOptions.origins;
|
||||
goog.asserts.assert(this.origins_.length == this.resolutions_.length);
|
||||
}
|
||||
goog.asserts.assert(
|
||||
(goog.isNull(this.origin_) && !goog.isNull(this.origins_)) ||
|
||||
(!goog.isNull(this.origin_) && goog.isNull(this.origins_)));
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<ol.Size>}
|
||||
*/
|
||||
this.tileSizes_ = null;
|
||||
if (goog.isDef(tileGridOptions.tileSizes)) {
|
||||
this.tileSizes_ = tileGridOptions.tileSizes;
|
||||
goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -65,7 +78,11 @@ ol.tilegrid.TileGrid = function(tileGridOptions) {
|
||||
*/
|
||||
this.tileSize_ = goog.isDef(tileGridOptions.tileSize) ?
|
||||
tileGridOptions.tileSize :
|
||||
new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE);
|
||||
goog.isNull(this.tileSizes_) ?
|
||||
new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE) : null;
|
||||
goog.asserts.assert(
|
||||
(goog.isNull(this.tileSize_) && !goog.isNull(this.tileSizes_)) ||
|
||||
(!goog.isNull(this.tileSize_) && goog.isNull(this.tileSizes_)));
|
||||
|
||||
};
|
||||
|
||||
@@ -114,7 +131,7 @@ ol.tilegrid.TileGrid.prototype.getOrigin = function(z) {
|
||||
ol.tilegrid.TileGrid.prototype.getPixelBoundsForTileCoordAndResolution =
|
||||
function(tileCoord, resolution) {
|
||||
var scale = resolution / this.getResolution(tileCoord.z);
|
||||
var tileSize = this.getTileSize();
|
||||
var tileSize = this.getTileSize(tileCoord.z);
|
||||
tileSize = new ol.Size(tileSize.width / scale,
|
||||
tileSize.height / scale);
|
||||
var minX, maxX, minY, maxY;
|
||||
@@ -152,7 +169,7 @@ ol.tilegrid.TileGrid.prototype.getResolutions = function() {
|
||||
ol.tilegrid.TileGrid.prototype.getTileRangeExtent = function(z, tileRange) {
|
||||
var origin = this.getOrigin(z);
|
||||
var resolution = this.getResolution(z);
|
||||
var tileSize = this.tileSize_;
|
||||
var tileSize = this.getTileSize(z);
|
||||
var minX = origin.x + tileRange.minX * tileSize.width * resolution;
|
||||
var minY = origin.y + tileRange.minY * tileSize.height * resolution;
|
||||
var maxX = origin.x + (tileRange.maxX + 1) * tileSize.width * resolution;
|
||||
@@ -194,7 +211,7 @@ ol.tilegrid.TileGrid.prototype.getTileRangeForExtentAndZ = function(extent, z) {
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordCenter = function(tileCoord) {
|
||||
var origin = this.getOrigin(tileCoord.z);
|
||||
var resolution = this.getResolution(tileCoord.z);
|
||||
var tileSize = this.tileSize_;
|
||||
var tileSize = this.getTileSize(tileCoord.z);
|
||||
var x = origin.x + (tileCoord.x + 0.5) * tileSize.width * resolution;
|
||||
var y = origin.y + (tileCoord.y + 0.5) * tileSize.height * resolution;
|
||||
return new ol.Coordinate(x, y);
|
||||
@@ -208,7 +225,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordCenter = function(tileCoord) {
|
||||
ol.tilegrid.TileGrid.prototype.getTileCoordExtent = function(tileCoord) {
|
||||
var origin = this.getOrigin(tileCoord.z);
|
||||
var resolution = this.getResolution(tileCoord.z);
|
||||
var tileSize = this.tileSize_;
|
||||
var tileSize = this.getTileSize(tileCoord.z);
|
||||
var minX = origin.x + tileCoord.x * tileSize.width * resolution;
|
||||
var minY = origin.y + tileCoord.y * tileSize.height * resolution;
|
||||
var maxX = minX + tileSize.width * resolution;
|
||||
@@ -246,7 +263,7 @@ ol.tilegrid.TileGrid.prototype.getTileCoordForCoordAndResolution_ = function(
|
||||
var z = this.getZForResolution(resolution);
|
||||
var scale = resolution / this.getResolution(z);
|
||||
var origin = this.getOrigin(z);
|
||||
var tileSize = this.getTileSize();
|
||||
var tileSize = this.getTileSize(z);
|
||||
|
||||
var x = scale * (coordinate.x - origin.x) / (resolution * tileSize.width);
|
||||
var y = scale * (coordinate.y - origin.y) / (resolution * tileSize.height);
|
||||
@@ -286,10 +303,17 @@ ol.tilegrid.TileGrid.prototype.getTileCoordResolution = function(tileCoord) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} z Z.
|
||||
* @return {ol.Size} Tile size.
|
||||
*/
|
||||
ol.tilegrid.TileGrid.prototype.getTileSize = function() {
|
||||
return this.tileSize_;
|
||||
ol.tilegrid.TileGrid.prototype.getTileSize = function(z) {
|
||||
if (!goog.isNull(this.tileSize_)) {
|
||||
return this.tileSize_;
|
||||
} else {
|
||||
goog.asserts.assert(!goog.isNull(this.tileSizes_));
|
||||
goog.asserts.assert(0 <= z && z < this.tileSizes_.length);
|
||||
return this.tileSizes_[z];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -86,7 +86,11 @@ ol.TileUrlFunction.createBboxParam =
|
||||
var bboxValues = axisOrientation.substr(0, 2) == 'ne' ?
|
||||
[tileExtent.minY, tileExtent.minX, tileExtent.maxY, tileExtent.maxX] :
|
||||
[tileExtent.minX, tileExtent.minY, tileExtent.maxX, tileExtent.maxY];
|
||||
return goog.uri.utils.appendParam(baseUrl, 'BBOX', bboxValues.join(','));
|
||||
var tileSize = tileGrid.getTileSize(tileCoord.z);
|
||||
return goog.uri.utils.appendParams(baseUrl,
|
||||
'BBOX', bboxValues.join(','),
|
||||
'HEIGHT', tileSize.height,
|
||||
'WIDTH', tileSize.width);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
goog.provide('ol.TransformFunction');
|
||||
|
||||
goog.require('ol.Coordinate');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function(ol.Coordinate): ol.Coordinate}
|
||||
* A transform function accepts an array of input coordinate values, an optional
|
||||
* output array, and an optional dimension (default should be 2). The function
|
||||
* transforms the input coordinate values, populates the output array, and
|
||||
* returns the output array.
|
||||
*
|
||||
* @typedef {function(Array.<number>, Array.<number>=, number=): Array.<number>}
|
||||
*/
|
||||
ol.TransformFunction;
|
||||
|
||||
@@ -11,7 +11,7 @@ goog.require('ol.Object');
|
||||
*/
|
||||
ol.ViewHint = {
|
||||
ANIMATING: 0,
|
||||
PANNING: 1
|
||||
INTERACTING: 1
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user