@@ -36,6 +36,8 @@ class CadControl extends Control {
36
36
* @param {Function } [options.drawCustomSnapLines] Allow to draw more snapping lines using selected corrdinaites.
37
37
* @param {Function } [options.filter] Returns an array containing the features
38
38
* to include for CAD (takes the source as a single argument).
39
+ * @param {Function } [options.lineFilter] An optional filter for the generated snapping lines
40
+ * array (takes the lines and cursor coordinate as arguments and returns the new line array)
39
41
* @param {Number } [options.nbClosestFeatures] Number of features to use for snapping (closest first). Default is 5.
40
42
* @param {Number } [options.snapTolerance] Snap tolerance in pixel
41
43
* for snap lines. Default is 10.
@@ -146,6 +148,11 @@ class CadControl extends Control {
146
148
*/
147
149
this . filter = options . filter || ( ( ) => true ) ;
148
150
151
+ /**
152
+ * Filter the generated line list
153
+ */
154
+ this . lineFilter = options . lineFilter || null ;
155
+
149
156
/**
150
157
* Interaction for snapping
151
158
* @type {ol.interaction.Snap }
@@ -656,7 +663,7 @@ class CadControl extends Control {
656
663
snapLinesOrder,
657
664
} = this . properties ;
658
665
659
- const lines = [ ] ;
666
+ let lines = [ ] ;
660
667
const helpLinesOrdered = [ ] ;
661
668
const helpLines = {
662
669
[ ORTHO_LINE_KEY ] : [ ] ,
@@ -706,6 +713,10 @@ class CadControl extends Control {
706
713
}
707
714
} ) ;
708
715
716
+ if ( typeof this . lineFilter === 'function' ) {
717
+ lines = this . lineFilter ( lines , coordinate ) ;
718
+ }
719
+
709
720
// We snap on intersections of lines (distance < this.snapTolerance) or on all the help lines.
710
721
const intersectFeatures = getIntersectedLinesAndPoint (
711
722
coordinate ,
0 commit comments