Merge remote-tracking branch 'openlayers/master' into vector-api
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
goog.provide('ol.geom.AbstractCollection');
|
||||
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryEvent');
|
||||
|
||||
|
||||
|
||||
@@ -77,21 +75,12 @@ ol.geom.AbstractCollection.prototype.getType = goog.abstractMethod;
|
||||
|
||||
/**
|
||||
* Listener for component change events.
|
||||
* @param {ol.geom.GeometryEvent} evt Geometry event.
|
||||
* @param {goog.events.Event} evt Change event.
|
||||
* @protected
|
||||
*/
|
||||
ol.geom.AbstractCollection.prototype.handleComponentChange = function(evt) {
|
||||
this.bounds = null;
|
||||
var oldExtent = ol.extent.createEmpty();
|
||||
var components = this.components;
|
||||
for (var i = components.length - 1; i >= 0; --i) {
|
||||
var component = components[i];
|
||||
ol.extent.extend(oldExtent,
|
||||
component === evt.target && !goog.isNull(evt.oldExtent) ?
|
||||
evt.oldExtent : component.getBounds());
|
||||
}
|
||||
this.dispatchEvent(new ol.geom.GeometryEvent(goog.events.EventType.CHANGE,
|
||||
this, oldExtent));
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
|
||||
+25
-35
@@ -1,24 +1,41 @@
|
||||
goog.provide('ol.geom.Geometry');
|
||||
goog.provide('ol.geom.GeometryEvent');
|
||||
goog.provide('ol.geom.GeometryType');
|
||||
|
||||
goog.require('goog.events.Event');
|
||||
goog.require('goog.events.EventTarget');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.Observable');
|
||||
goog.require('ol.TransformFunction');
|
||||
|
||||
|
||||
/**
|
||||
* Geometry types.
|
||||
*
|
||||
* @enum {string}
|
||||
* @todo stability stable
|
||||
*/
|
||||
ol.geom.GeometryType = {
|
||||
POINT: 'Point',
|
||||
LINE_STRING: 'LineString',
|
||||
LINEAR_RING: 'LinearRing',
|
||||
POLYGON: 'Polygon',
|
||||
MULTI_POINT: 'MultiPoint',
|
||||
MULTI_LINE_STRING: 'MultiLineString',
|
||||
MULTI_POLYGON: 'MultiPolygon',
|
||||
GEOMETRY_COLLECTION: 'GeometryCollection'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {goog.events.EventTarget}
|
||||
* @extends {ol.Observable}
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.geom.Geometry = function() {
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.geom.Geometry, goog.events.EventTarget);
|
||||
goog.inherits(ol.geom.Geometry, ol.Observable);
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,36 +74,9 @@ ol.geom.Geometry.prototype.getType = goog.abstractMethod;
|
||||
ol.geom.Geometry.prototype.transform = goog.abstractMethod;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for geometry events.
|
||||
* @constructor
|
||||
* @extends {goog.events.Event}
|
||||
* @param {string} type Event type.
|
||||
* @param {ol.geom.Geometry} target The target geometry.
|
||||
* @param {ol.Extent} oldExtent The previous geometry extent.
|
||||
* Dispatch a generic event with type "change."
|
||||
*/
|
||||
ol.geom.GeometryEvent = function(type, target, oldExtent) {
|
||||
goog.base(this, type, target);
|
||||
|
||||
this.oldExtent = oldExtent;
|
||||
};
|
||||
goog.inherits(ol.geom.GeometryEvent, goog.events.Event);
|
||||
|
||||
|
||||
/**
|
||||
* Geometry types.
|
||||
*
|
||||
* @enum {string}
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.geom.GeometryType = {
|
||||
POINT: 'point',
|
||||
LINESTRING: 'linestring',
|
||||
LINEARRING: 'linearring',
|
||||
POLYGON: 'polygon',
|
||||
MULTIPOINT: 'multipoint',
|
||||
MULTILINESTRING: 'multilinestring',
|
||||
MULTIPOLYGON: 'multipolygon',
|
||||
GEOMETRYCOLLECTION: 'geometrycollection'
|
||||
ol.geom.Geometry.prototype.dispatchChangeEvent = function() {
|
||||
this.dispatchEvent(goog.events.EventType.CHANGE);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
goog.provide('ol.geom.LineString');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('ol.CoordinateArray');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryEvent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
|
||||
|
||||
@@ -15,7 +13,7 @@ goog.require('ol.geom.GeometryType');
|
||||
* @constructor
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @param {ol.CoordinateArray} coordinates Array of coordinates (e.g.
|
||||
* [[x0, y0], [x1, y1]]).
|
||||
* `[[x0, y0], [x1, y1]]`).
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.geom.LineString = function(coordinates) {
|
||||
@@ -90,7 +88,7 @@ ol.geom.LineString.prototype.getBounds = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.geom.LineString.prototype.getType = function() {
|
||||
return ol.geom.GeometryType.LINESTRING;
|
||||
return ol.geom.GeometryType.LINE_STRING;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,11 +114,9 @@ ol.geom.LineString.prototype.distanceFromCoordinate = function(coordinate) {
|
||||
* @param {ol.CoordinateArray} coordinates Coordinates array.
|
||||
*/
|
||||
ol.geom.LineString.prototype.setCoordinates = function(coordinates) {
|
||||
var oldBounds = this.bounds_;
|
||||
this.bounds_ = null;
|
||||
this.coordinates_ = coordinates;
|
||||
this.dispatchEvent(new ol.geom.GeometryEvent(goog.events.EventType.CHANGE,
|
||||
this, oldBounds));
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
@@ -134,5 +130,5 @@ ol.geom.LineString.prototype.transform = function(transform) {
|
||||
coord = coordinates[i];
|
||||
transform(coord, coord, coord.length);
|
||||
}
|
||||
this.setCoordinates(coordinates); // for change event
|
||||
this.setCoordinates(coordinates); // for invalidating bounds
|
||||
};
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
goog.provide('ol.geom.Point');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryEvent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
|
||||
|
||||
@@ -12,7 +10,7 @@ goog.require('ol.geom.GeometryType');
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.geom.Geometry}
|
||||
* @param {ol.Coordinate} coordinates Coordinate values (e.g. [x, y]).
|
||||
* @param {ol.Coordinate} coordinates Coordinate values (e.g. `[x, y]`).
|
||||
* @todo stability experimental
|
||||
*/
|
||||
ol.geom.Point = function(coordinates) {
|
||||
@@ -79,11 +77,9 @@ ol.geom.Point.prototype.getType = function() {
|
||||
* @param {ol.Coordinate} coordinates Coordinates array.
|
||||
*/
|
||||
ol.geom.Point.prototype.setCoordinates = function(coordinates) {
|
||||
var oldBounds = this.bounds_;
|
||||
this.bounds_ = null;
|
||||
this.coordinates_ = coordinates;
|
||||
this.dispatchEvent(new ol.geom.GeometryEvent(goog.events.EventType.CHANGE,
|
||||
this, oldBounds));
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
@@ -93,5 +89,5 @@ ol.geom.Point.prototype.setCoordinates = function(coordinates) {
|
||||
ol.geom.Point.prototype.transform = function(transform) {
|
||||
var coordinates = this.getCoordinates();
|
||||
transform(coordinates, coordinates, coordinates.length);
|
||||
this.setCoordinates(coordinates); // for change event
|
||||
this.setCoordinates(coordinates); // for invalidating bounds
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@ goog.require('goog.events.EventType');
|
||||
goog.require('ol.CoordinateArray');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.Geometry');
|
||||
goog.require('ol.geom.GeometryEvent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.LinearRing');
|
||||
|
||||
@@ -108,19 +107,11 @@ ol.geom.Polygon.prototype.getRings = function() {
|
||||
|
||||
/**
|
||||
* Listener for ring change events.
|
||||
* @param {ol.geom.GeometryEvent} evt Geometry event.
|
||||
* @param {goog.events.Event} evt Change event.
|
||||
* @private
|
||||
*/
|
||||
ol.geom.Polygon.prototype.handleRingChange_ = function(evt) {
|
||||
var ring = evt.target;
|
||||
var oldExtent = null;
|
||||
if (ring === this.rings_[0]) {
|
||||
oldExtent = evt.oldExtent;
|
||||
} else {
|
||||
oldExtent = this.getBounds();
|
||||
}
|
||||
this.dispatchEvent(new ol.geom.GeometryEvent(goog.events.EventType.CHANGE,
|
||||
this, oldExtent));
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user