-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Snap to layer algorithm accepts a mode parameter
With a new option to prefer to snap to closest point on geometry. The old behaviour was to prefer to snap to nodes, even if a node was further from the input geometry than a segment. The new option allows you to snap geometries to the closest point, regardless of whether it's a node or segment.
- Loading branch information
1 parent
983fe24
commit 8acc286
Showing
11 changed files
with
369 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
python/plugins/processing/tests/testdata/expected/snap_point_to_lines_prefer_closest.gfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<GMLFeatureClassList> | ||
<GMLFeatureClass> | ||
<Name>snap_point_to_lines_prefer_closest</Name> | ||
<ElementPath>snap_point_to_lines_prefer_closest</ElementPath> | ||
<!--POINT--> | ||
<GeometryType>1</GeometryType> | ||
<SRSName>EPSG:4326</SRSName> | ||
<DatasetSpecificInfo> | ||
<FeatureCount>9</FeatureCount> | ||
<ExtentXMin>0.20114</ExtentXMin> | ||
<ExtentXMax>7.97127</ExtentXMax> | ||
<ExtentYMin>-4.82759</ExtentYMin> | ||
<ExtentYMax>2.74139</ExtentYMax> | ||
</DatasetSpecificInfo> | ||
</GMLFeatureClass> | ||
</GMLFeatureClassList> |
59 changes: 59 additions & 0 deletions
59
python/plugins/processing/tests/testdata/expected/snap_point_to_lines_prefer_closest.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ogr:FeatureCollection | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="" | ||
xmlns:ogr="http://ogr.maptools.org/" | ||
xmlns:gml="http://www.opengis.net/gml"> | ||
<gml:boundedBy> | ||
<gml:Box> | ||
<gml:coord><gml:X>0.201140250855188</gml:X><gml:Y>-4.827594070695552</gml:Y></gml:coord> | ||
<gml:coord><gml:X>7.971265678449257</gml:X><gml:Y>2.74139110604333</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.0"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.1"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.0,2.74139110604333</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.2"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.3"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.4"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.683922462941847,1.0</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.5"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.201140250855188,-4.827594070695552</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.6"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.971265678449257,0.609122006841505</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.7"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.456898517673889,-1.543101482326111</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_closest fid="points.8"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.220296465222349,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_closest> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
16 changes: 16 additions & 0 deletions
16
python/plugins/processing/tests/testdata/expected/snap_point_to_lines_prefer_nodes.gfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<GMLFeatureClassList> | ||
<GMLFeatureClass> | ||
<Name>snap_point_to_lines_prefer_nodes</Name> | ||
<ElementPath>snap_point_to_lines_prefer_nodes</ElementPath> | ||
<!--POINT--> | ||
<GeometryType>1</GeometryType> | ||
<SRSName>EPSG:4326</SRSName> | ||
<DatasetSpecificInfo> | ||
<FeatureCount>9</FeatureCount> | ||
<ExtentXMin>0.20114</ExtentXMin> | ||
<ExtentXMax>7.97127</ExtentXMax> | ||
<ExtentYMin>-4.82759</ExtentYMin> | ||
<ExtentYMax>3.00000</ExtentYMax> | ||
</DatasetSpecificInfo> | ||
</GMLFeatureClass> | ||
</GMLFeatureClassList> |
59 changes: 59 additions & 0 deletions
59
python/plugins/processing/tests/testdata/expected/snap_point_to_lines_prefer_nodes.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ogr:FeatureCollection | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="" | ||
xmlns:ogr="http://ogr.maptools.org/" | ||
xmlns:gml="http://www.opengis.net/gml"> | ||
<gml:boundedBy> | ||
<gml:Box> | ||
<gml:coord><gml:X>0.201140250855188</gml:X><gml:Y>-4.827594070695552</gml:Y></gml:coord> | ||
<gml:coord><gml:X>7.971265678449257</gml:X><gml:Y>3</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.0"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.1"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.2"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.3"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.4"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.5"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.201140250855188,-4.827594070695552</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.6"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.971265678449257,0.609122006841505</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.7"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.456898517673889,-1.543101482326111</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:snap_point_to_lines_prefer_nodes fid="points.8"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
</ogr:snap_point_to_lines_prefer_nodes> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.