Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions
+79 -78
View File
@@ -1,21 +1,21 @@
goog.provide('ol.interaction.Extent');
goog.require('ol');
goog.require('ol.Feature');
goog.require('ol.MapBrowserEventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.coordinate');
goog.require('ol.events.Event');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.Point');
goog.require('ol.geom.Polygon');
goog.require('ol.interaction.ExtentEventType');
goog.require('ol.interaction.Pointer');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
/**
* @module ol/interaction/Extent
*/
import _ol_ from '../index.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_Event_ from '../events/Event.js';
import _ol_extent_ from '../extent.js';
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
import _ol_geom_Point_ from '../geom/Point.js';
import _ol_geom_Polygon_ from '../geom/Polygon.js';
import _ol_interaction_ExtentEventType_ from '../interaction/ExtentEventType.js';
import _ol_interaction_Pointer_ from '../interaction/Pointer.js';
import _ol_layer_Vector_ from '../layer/Vector.js';
import _ol_source_Vector_ from '../source/Vector.js';
import _ol_style_Style_ from '../style/Style.js';
/**
* @classdesc
@@ -29,7 +29,7 @@ goog.require('ol.style.Style');
* @param {olx.interaction.ExtentOptions=} opt_options Options.
* @api
*/
ol.interaction.Extent = function(opt_options) {
var _ol_interaction_Extent_ = function(opt_options) {
var options = opt_options || {};
@@ -81,11 +81,11 @@ ol.interaction.Extent = function(opt_options) {
}
/* Inherit ol.interaction.Pointer */
ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Extent.handleDownEvent_,
handleDragEvent: ol.interaction.Extent.handleDragEvent_,
handleEvent: ol.interaction.Extent.handleEvent_,
handleUpEvent: ol.interaction.Extent.handleUpEvent_
_ol_interaction_Pointer_.call(this, {
handleDownEvent: _ol_interaction_Extent_.handleDownEvent_,
handleDragEvent: _ol_interaction_Extent_.handleDragEvent_,
handleEvent: _ol_interaction_Extent_.handleEvent_,
handleUpEvent: _ol_interaction_Extent_.handleUpEvent_
});
/**
@@ -93,12 +93,12 @@ ol.interaction.Extent = function(opt_options) {
* @type {ol.layer.Vector}
* @private
*/
this.extentOverlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
this.extentOverlay_ = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
wrapX: !!opt_options.wrapX
}),
style: opt_options.boxStyle ? opt_options.boxStyle : ol.interaction.Extent.getDefaultExtentStyleFunction_(),
style: opt_options.boxStyle ? opt_options.boxStyle : _ol_interaction_Extent_.getDefaultExtentStyleFunction_(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
@@ -108,12 +108,12 @@ ol.interaction.Extent = function(opt_options) {
* @type {ol.layer.Vector}
* @private
*/
this.vertexOverlay_ = new ol.layer.Vector({
source: new ol.source.Vector({
this.vertexOverlay_ = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
useSpatialIndex: false,
wrapX: !!opt_options.wrapX
}),
style: opt_options.pointerStyle ? opt_options.pointerStyle : ol.interaction.Extent.getDefaultPointerStyleFunction_(),
style: opt_options.pointerStyle ? opt_options.pointerStyle : _ol_interaction_Extent_.getDefaultPointerStyleFunction_(),
updateWhileAnimating: true,
updateWhileInteracting: true
});
@@ -123,7 +123,7 @@ ol.interaction.Extent = function(opt_options) {
}
};
ol.inherits(ol.interaction.Extent, ol.interaction.Pointer);
_ol_.inherits(_ol_interaction_Extent_, _ol_interaction_Pointer_);
/**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
@@ -131,16 +131,16 @@ ol.inherits(ol.interaction.Extent, ol.interaction.Pointer);
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleEvent_ = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof ol.MapBrowserPointerEvent)) {
_ol_interaction_Extent_.handleEvent_ = function(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof _ol_MapBrowserPointerEvent_)) {
return true;
}
//display pointer (if not dragging)
if (mapBrowserEvent.type == ol.MapBrowserEventType.POINTERMOVE && !this.handlingDownUpSequence) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE && !this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent);
}
//call pointer to determine up/down/drag
ol.interaction.Pointer.handleEvent.call(this, mapBrowserEvent);
_ol_interaction_Pointer_.handleEvent.call(this, mapBrowserEvent);
//return false to stop propagation
return false;
};
@@ -151,7 +151,7 @@ ol.interaction.Extent.handleEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.handleDownEvent_ = function(mapBrowserEvent) {
var pixel = mapBrowserEvent.pixel;
var map = mapBrowserEvent.map;
@@ -183,15 +183,15 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
//snap to point
if (x !== null && y !== null) {
this.pointerHandler_ = ol.interaction.Extent.getPointHandler_(getOpposingPoint(vertex));
this.pointerHandler_ = _ol_interaction_Extent_.getPointHandler_(getOpposingPoint(vertex));
//snap to edge
} else if (x !== null) {
this.pointerHandler_ = ol.interaction.Extent.getEdgeHandler_(
this.pointerHandler_ = _ol_interaction_Extent_.getEdgeHandler_(
getOpposingPoint([x, extent[1]]),
getOpposingPoint([x, extent[3]])
);
} else if (y !== null) {
this.pointerHandler_ = ol.interaction.Extent.getEdgeHandler_(
this.pointerHandler_ = _ol_interaction_Extent_.getEdgeHandler_(
getOpposingPoint([extent[0], y]),
getOpposingPoint([extent[2], y])
);
@@ -200,7 +200,7 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
} else {
vertex = map.getCoordinateFromPixel(pixel);
this.setExtent([vertex[0], vertex[1], vertex[0], vertex[1]]);
this.pointerHandler_ = ol.interaction.Extent.getPointHandler_(vertex);
this.pointerHandler_ = _ol_interaction_Extent_.getPointHandler_(vertex);
}
return true; //event handled; start downup sequence
};
@@ -211,7 +211,7 @@ ol.interaction.Extent.handleDownEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleDragEvent_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.handleDragEvent_ = function(mapBrowserEvent) {
if (this.pointerHandler_) {
var pixelCoordinate = mapBrowserEvent.coordinate;
this.setExtent(this.pointerHandler_(pixelCoordinate));
@@ -226,11 +226,11 @@ ol.interaction.Extent.handleDragEvent_ = function(mapBrowserEvent) {
* @this {ol.interaction.Extent}
* @private
*/
ol.interaction.Extent.handleUpEvent_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.handleUpEvent_ = function(mapBrowserEvent) {
this.pointerHandler_ = null;
//If bbox is zero area, set to null;
var extent = this.getExtent();
if (!extent || ol.extent.getArea(extent) === 0) {
if (!extent || _ol_extent_.getArea(extent) === 0) {
this.setExtent(null);
}
return false; //Stop handling downup sequence
@@ -242,10 +242,10 @@ ol.interaction.Extent.handleUpEvent_ = function(mapBrowserEvent) {
* @return {ol.StyleFunction} Default Extent style
* @private
*/
ol.interaction.Extent.getDefaultExtentStyleFunction_ = function() {
var style = ol.style.Style.createDefaultEditing();
_ol_interaction_Extent_.getDefaultExtentStyleFunction_ = function() {
var style = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return style[ol.geom.GeometryType.POLYGON];
return style[_ol_geom_GeometryType_.POLYGON];
};
};
@@ -255,10 +255,10 @@ ol.interaction.Extent.getDefaultExtentStyleFunction_ = function() {
* @return {ol.StyleFunction} Default pointer style
* @private
*/
ol.interaction.Extent.getDefaultPointerStyleFunction_ = function() {
var style = ol.style.Style.createDefaultEditing();
_ol_interaction_Extent_.getDefaultPointerStyleFunction_ = function() {
var style = _ol_style_Style_.createDefaultEditing();
return function(feature, resolution) {
return style[ol.geom.GeometryType.POINT];
return style[_ol_geom_GeometryType_.POINT];
};
};
@@ -267,9 +267,9 @@ ol.interaction.Extent.getDefaultPointerStyleFunction_ = function() {
* @returns {function (ol.Coordinate): ol.Extent} event handler
* @private
*/
ol.interaction.Extent.getPointHandler_ = function(fixedPoint) {
_ol_interaction_Extent_.getPointHandler_ = function(fixedPoint) {
return function(point) {
return ol.extent.boundingExtent([fixedPoint, point]);
return _ol_extent_.boundingExtent([fixedPoint, point]);
};
};
@@ -279,14 +279,14 @@ ol.interaction.Extent.getPointHandler_ = function(fixedPoint) {
* @returns {function (ol.Coordinate): ol.Extent|null} event handler
* @private
*/
ol.interaction.Extent.getEdgeHandler_ = function(fixedP1, fixedP2) {
_ol_interaction_Extent_.getEdgeHandler_ = function(fixedP1, fixedP2) {
if (fixedP1[0] == fixedP2[0]) {
return function(point) {
return ol.extent.boundingExtent([fixedP1, [point[0], fixedP2[1]]]);
return _ol_extent_.boundingExtent([fixedP1, [point[0], fixedP2[1]]]);
};
} else if (fixedP1[1] == fixedP2[1]) {
return function(point) {
return ol.extent.boundingExtent([fixedP1, [fixedP2[0], point[1]]]);
return _ol_extent_.boundingExtent([fixedP1, [fixedP2[0], point[1]]]);
};
} else {
return null;
@@ -298,7 +298,7 @@ ol.interaction.Extent.getEdgeHandler_ = function(fixedP1, fixedP2) {
* @returns {Array<Array<ol.Coordinate>>} extent line segments
* @private
*/
ol.interaction.Extent.getSegments_ = function(extent) {
_ol_interaction_Extent_.getSegments_ = function(extent) {
return [
[[extent[0], extent[1]], [extent[0], extent[3]]],
[[extent[0], extent[3]], [extent[2], extent[3]]],
@@ -313,30 +313,30 @@ ol.interaction.Extent.getSegments_ = function(extent) {
* @returns {ol.Coordinate|null} snapped vertex on extent
* @private
*/
ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) {
_ol_interaction_Extent_.prototype.snapToVertex_ = function(pixel, map) {
var pixelCoordinate = map.getCoordinateFromPixel(pixel);
var sortByDistance = function(a, b) {
return ol.coordinate.squaredDistanceToSegment(pixelCoordinate, a) -
ol.coordinate.squaredDistanceToSegment(pixelCoordinate, b);
return _ol_coordinate_.squaredDistanceToSegment(pixelCoordinate, a) -
_ol_coordinate_.squaredDistanceToSegment(pixelCoordinate, b);
};
var extent = this.getExtent();
if (extent) {
//convert extents to line segments and find the segment closest to pixelCoordinate
var segments = ol.interaction.Extent.getSegments_(extent);
var segments = _ol_interaction_Extent_.getSegments_(extent);
segments.sort(sortByDistance);
var closestSegment = segments[0];
var vertex = (ol.coordinate.closestOnSegment(pixelCoordinate,
var vertex = (_ol_coordinate_.closestOnSegment(pixelCoordinate,
closestSegment));
var vertexPixel = map.getPixelFromCoordinate(vertex);
//if the distance is within tolerance, snap to the segment
if (ol.coordinate.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
if (_ol_coordinate_.distance(pixel, vertexPixel) <= this.pixelTolerance_) {
//test if we should further snap to a vertex
var pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
var pixel2 = map.getPixelFromCoordinate(closestSegment[1]);
var squaredDist1 = ol.coordinate.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = ol.coordinate.squaredDistance(vertexPixel, pixel2);
var squaredDist1 = _ol_coordinate_.squaredDistance(vertexPixel, pixel1);
var squaredDist2 = _ol_coordinate_.squaredDistance(vertexPixel, pixel2);
var dist = Math.sqrt(Math.min(squaredDist1, squaredDist2));
this.snappedToVertex_ = dist <= this.pixelTolerance_;
if (this.snappedToVertex_) {
@@ -353,7 +353,7 @@ ol.interaction.Extent.prototype.snapToVertex_ = function(pixel, map) {
* @param {ol.MapBrowserEvent} mapBrowserEvent pointer move event
* @private
*/
ol.interaction.Extent.prototype.handlePointerMove_ = function(mapBrowserEvent) {
_ol_interaction_Extent_.prototype.handlePointerMove_ = function(mapBrowserEvent) {
var pixel = mapBrowserEvent.pixel;
var map = mapBrowserEvent.map;
@@ -369,14 +369,14 @@ ol.interaction.Extent.prototype.handlePointerMove_ = function(mapBrowserEvent) {
* @returns {ol.Feature} extent as featrue
* @private
*/
ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent) {
_ol_interaction_Extent_.prototype.createOrUpdateExtentFeature_ = function(extent) {
var extentFeature = this.extentFeature_;
if (!extentFeature) {
if (!extent) {
extentFeature = new ol.Feature({});
extentFeature = new _ol_Feature_({});
} else {
extentFeature = new ol.Feature(ol.geom.Polygon.fromExtent(extent));
extentFeature = new _ol_Feature_(_ol_geom_Polygon_.fromExtent(extent));
}
this.extentFeature_ = extentFeature;
this.extentOverlay_.getSource().addFeature(extentFeature);
@@ -384,7 +384,7 @@ ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent)
if (!extent) {
extentFeature.setGeometry(undefined);
} else {
extentFeature.setGeometry(ol.geom.Polygon.fromExtent(extent));
extentFeature.setGeometry(_ol_geom_Polygon_.fromExtent(extent));
}
}
return extentFeature;
@@ -396,10 +396,10 @@ ol.interaction.Extent.prototype.createOrUpdateExtentFeature_ = function(extent)
* @returns {ol.Feature} vertex as feature
* @private
*/
ol.interaction.Extent.prototype.createOrUpdatePointerFeature_ = function(vertex) {
_ol_interaction_Extent_.prototype.createOrUpdatePointerFeature_ = function(vertex) {
var vertexFeature = this.vertexFeature_;
if (!vertexFeature) {
vertexFeature = new ol.Feature(new ol.geom.Point(vertex));
vertexFeature = new _ol_Feature_(new _ol_geom_Point_(vertex));
this.vertexFeature_ = vertexFeature;
this.vertexOverlay_.getSource().addFeature(vertexFeature);
} else {
@@ -413,10 +413,10 @@ ol.interaction.Extent.prototype.createOrUpdatePointerFeature_ = function(vertex)
/**
* @inheritDoc
*/
ol.interaction.Extent.prototype.setMap = function(map) {
_ol_interaction_Extent_.prototype.setMap = function(map) {
this.extentOverlay_.setMap(map);
this.vertexOverlay_.setMap(map);
ol.interaction.Pointer.prototype.setMap.call(this, map);
_ol_interaction_Pointer_.prototype.setMap.call(this, map);
};
/**
@@ -425,7 +425,7 @@ ol.interaction.Extent.prototype.setMap = function(map) {
* @return {ol.Extent} Drawn extent in the view projection.
* @api
*/
ol.interaction.Extent.prototype.getExtent = function() {
_ol_interaction_Extent_.prototype.getExtent = function() {
return this.extent_;
};
@@ -435,11 +435,11 @@ ol.interaction.Extent.prototype.getExtent = function() {
* @param {ol.Extent} extent Extent
* @api
*/
ol.interaction.Extent.prototype.setExtent = function(extent) {
_ol_interaction_Extent_.prototype.setExtent = function(extent) {
//Null extent means no bbox
this.extent_ = extent ? extent : null;
this.createOrUpdateExtentFeature_(extent);
this.dispatchEvent(new ol.interaction.Extent.Event(this.extent_));
this.dispatchEvent(new _ol_interaction_Extent_.Event(this.extent_));
};
@@ -453,8 +453,8 @@ ol.interaction.Extent.prototype.setExtent = function(extent) {
* @param {ol.Extent} extent the new extent
* @extends {ol.events.Event}
*/
ol.interaction.Extent.Event = function(extent) {
ol.events.Event.call(this, ol.interaction.ExtentEventType.EXTENTCHANGED);
_ol_interaction_Extent_.Event = function(extent) {
_ol_events_Event_.call(this, _ol_interaction_ExtentEventType_.EXTENTCHANGED);
/**
* The current extent.
@@ -464,4 +464,5 @@ ol.interaction.Extent.Event = function(extent) {
this.extent = extent;
};
ol.inherits(ol.interaction.Extent.Event, ol.events.Event);
_ol_.inherits(_ol_interaction_Extent_.Event, _ol_events_Event_);
export default _ol_interaction_Extent_;