Add ol/pixel module for Pixel type
This commit is contained in:
@@ -29,7 +29,7 @@ app.Drag = function() {
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
* @private
|
||||
*/
|
||||
this.coordinate_ = null;
|
||||
|
||||
@@ -31,7 +31,7 @@ class MapBrowserEvent extends MapEvent {
|
||||
|
||||
/**
|
||||
* The map pixel relative to the viewport corresponding to the original browser event.
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
* @api
|
||||
*/
|
||||
this.pixel = map.getEventPixel(browserEvent);
|
||||
|
||||
@@ -508,7 +508,7 @@ class Overlay extends BaseObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {module:ol~Pixel} pixel The pixel location.
|
||||
* @param {module:ol/pixel~Pixel} pixel The pixel location.
|
||||
* @param {module:ol/size~Size|undefined} mapSize The map size.
|
||||
* @protected
|
||||
*/
|
||||
|
||||
@@ -543,7 +543,7 @@ class PluggableMap extends BaseObject {
|
||||
* Detect features that intersect a pixel on the viewport, and execute a
|
||||
* callback with each intersecting feature. Layers included in the detection can
|
||||
* be configured through the `layerFilter` option in `opt_options`.
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @param {function(this: S, (module:ol/Feature|module:ol/render/Feature),
|
||||
* module:ol/layer/Layer): T} callback Feature callback. The callback will be
|
||||
* called with two arguments. The first argument is one
|
||||
@@ -575,7 +575,7 @@ class PluggableMap extends BaseObject {
|
||||
|
||||
/**
|
||||
* Get all features that intersect a pixel on the viewport.
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options.
|
||||
* @return {Array.<module:ol/Feature|module:ol/render/Feature>} The detected features or
|
||||
* `null` if none were found.
|
||||
@@ -596,7 +596,7 @@ class PluggableMap extends BaseObject {
|
||||
* Detect layers that have a color value at a pixel on the viewport, and
|
||||
* execute a callback with each matching layer. Layers included in the
|
||||
* detection can be configured through `opt_layerFilter`.
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @param {function(this: S, module:ol/layer/Layer, (Uint8ClampedArray|Uint8Array)): T} callback
|
||||
* Layer callback. This callback will receive two arguments: first is the
|
||||
* {@link module:ol/layer/Layer layer}, second argument is an array representing
|
||||
@@ -624,7 +624,7 @@ class PluggableMap extends BaseObject {
|
||||
/**
|
||||
* Detect if features intersect a pixel on the viewport. Layers included in the
|
||||
* detection can be configured through `opt_layerFilter`.
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @param {module:ol/PluggableMap~AtPixelOptions=} opt_options Optional options.
|
||||
* @return {boolean} Is there a feature at the given pixel?
|
||||
* @template U
|
||||
@@ -656,7 +656,7 @@ class PluggableMap extends BaseObject {
|
||||
/**
|
||||
* Returns the map pixel position for a browser event relative to the viewport.
|
||||
* @param {Event} event Event.
|
||||
* @return {module:ol~Pixel} Pixel.
|
||||
* @return {module:ol/pixel~Pixel} Pixel.
|
||||
* @api
|
||||
*/
|
||||
getEventPixel(event) {
|
||||
@@ -700,7 +700,7 @@ class PluggableMap extends BaseObject {
|
||||
/**
|
||||
* Get the coordinate for a given pixel. This returns a coordinate in the
|
||||
* map view projection.
|
||||
* @param {module:ol~Pixel} pixel Pixel position in the map viewport.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel position in the map viewport.
|
||||
* @return {module:ol/coordinate~Coordinate} The coordinate for the pixel position.
|
||||
* @api
|
||||
*/
|
||||
@@ -784,7 +784,7 @@ class PluggableMap extends BaseObject {
|
||||
* Get the pixel for a coordinate. This takes a coordinate in the map view
|
||||
* projection and returns the corresponding pixel.
|
||||
* @param {module:ol/coordinate~Coordinate} coordinate A map coordinate.
|
||||
* @return {module:ol~Pixel} A pixel position in the map viewport.
|
||||
* @return {module:ol/pixel~Pixel} A pixel position in the map viewport.
|
||||
* @api
|
||||
*/
|
||||
getPixelFromCoordinate(coordinate) {
|
||||
|
||||
@@ -1077,7 +1077,7 @@ class View extends BaseObject {
|
||||
* Center on coordinate and view position.
|
||||
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
|
||||
* @param {module:ol/size~Size} size Box pixel size.
|
||||
* @param {module:ol~Pixel} position Position on the view to center on.
|
||||
* @param {module:ol/pixel~Pixel} position Position on the view to center on.
|
||||
* @api
|
||||
*/
|
||||
centerOn(coordinate, size, position) {
|
||||
|
||||
@@ -107,7 +107,7 @@ class MousePosition extends Control {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
*/
|
||||
this.lastMouseMovePixel_ = null;
|
||||
|
||||
@@ -208,7 +208,7 @@ class MousePosition extends Control {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?module:ol~Pixel} pixel Pixel.
|
||||
* @param {?module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @private
|
||||
*/
|
||||
updateHTML_(pixel) {
|
||||
|
||||
@@ -33,9 +33,3 @@ export {default as WebGLMap} from './WebGLMap.js';
|
||||
|
||||
export {getUid, inherits, VERSION} from './util.js';
|
||||
|
||||
/**
|
||||
* An array with two elements, representing a pixel. The first element is the
|
||||
* x-coordinate, the second the y-coordinate of the pixel.
|
||||
* @typedef {Array.<number>} Pixel
|
||||
* @api
|
||||
*/
|
||||
|
||||
@@ -11,9 +11,9 @@ import RenderBox from '../render/Box.js';
|
||||
|
||||
/**
|
||||
* A function that takes a {@link module:ol/MapBrowserEvent} and two
|
||||
* {@link module:ol~Pixel}s and returns a `{boolean}`. If the condition is met,
|
||||
* {@link module:ol/pixel~Pixel}s and returns a `{boolean}`. If the condition is met,
|
||||
* true should be returned.
|
||||
* @typedef {function(this: ?, module:ol/MapBrowserEvent, module:ol~Pixel, module:ol~Pixel):boolean} EndCondition
|
||||
* @typedef {function(this: ?, module:ol/MapBrowserEvent, module:ol/pixel~Pixel, module:ol/pixel~Pixel):boolean} EndCondition
|
||||
*/
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import RenderBox from '../render/Box.js';
|
||||
* @property {number} [minArea=64] The minimum area of the box in pixel, this value is used by the default
|
||||
* `boxEndCondition` function.
|
||||
* @property {module:ol/interaction/DragBox~EndCondition} [boxEndCondition] A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two
|
||||
* {@link module:ol~Pixel}s to indicate whether a `boxend` event should be fired.
|
||||
* {@link module:ol/pixel~Pixel}s to indicate whether a `boxend` event should be fired.
|
||||
* Default is `true` if the area of the box is bigger than the `minArea` option.
|
||||
* @property {function(this:module:ol/interaction/DragBox, module:ol/MapBrowserEvent)} onBoxEnd Code to execute just
|
||||
* before `boxend` is fired.
|
||||
@@ -143,7 +143,7 @@ class DragBox extends PointerInteraction {
|
||||
this.onBoxEnd_ = options.onBoxEnd ? options.onBoxEnd : UNDEFINED;
|
||||
|
||||
/**
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
* @private
|
||||
*/
|
||||
this.startPixel_ = null;
|
||||
@@ -178,8 +178,8 @@ class DragBox extends PointerInteraction {
|
||||
* should fire.
|
||||
* @param {module:ol/MapBrowserEvent} mapBrowserEvent The originating MapBrowserEvent
|
||||
* leading to the box end.
|
||||
* @param {module:ol~Pixel} startPixel The starting pixel of the box.
|
||||
* @param {module:ol~Pixel} endPixel The end pixel of the box.
|
||||
* @param {module:ol/pixel~Pixel} startPixel The starting pixel of the box.
|
||||
* @param {module:ol/pixel~Pixel} endPixel The end pixel of the box.
|
||||
* @return {boolean} Whether or not the boxend condition should be fired.
|
||||
* @this {module:ol/interaction/DragBox}
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ class DragPan extends PointerInteraction {
|
||||
this.kinetic_ = options.kinetic;
|
||||
|
||||
/**
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
*/
|
||||
this.lastCentroid = null;
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ class Draw extends PointerInteraction {
|
||||
this.shouldHandle_ = false;
|
||||
|
||||
/**
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
* @private
|
||||
*/
|
||||
this.downPx_ = null;
|
||||
|
||||
@@ -177,7 +177,7 @@ class ExtentInteraction extends PointerInteraction {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {module:ol~Pixel} pixel cursor location
|
||||
* @param {module:ol/pixel~Pixel} pixel cursor location
|
||||
* @param {module:ol/PluggableMap} map map
|
||||
* @returns {module:ol/coordinate~Coordinate|null} snapped vertex on extent
|
||||
* @private
|
||||
|
||||
@@ -209,7 +209,7 @@ class Modify extends PointerInteraction {
|
||||
this.vertexSegments_ = null;
|
||||
|
||||
/**
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
* @private
|
||||
*/
|
||||
this.lastPixel_ = [0, 0];
|
||||
@@ -668,7 +668,7 @@ class Modify extends PointerInteraction {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {module:ol~Pixel} pixel Pixel
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel
|
||||
* @param {module:ol/PluggableMap} map Map.
|
||||
* @private
|
||||
*/
|
||||
|
||||
@@ -170,7 +170,7 @@ class PointerInteraction extends Interaction {
|
||||
|
||||
/**
|
||||
* @param {Array.<module:ol/pointer/PointerEvent>} pointerEvents List of events.
|
||||
* @return {module:ol~Pixel} Centroid pixel.
|
||||
* @return {module:ol/pixel~Pixel} Centroid pixel.
|
||||
*/
|
||||
export function centroid(pointerEvents) {
|
||||
const length = pointerEvents.length;
|
||||
|
||||
@@ -22,7 +22,7 @@ import RBush from '../structs/RBush.js';
|
||||
* @typedef {Object} Result
|
||||
* @property {boolean} snapped
|
||||
* @property {module:ol/coordinate~Coordinate|null} vertex
|
||||
* @property {module:ol~Pixel|null} vertexPixel
|
||||
* @property {module:ol/pixel~Pixel|null} vertexPixel
|
||||
*/
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ class Snap extends PointerInteraction {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {module:ol~Pixel} pixel Pixel
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel
|
||||
* @param {module:ol/coordinate~Coordinate} pixelCoordinate Coordinate
|
||||
* @param {module:ol/PluggableMap} map Map.
|
||||
* @return {module:ol/interaction/Snap~Result} Snap result
|
||||
|
||||
@@ -163,7 +163,7 @@ class Translate extends PointerInteraction {
|
||||
/**
|
||||
* Tests to see if the given coordinates intersects any of our selected
|
||||
* features.
|
||||
* @param {module:ol~Pixel} pixel Pixel coordinate to test for intersection.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel coordinate to test for intersection.
|
||||
* @param {module:ol/PluggableMap} map Map to test the intersection on.
|
||||
* @return {module:ol/Feature} Returns the feature found at the specified pixel
|
||||
* coordinates.
|
||||
|
||||
6
src/ol/pixel.js
Normal file
6
src/ol/pixel.js
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* An array with two elements, representing a pixel. The first element is the
|
||||
* x-coordinate, the second the y-coordinate of the pixel.
|
||||
* @typedef {Array.<number>} Pixel
|
||||
* @api
|
||||
*/
|
||||
@@ -154,7 +154,7 @@ class MouseSource extends EventSource {
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<module:ol~Pixel>}
|
||||
* @type {Array.<module:ol/pixel~Pixel>}
|
||||
*/
|
||||
this.lastTouches = [];
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ class RenderBox extends Disposable {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
*/
|
||||
this.startPixel_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {module:ol~Pixel}
|
||||
* @type {module:ol/pixel~Pixel}
|
||||
*/
|
||||
this.endPixel_ = null;
|
||||
|
||||
@@ -83,8 +83,8 @@ class RenderBox extends Disposable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {module:ol~Pixel} startPixel Start pixel.
|
||||
* @param {module:ol~Pixel} endPixel End pixel.
|
||||
* @param {module:ol/pixel~Pixel} startPixel Start pixel.
|
||||
* @param {module:ol/pixel~Pixel} endPixel End pixel.
|
||||
*/
|
||||
setPixels(startPixel, endPixel) {
|
||||
this.startPixel_ = startPixel;
|
||||
|
||||
@@ -167,7 +167,7 @@ class MapRenderer extends Disposable {
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @param {module:ol/PluggableMap~FrameState} frameState FrameState.
|
||||
* @param {number} hitTolerance Hit tolerance in pixels.
|
||||
* @param {function(this: S, module:ol/layer/Layer, (Uint8ClampedArray|Uint8Array)): T} callback Layer
|
||||
|
||||
@@ -240,7 +240,7 @@ class WebGLLayerRenderer extends LayerRenderer {
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {module:ol~Pixel} pixel Pixel.
|
||||
* @param {module:ol/pixel~Pixel} pixel Pixel.
|
||||
* @param {module:ol/PluggableMap~FrameState} frameState FrameState.
|
||||
* @param {function(this: S, module:ol/layer/Layer, (Uint8ClampedArray|Uint8Array)): T} callback Layer
|
||||
* callback.
|
||||
|
||||
@@ -125,8 +125,8 @@ export function setFromArray(transform1, transform2) {
|
||||
* resulting, transformed coordinate. The coordinate will be modified in-place.
|
||||
*
|
||||
* @param {module:ol/transform~Transform} transform The transformation.
|
||||
* @param {module:ol/coordinate~Coordinate|module:ol~Pixel} coordinate The coordinate to transform.
|
||||
* @return {module:ol/coordinate~Coordinate|module:ol~Pixel} return coordinate so that operations can be
|
||||
* @param {module:ol/coordinate~Coordinate|module:ol/pixel~Pixel} coordinate The coordinate to transform.
|
||||
* @return {module:ol/coordinate~Coordinate|module:ol/pixel~Pixel} return coordinate so that operations can be
|
||||
* chained together.
|
||||
*/
|
||||
export function apply(transform, coordinate) {
|
||||
|
||||
Reference in New Issue
Block a user