Class: CadControl

CadControl(optionsopt)

Control with snapping functionality for geometry alignment.

Constructor

new CadControl(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>
Tool options.
Properties
Name Type Attributes Description
drawCustomSnapLines function <optional>
Allow to draw more snapping lines using selected coordinates.
filter function <optional>
Returns an array containing the features to include for CAD (takes the source as a single argument).
extentFilter function <optional>
An optional spatial filter for the features to snap with. Returns an ol.Extent which will be used by the source.getFeaturesinExtent method.
lineFilter function <optional>
An optional filter for the generated snapping lines array (takes the lines and cursor coordinate as arguments and returns the new line array)
nbClosestFeatures Number <optional>
Number of features to use for snapping (closest first). Default is 5.
snapTolerance Number <optional>
Snap tolerance in pixel for snap lines. Default is 10.
showSnapLines Boolean <optional>
Whether to show snap lines (default is true).
showSnapPoints Boolean <optional>
Whether to show snap points around the closest feature.
showOrthoLines Boolean <optional>
Whether to show snap lines that arae perpendicular to segment (default is true).
showSegmentLines Boolean <optional>
Whether to show snap lines that extends a segment (default is true).
showVerticalAndHorizontalLines Boolean <optional>
Whether to show vertical and horizontal lines for each snappable point (default is true).
snapLinesOrder Boolean <optional>
Define order of display of snap lines, must be an array containing the following values 'ortho', 'segment', 'vh'. Default is ['ortho', 'segment', 'vh', 'custom'].
snapPointDist Number <optional>
Distance of the snap points (default is 30).
useMapUnits Boolean <optional>
Whether to use map units as measurement for point snapping. Default is false (pixel are used).
source ol.VectorSource <optional>
The vector source to retrieve the snappable features from.
snapStyle ol.style.Style.StyleLike <optional>
Style used for the snap layer.
linesStyle ol.style.Style.StyleLike <optional>
Style used for the lines layer.
Source:

Extends

  • Control

Members

(private) drawCustomSnapLines :function

Function to draw more snapping lines.
Type:
  • function
Source:

extentFilter

Filter the features spatially.
Source:

(private) filter :function

Filter the features to snap with.
Type:
  • function
Source:

lineFilter

Filter the generated line list
Source:

(private) linesLayer :ol.layer.Vector

Layer for colored lines indicating intersection point between snapping lines.
Type:
  • ol.layer.Vector
Source:

(private) nbClosestFeatures :Number

Number of features to use for snapping (closest first). Default is 5.
Type:
  • Number
Source:

(private) pointerInteraction :ol.interaction.Pointer

Interaction for handling move events.
Type:
  • ol.interaction.Pointer
Source:

(private) snapInteraction :ol.interaction.Snap

Interaction for snapping
Type:
  • ol.interaction.Snap
Source:

(private) snapLayer :ol.layer.Vector

Layer for drawing snapping geometries.
Type:
  • ol.layer.Vector
Source:

(private) snapTolerance :Number

Snap tolerance in pixel.
Type:
  • Number
Source:

Methods

activate()

Source:

deactivate()

Source:

(private) drawSnapLines(coordinate, features)

Draws snap lines by building the extent for a pair of features.
Parameters:
Name Type Description
coordinate ol.Coordinate Mouse pointer coordinate.
features Array.<ol.Feature> List of features.
Source:

(private) drawSnapPoints(coordinate, feature)

Adds snap points to the snapping layer.
Parameters:
Name Type Description
coordinate ol.Coordinate cursor coordinate.
feature ol.eaturee Feature to draw the snap points for.
Source:

(private) getClosestFeatures(coordinate, nbFeatures) → {Array.<ol.Feature>}

Returns a list of the {num} closest features to a given coordinate.
Parameters:
Name Type Default Description
coordinate ol.Coordinate Coordinate.
nbFeatures Number 1 Number of features to search.
Source:
Returns:
List of closest features.
Type
Array.<ol.Feature>

getDialogTemplate()

Source:

getOrthoLines()

For each segment, we calculate lines that are perpendicular.
Source:

(private) getRotatedExtent(geometry) → {Array.<number>}

Returns an extent array, considers the map rotation.
Parameters:
Name Type Description
geometry ol.Geometry An OL geometry.
Source:
Returns:
extent array.
Type
Array.<number>

getSegmentLines()

For each segment, we calculate lines that extends it.
Source:

(private) onMove(evt)

Handle move event.
Parameters:
Name Type Description
evt ol.MapBrowserEvent Move event.
Source:

setMap()

Source: