Merge remote-tracking branch 'upstream/master' into webgl-point-merge

This commit is contained in:
Éric Lemoine
2014-11-10 15:40:03 +01:00
24 changed files with 187 additions and 227 deletions

View File

@@ -12,7 +12,6 @@ goog.require('goog.style');
goog.require('ol.Attribution');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.pointer.PointerEventHandler');
@@ -97,10 +96,6 @@ ol.control.Attribution = function(opt_options) {
'title': tipLabel
}, this.labelSpan_);
var buttonHandler = new ol.pointer.PointerEventHandler(button);
this.registerDisposable(buttonHandler);
goog.events.listen(buttonHandler, ol.pointer.EventType.POINTERUP,
this.handlePointerUp_, false, this);
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
@@ -330,19 +325,7 @@ ol.control.Attribution.prototype.insertLogos_ = function(frameState) {
* @private
*/
ol.control.Attribution.prototype.handleClick_ = function(event) {
if (event.screenX !== 0 && event.screenY !== 0) {
return;
}
this.handleToggle_();
};
/**
* @param {ol.pointer.PointerEvent} pointerEvent The event to handle
* @private
*/
ol.control.Attribution.prototype.handlePointerUp_ = function(pointerEvent) {
pointerEvent.browserEvent.preventDefault();
event.preventDefault();
this.handleToggle_();
};

View File

@@ -10,7 +10,6 @@ goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.pointer.PointerEventHandler');
@@ -45,10 +44,7 @@ ol.control.FullScreen = function(opt_options) {
'type': 'button',
'title': tipLabel
});
var buttonHandler = new ol.pointer.PointerEventHandler(button);
this.registerDisposable(buttonHandler);
goog.events.listen(buttonHandler,
ol.pointer.EventType.POINTERUP, this.handlePointerUp_, false, this);
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
@@ -88,19 +84,7 @@ goog.inherits(ol.control.FullScreen, ol.control.Control);
* @private
*/
ol.control.FullScreen.prototype.handleClick_ = function(event) {
if (event.screenX !== 0 && event.screenY !== 0) {
return;
}
this.handleFullScreen_();
};
/**
* @param {ol.pointer.PointerEvent} pointerEvent The event to handle
* @private
*/
ol.control.FullScreen.prototype.handlePointerUp_ = function(pointerEvent) {
pointerEvent.browserEvent.preventDefault();
event.preventDefault();
this.handleFullScreen_();
};

View File

@@ -19,7 +19,6 @@ goog.require('ol.control.Control');
goog.require('ol.coordinate');
goog.require('ol.css');
goog.require('ol.extent');
goog.require('ol.pointer.PointerEventHandler');
@@ -84,10 +83,6 @@ ol.control.OverviewMap = function(opt_options) {
'title': tipLabel
}, this.labelSpan_);
var buttonHandler = new ol.pointer.PointerEventHandler(button);
this.registerDisposable(buttonHandler);
goog.events.listen(buttonHandler, ol.pointer.EventType.POINTERUP,
this.handlePointerUp_, false, this);
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
@@ -419,19 +414,7 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function(
* @private
*/
ol.control.OverviewMap.prototype.handleClick_ = function(event) {
if (event.screenX !== 0 && event.screenY !== 0) {
return;
}
this.handleToggle_();
};
/**
* @param {ol.pointer.PointerEvent} pointerEvent The event to handle
* @private
*/
ol.control.OverviewMap.prototype.handlePointerUp_ = function(pointerEvent) {
pointerEvent.browserEvent.preventDefault();
event.preventDefault();
this.handleToggle_();
};

View File

@@ -11,7 +11,6 @@ goog.require('ol.animation');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.easing');
goog.require('ol.pointer.PointerEventHandler');
@@ -49,10 +48,6 @@ ol.control.Rotate = function(opt_options) {
'title': tipLabel
}, this.label_);
var handler = new ol.pointer.PointerEventHandler(button);
this.registerDisposable(handler);
goog.events.listen(handler, ol.pointer.EventType.POINTERUP,
ol.control.Rotate.prototype.handlePointerUp_, false, this);
goog.events.listen(button, goog.events.EventType.CLICK,
ol.control.Rotate.prototype.handleClick_, false, this);
@@ -103,19 +98,7 @@ goog.inherits(ol.control.Rotate, ol.control.Control);
* @private
*/
ol.control.Rotate.prototype.handleClick_ = function(event) {
if (event.screenX !== 0 && event.screenY !== 0) {
return;
}
this.resetNorth_();
};
/**
* @param {ol.pointer.PointerEvent} pointerEvent The event to handle
* @private
*/
ol.control.Rotate.prototype.handlePointerUp_ = function(pointerEvent) {
pointerEvent.browserEvent.preventDefault();
event.preventDefault();
this.resetNorth_();
};

View File

@@ -8,7 +8,6 @@ goog.require('ol.animation');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.easing');
goog.require('ol.pointer.PointerEventHandler');
@@ -47,11 +46,6 @@ ol.control.Zoom = function(opt_options) {
'title': zoomInTipLabel
}, zoomInLabel);
var inElementHandler = new ol.pointer.PointerEventHandler(inElement);
this.registerDisposable(inElementHandler);
goog.events.listen(inElementHandler,
ol.pointer.EventType.POINTERUP, goog.partial(
ol.control.Zoom.prototype.handlePointerUp_, delta), false, this);
goog.events.listen(inElement,
goog.events.EventType.CLICK, goog.partial(
ol.control.Zoom.prototype.handleClick_, delta), false, this);
@@ -69,11 +63,6 @@ ol.control.Zoom = function(opt_options) {
'title': zoomOutTipLabel
}, zoomOutLabel);
var outElementHandler = new ol.pointer.PointerEventHandler(outElement);
this.registerDisposable(outElementHandler);
goog.events.listen(outElementHandler,
ol.pointer.EventType.POINTERUP, goog.partial(
ol.control.Zoom.prototype.handlePointerUp_, -delta), false, this);
goog.events.listen(outElement,
goog.events.EventType.CLICK, goog.partial(
ol.control.Zoom.prototype.handleClick_, -delta), false, this);
@@ -111,20 +100,7 @@ goog.inherits(ol.control.Zoom, ol.control.Control);
* @private
*/
ol.control.Zoom.prototype.handleClick_ = function(delta, event) {
if (event.screenX !== 0 && event.screenY !== 0) {
return;
}
this.zoomByDelta_(delta);
};
/**
* @param {number} delta Zoom delta.
* @param {ol.pointer.PointerEvent} pointerEvent The event to handle
* @private
*/
ol.control.Zoom.prototype.handlePointerUp_ = function(delta, pointerEvent) {
pointerEvent.browserEvent.preventDefault();
event.preventDefault();
this.zoomByDelta_(delta);
};

View File

@@ -7,7 +7,6 @@ goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.control.Control');
goog.require('ol.css');
goog.require('ol.pointer.PointerEventHandler');
@@ -40,10 +39,6 @@ ol.control.ZoomToExtent = function(opt_options) {
'title': tipLabel
});
var buttonHandler = new ol.pointer.PointerEventHandler(button);
this.registerDisposable(buttonHandler);
goog.events.listen(buttonHandler, ol.pointer.EventType.POINTERUP,
this.handlePointerUp_, false, this);
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
@@ -71,19 +66,7 @@ goog.inherits(ol.control.ZoomToExtent, ol.control.Control);
* @private
*/
ol.control.ZoomToExtent.prototype.handleClick_ = function(event) {
if (event.screenX !== 0 && event.screenY !== 0) {
return;
}
this.handleZoomToExtent_();
};
/**
* @param {ol.pointer.PointerEvent} pointerEvent The event to handle
* @private
*/
ol.control.ZoomToExtent.prototype.handlePointerUp_ = function(pointerEvent) {
pointerEvent.browserEvent.preventDefault();
event.preventDefault();
this.handleZoomToExtent_();
};

View File

@@ -176,6 +176,8 @@ ol.FeatureOverlay.prototype.handleMapPostCompose_ = function(event) {
var frameState = event.frameState;
var pixelRatio = frameState.pixelRatio;
var resolution = frameState.viewState.resolution;
var squaredTolerance = ol.renderer.vector.getSquaredTolerance(resolution,
pixelRatio);
var i, ii, styles, featureStyleFunction;
this.features_.forEach(function(feature) {
featureStyleFunction = feature.getStyleFunction();
@@ -189,8 +191,7 @@ ol.FeatureOverlay.prototype.handleMapPostCompose_ = function(event) {
ii = styles.length;
for (i = 0; i < ii; ++i) {
ol.renderer.vector.renderFeature(replayGroup, feature, styles[i],
ol.renderer.vector.getSquaredTolerance(resolution, pixelRatio),
feature, this.handleImageChange_, this);
squaredTolerance, feature, this.handleImageChange_, this);
}
}, this);
};

View File

