Skip to content

Commit

Permalink
[processing] Port "Points along geometry" to QgsFeatureBasedAlgorithm
Browse files Browse the repository at this point in the history
(and c++), allow distance/start/end offset to be dynamic, avoid
algorithm "hangs" when inappropriately small (or 0) distances
are used
  • Loading branch information
nyalldawson authored and nirvn committed Jun 12, 2019
1 parent e0eedc5 commit 4ff8429
Show file tree
Hide file tree
Showing 24 changed files with 1,450 additions and 150 deletions.
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/help/qgis.yaml
Expand Up @@ -94,11 +94,6 @@ qgis:creategridlines: >

The top-left point (minX, maxY) is used as the reference point. That means that, at that point, an element is guaranteed to be placed. Unless the width and height of the selected extent is a multiple of the selected spacing, that is not true for the other points that define that extent.

qgis:createpointsalonglines: >
This algorithm creates a points layer, with points distributed along the lines of an input vector layer. the distance between points (measured along the line) is defined as a parameter.

Start and end points can be defined, so the first and last point do not fall on the line first and last node. Start and end points are defined as distances, measured from the first and last nodes of the lines, in the units of the projection used by the lines layer.

qgis:createspatialindex: >
Creates an index to speed up access to the features in a layer based on their spatial location. Support for spatial index creation is dependent on the layer's data provider.

Expand Down
142 changes: 0 additions & 142 deletions python/plugins/processing/algs/qgis/PointsAlongGeometry.py

This file was deleted.

2 changes: 0 additions & 2 deletions python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py
Expand Up @@ -84,7 +84,6 @@
from .NearestNeighbourAnalysis import NearestNeighbourAnalysis
from .Orthogonalize import Orthogonalize
from .PointDistance import PointDistance
from .PointsAlongGeometry import PointsAlongGeometry
from .PointsDisplacement import PointsDisplacement
from .PointsFromLines import PointsFromLines
from .PointsFromPolygons import PointsFromPolygons
Expand Down Expand Up @@ -195,7 +194,6 @@ def getAlgs(self):
NearestNeighbourAnalysis(),
Orthogonalize(),
PointDistance(),
PointsAlongGeometry(),
PointsDisplacement(),
PointsFromLines(),
PointsFromPolygons(),
Expand Down
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ points_along_lines_end_offset.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>2</gml:X><gml:Y>-3</gml:Y></gml:coord>
<gml:coord><gml:X>9</gml:X><gml:Y>3</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6,2</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>0</ogr:distance>
<ogr:angle>90</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,2</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>1</ogr:distance>
<ogr:angle>90</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8,2</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>2</ogr:distance>
<ogr:angle>90</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>9,2</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>3</ogr:distance>
<ogr:angle>45</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>9,3</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>4</ogr:distance>
<ogr:angle>22.5</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,0</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>0</ogr:distance>
<ogr:angle>0</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,1</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>1</ogr:distance>
<ogr:angle>0</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-3</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>0</ogr:distance>
<ogr:angle>90</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6,-3</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>0</ogr:distance>
<ogr:angle>45</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6.70710678118655,-2.29289321881345</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>1</ogr:distance>
<ogr:angle>45</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.41421356237309,-1.58578643762691</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>2</ogr:distance>
<ogr:angle>45</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8.12132034355964,-0.878679656440358</gml:coordinates></gml:Point></ogr:geometryProperty>
<ogr:distance>3</ogr:distance>
<ogr:angle>45</ogr:angle>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines_end_offset fid="lines.6">
<ogr:distance xsi:nil="true"/>
<ogr:angle xsi:nil="true"/>
</ogr:points_along_lines_end_offset>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="points_along_lines_end_offset" type="ogr:points_along_lines_end_offset_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="points_along_lines_end_offset_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="distance" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="angle" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Binary file not shown.
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
@@ -0,0 +1 @@
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]
Binary file not shown.
Binary file not shown.

0 comments on commit 4ff8429

Please sign in to comment.