UNPKG

ole

Version:

OpenLayers Editor

179 lines (178 loc) 6.58 kB
export default CadControl; /** * Control with snapping functionality for geometry alignment. * @extends {Control} * @alias ole.CadControl */ declare class CadControl extends Control { /** * @param {Object} [options] Tool options. * @param {Function} [options.drawCustomSnapLines] Allow to draw more snapping lines using selected coordinates. * @param {Function} [options.filter] Returns an array containing the features * to include for CAD (takes the source as a single argument). * @param {Function} [options.extentFilter] An optional spatial filter for the features to snap with. Returns an ol.Extent which will be used by the source.getFeaturesinExtent method. * @param {Function} [options.lineFilter] An optional filter for the generated snapping lines * array (takes the lines and cursor coordinate as arguments and returns the new line array) * @param {Number} [options.nbClosestFeatures] Number of features to use for snapping (closest first). Default is 5. * @param {Number} [options.snapTolerance] Snap tolerance in pixel * for snap lines. Default is 10. * @param {Boolean} [options.showSnapLines] Whether to show * snap lines (default is true). * @param {Boolean} [options.showSnapPoints] Whether to show * snap points around the closest feature. * @param {Boolean} [options.showOrthoLines] Whether to show * snap lines that arae perpendicular to segment (default is true). * @param {Boolean} [options.showSegmentLines] Whether to show * snap lines that extends a segment (default is true). * @param {Boolean} [options.showVerticalAndHorizontalLines] Whether to show vertical * and horizontal lines for each snappable point (default is true). * @param {Boolean} [options.snapLinesOrder] Define order of display of snap lines, * must be an array containing the following values 'ortho', 'segment', 'vh'. Default is ['ortho', 'segment', 'vh', 'custom']. * @param {Number} [options.snapPointDist] Distance of the * snap points (default is 30). * @param {Boolean} [options.useMapUnits] Whether to use map units * as measurement for point snapping. Default is false (pixel are used). * @param {ol.VectorSource} [options.source] The vector source to retrieve the snappable features from. * @param {ol.style.Style.StyleLike} [options.snapStyle] Style used for the snap layer. * @param {ol.style.Style.StyleLike} [options.linesStyle] Style used for the lines layer. * */ constructor(options?: { drawCustomSnapLines?: Function | undefined; filter?: Function | undefined; extentFilter?: Function | undefined; lineFilter?: Function | undefined; nbClosestFeatures?: number | undefined; snapTolerance?: number | undefined; showSnapLines?: boolean | undefined; showSnapPoints?: boolean | undefined; showOrthoLines?: boolean | undefined; showSegmentLines?: boolean | undefined; showVerticalAndHorizontalLines?: boolean | undefined; snapLinesOrder?: boolean | undefined; snapPointDist?: number | undefined; useMapUnits?: boolean | undefined; source?: any; snapStyle?: any; linesStyle?: any; } | undefined); /** * Interaction for handling move events. * @type {ol.interaction.Pointer} * @private */ private pointerInteraction; /** * Layer for drawing snapping geometries. * @type {ol.layer.Vector} * @private */ private snapLayer; /** * Layer for colored lines indicating * intersection point between snapping lines. * @type {ol.layer.Vector} * @private */ private linesLayer; /** * Function to draw more snapping lines. * @type {Function} * @private */ private drawCustomSnapLines; /** * Number of features to use for snapping (closest first). Default is 5. * @type {Number} * @private */ private nbClosestFeatures; /** * Snap tolerance in pixel. * @type {Number} * @private */ private snapTolerance; /** * Filter the features to snap with. * @type {Function} * @private */ private filter; /** * Filter the features spatially. */ extentFilter: Function; /** * Filter the generated line list */ lineFilter: Function | undefined; /** * Interaction for snapping * @type {ol.interaction.Snap} * @private */ private snapInteraction; handleInteractionAdd(evt: any): void; /** * @inheritdoc */ getDialogTemplate(): string; /** * @inheritdoc */ setMap(map: any): void; /** * Handle move event. * @private * @param {ol.MapBrowserEvent} evt Move event. */ private onMove; /** * Returns a list of the {num} closest features * to a given coordinate. * @private * @param {ol.Coordinate} coordinate Coordinate. * @param {Number} nbFeatures Number of features to search. * @returns {Array.<ol.Feature>} List of closest features. */ private getClosestFeatures; /** * Returns an extent array, considers the map rotation. * @private * @param {ol.Geometry} geometry An OL geometry. * @returns {Array.<number>} extent array. */ private getRotatedExtent; getVerticalAndHorizontalLines(coordinate: any, snapCoords: any): Feature<LineString>[]; /** * For each segment, we calculate lines that extends it. */ getSegmentLines(coordinate: any, snapCoords: any, snapCoordsBefore: any): Feature<LineString>[]; /** * For each segment, we calculate lines that are perpendicular. */ getOrthoLines(coordinate: any, snapCoords: any, snapCoordsBefore: any): any[]; /** * Draws snap lines by building the extent for * a pair of features. * @private * @param {ol.Coordinate} coordinate Mouse pointer coordinate. * @param {Array.<ol.Feature>} features List of features. */ private drawSnapLines; /** * Adds snap points to the snapping layer. * @private * @param {ol.Coordinate} coordinate cursor coordinate. * @param {ol.eaturee} feature Feature to draw the snap points for. */ private drawSnapPoints; /** * @inheritdoc */ deactivate(silent: any): void; } import Control from './control'; import { LineString } from 'ol/geom'; import Feature from 'ol/Feature';