@@ -5,12 +5,17 @@ goog.require('ol.Feature');
goog.require('ol.format.Feature');
goog.require('ol.format.TextFeature');
goog.require('ol.geom.LineString');
goog.require('ol.geom.flat.flip');
goog.require('ol.geom.flat.inflate');
goog.require('ol.proj');
/**
* @classdesc
* Feature format for reading and writing data in the Encoded
* Polyline Algorithm Format.
*
* @constructor
* @extends {ol.format.TextFeature}
* @param {olx.format.PolylineOptions=} opt_options
@@ -250,7 +255,8 @@ ol.format.Polyline.encodeUnsignedInteger = function(num) {
/**
* Read the feature from the Polyline source.
* Read the feature from the Polyline source. The coordinates are assumed to be
* in two dimensions and in latitude, longitude order.
*
* @function
* @param {ArrayBuffer|Document|Node|Object|string} source Source.
@@ -311,6 +317,8 @@ ol.format.Polyline.prototype.readGeometry;
ol.format.Polyline.prototype.readGeometryFromText =
function(text, opt_options) {
var flatCoordinates = ol.format.Polyline.decodeDeltas(text, 2, this.factor_);
ol.geom.flat.flip.flipXY(
flatCoordinates, 0, flatCoordinates.length, 2, flatCoordinates);
var coordinates = ol.geom.flat.inflate.coordinates(
flatCoordinates, 0, flatCoordinates.length, 2);
@@ -387,5 +395,7 @@ ol.format.Polyline.prototype.writeGeometryText =
geometry, true, this.adaptOptions(opt_options)));
var flatCoordinates = geometry.getFlatCoordinates();
var stride = geometry.getStride();
ol.geom.flat.flip.flipXY(
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates);
return ol.format.Polyline.encodeDeltas(flatCoordinates, stride, this.factor_);
};

View File

@@ -286,7 +286,7 @@ ol.interaction.Draw.prototype.handlePointerUp = function(event) {
this.startDrawing_(event);
} else if (this.mode_ === ol.interaction.DrawMode.POINT ||
this.atFinish_(event)) {
this.finishDrawing_(event);
this.finishDrawing();
} else {
this.addToDrawing_(event);
}
@@ -481,10 +481,9 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
/**
* Stop drawing and add the sketch feature to the target layer.
* @param {ol.MapBrowserEvent} event Event.
* @private
* @api
*/
ol.interaction.Draw.prototype.finishDrawing_ = function(event) {
ol.interaction.Draw.prototype.finishDrawing = function() {
var sketchFeature = this.abortDrawing_();
goog.asserts.assert(!goog.isNull(sketchFeature));
var coordinates;

View File

@@ -33,6 +33,7 @@ ol.interaction.InteractionProperty = {
*
* @constructor
* @extends {ol.Object}
* @implements {oli.interaction.Interaction}
* @api
*/
ol.interaction.Interaction = function() {
@@ -76,10 +77,16 @@ ol.interaction.Interaction.prototype.getMap = function() {
/**
* Method called by the map to notify the interaction that a browser
* event was dispatched on the map. If the interaction wants to handle
* that event it can return `false` to prevent the propagation of the
* event to other interactions in the map's interactions chain.
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} Whether the map browser event should continue
* through the chain of interactions. false means stop, true
* through the chain of interactions. `false` means stop, `true`
* means continue.
* @function
* @api
*/
ol.interaction.Interaction.prototype.handleMapBrowserEvent =
goog.abstractMethod;

View File

@@ -104,21 +104,23 @@ ol.renderer.canvas.Map.prototype.dispatchComposeEvent_ =
var viewState = frameState.viewState;
var resolution = viewState.resolution;
var rotation = viewState.rotation;
ol.vec.Mat4.makeTransform2D(this.transform_,
this.canvas_.width / 2,
this.canvas_.height / 2,
pixelRatio / viewState.resolution,
-pixelRatio / viewState.resolution,
-viewState.rotation,
this.canvas_.width / 2, this.canvas_.height / 2,
pixelRatio / resolution, -pixelRatio / resolution,
-rotation,
-viewState.center[0], -viewState.center[1]);
var tolerance = ol.renderer.vector.getTolerance(resolution, pixelRatio);
var replayGroup = new ol.render.canvas.ReplayGroup(tolerance, extent,
resolution);
var vectorContext = new ol.render.canvas.Immediate(context, pixelRatio,
extent, this.transform_, rotation);
var replayGroup = new ol.render.canvas.ReplayGroup(
ol.renderer.vector.getTolerance(resolution, pixelRatio), extent,
resolution);
var composeEvent = new ol.render.Event(type, map, vectorContext,
replayGroup, frameState, context, null);
map.dispatchEvent(composeEvent);
replayGroup.finish();
if (!replayGroup.isEmpty()) {
replayGroup.replay(context, extent, pixelRatio, this.transform_,

View File

@@ -77,14 +77,19 @@ ol.ViewHint = {
* the "next" resolution. And releasing the fingers after pinch-zooming
* snaps to the closest resolution (with an animation).
*
* So the *resolution constraint* snaps to specific resolutions. It is
* The *resolution constraint* snaps to specific resolutions. It is
* determined by the following options: `resolutions`, `maxResolution`,
* `maxZoom`, and `zoomFactor`. If `resolutions` is set, the other three
* options are ignored. See documentation for each option for more
* information.
*
* The *rotation constraint* is currently not configurable. It snaps the
* rotation value to zero when approaching the horizontal.
* The *rotation constraint* snaps to specific angles. It is determined
* by the following options: `enableRotation` and `constrainRotation`.
* By default the rotation value is snapped to zero when approaching the
* horizontal.
*
* The *center constraint* is determined by the `extent` option. By
* default the center is not constrained at all.
*
* @constructor
* @extends {ol.Object}