80 lines
1.9 KiB
JavaScript
80 lines
1.9 KiB
JavaScript
goog.provide('ol.geom.Point');
|
|
|
|
goog.require('goog.asserts');
|
|
goog.require('ol.extent');
|
|
goog.require('ol.geom.Geometry');
|
|
goog.require('ol.geom.flat');
|
|
|
|
|
|
|
|
/**
|
|
* @constructor
|
|
* @extends {ol.geom.Geometry}
|
|
* @param {ol.geom.RawPoint} coordinates Coordinates.
|
|
* @param {ol.geom.Layout=} opt_layout Layout.
|
|
*/
|
|
ol.geom.Point = function(coordinates, opt_layout) {
|
|
goog.base(this);
|
|
this.setCoordinates(coordinates, opt_layout);
|
|
};
|
|
goog.inherits(ol.geom.Point, ol.geom.Geometry);
|
|
|
|
|
|
/**
|
|
* @return {ol.geom.RawPoint} Coordinates.
|
|
*/
|
|
ol.geom.Point.prototype.getCoordinates = function() {
|
|
return this.flatCoordinates.slice();
|
|
};
|
|
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
ol.geom.Point.prototype.getExtent = function(opt_extent) {
|
|
if (this.extentRevision != this.revision) {
|
|
this.extent = ol.extent.createOrUpdateFromCoordinate(
|
|
this.flatCoordinates, this.extent);
|
|
this.extentRevision = this.revision;
|
|
}
|
|
goog.asserts.assert(goog.isDef(this.extent));
|
|
return ol.extent.returnOrUpdate(this.extent, opt_extent);
|
|
};
|
|
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
ol.geom.Point.prototype.getType = function() {
|
|
return ol.geom.Type.POINT;
|
|
};
|
|
|
|
|
|
/**
|
|
* @param {ol.geom.RawPoint} coordinates Coordinates.
|
|
* @param {ol.geom.Layout=} opt_layout Layout.
|
|
*/
|
|
ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) {
|
|
if (goog.isNull(coordinates)) {
|
|
this.setFlatCoordinates(ol.geom.Layout.XY, null);
|
|
} else {
|
|
this.setLayout(opt_layout, coordinates, 0);
|
|
if (goog.isNull(this.flatCoordinates)) {
|
|
this.flatCoordinates = [];
|
|
}
|
|
this.flatCoordinates.length = ol.geom.flat.deflateCoordinate(
|
|
this.flatCoordinates, 0, coordinates, this.stride);
|
|
this.dispatchChangeEvent();
|
|
}
|
|
};
|
|
|
|
|
|
/**
|
|
* @param {ol.geom.Layout} layout Layout.
|
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
|
*/
|
|
ol.geom.Point.prototype.setFlatCoordinates = function(layout, flatCoordinates) {
|
|
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
|
this.dispatchChangeEvent();
|
|
};
|