Skip to content

Commit 82f4a82

Browse files
committedAug 10, 2016
[FEATURE][processing] New algorithm for offsetting lines
1 parent 7ee55a7 commit 82f4a82

12 files changed

+462
-1
lines changed
 

‎python/plugins/processing/algs/help/qgis.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ qgis:numberofuniquevaluesinclasses: >
257257

258258
The resulting layer contains the same features as the input layer, but with an additional attribute containing the count of unique values for that class.
259259

260+
qgis:offsetline: >
261+
This algorithm offsets lines by a specified distance. Positive distances will offset lines to the left, and negative distances will offset to the right of lines.
262+
263+
The segments parameter controls the number of line segments to use to approximate a quarter circle when creating rounded offsets.
264+
265+
The join style parameter specifies whether round, mitre or beveled joins should be used when offseting corners in a line.
266+
267+
The mitre limit parameter is only applicable for mitre join styles, and controls the maximum distance from the offset curve to use when creating a mitred join.
268+
260269
qgis:orientedminimumboundingbox: >
261270
This algorithm takes a vector layer and generate a new one with the minimum rectangle that covers all the input features.
262271

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
OffsetLine.py
6+
--------------
7+
Date : July 2016
8+
Copyright : (C) 2016 by Nyall Dawson
9+
Email : nyall dot dawson at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Nyall Dawson'
21+
__date__ = 'July 2016'
22+
__copyright__ = '(C) 2016, Nyall Dawson'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive323
25+
26+
__revision__ = '$Format:%H$'
27+
28+
import os
29+
30+
from qgis.core import QgsGeometry, QgsWkbTypes
31+
32+
from qgis.PyQt.QtGui import QIcon
33+
34+
from processing.core.GeoAlgorithm import GeoAlgorithm
35+
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
36+
from processing.core.parameters import ParameterVector, ParameterSelection, ParameterNumber
37+
from processing.core.outputs import OutputVector
38+
from processing.tools import dataobjects, vector
39+
40+
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
41+
42+
43+
class OffsetLine(GeoAlgorithm):
44+
45+
INPUT_LAYER = 'INPUT_LAYER'
46+
OUTPUT_LAYER = 'OUTPUT_LAYER'
47+
DISTANCE = 'DISTANCE'
48+
SEGMENTS = 'SEGMENTS'
49+
JOIN_STYLE = 'JOIN_STYLE'
50+
MITRE_LIMIT = 'MITRE_LIMIT'
51+
52+
def defineCharacteristics(self):
53+
self.name, self.i18n_name = self.trAlgorithm('Offset line')
54+
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools')
55+
56+
self.addParameter(ParameterVector(self.INPUT_LAYER,
57+
self.tr('Input layer'), [ParameterVector.VECTOR_TYPE_LINE]))
58+
self.addParameter(ParameterNumber(self.DISTANCE,
59+
self.tr('Distance'), default=10.0))
60+
self.addParameter(ParameterNumber(self.SEGMENTS,
61+
self.tr('Segments'), 1, default=8))
62+
self.join_styles = [self.tr('Round'),
63+
'Mitre',
64+
'Bevel']
65+
self.addParameter(ParameterSelection(
66+
self.JOIN_STYLE,
67+
self.tr('Join style'),
68+
self.join_styles))
69+
self.addParameter(ParameterNumber(self.MITRE_LIMIT,
70+
self.tr('Mitre limit'), 1, default=2))
71+
72+
self.addOutput(OutputVector(self.OUTPUT_LAYER, self.tr('Offset')))
73+
74+
def processAlgorithm(self, progress):
75+
layer = dataobjects.getObjectFromUri(
76+
self.getParameterValue(self.INPUT_LAYER))
77+
78+
writer = self.getOutputFromName(
79+
self.OUTPUT_LAYER).getVectorWriter(
80+
layer.fields().toList(),
81+
QgsWkbTypes.LineString,
82+
layer.crs())
83+
84+
distance = self.getParameterValue(self.DISTANCE)
85+
segments = int(self.getParameterValue(self.SEGMENTS))
86+
join_style = self.getParameterValue(self.JOIN_STYLE) + 1
87+
miter_limit = self.getParameterValue(self.MITRE_LIMIT)
88+
89+
features = vector.features(layer)
90+
total = 100.0 / len(features)
91+
92+
for current, input_feature in enumerate(features):
93+
output_feature = input_feature
94+
input_geometry = input_feature.geometry()
95+
if input_geometry:
96+
output_geometry = input_geometry.offsetCurve(distance, segments, join_style, miter_limit)
97+
if not output_geometry:
98+
raise GeoAlgorithmExecutionException(
99+
self.tr('Error calculating line offset'))
100+
101+
output_feature.setGeometry(output_geometry)
102+
103+
writer.addFeature(output_feature)
104+
progress.setPercentage(int(current * total))
105+
106+
del writer

‎python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
from .BoundingBox import BoundingBox
151151
from .Boundary import Boundary
152152
from .PointOnSurface import PointOnSurface
153+
from .OffsetLine import OffsetLine
153154

154155
pluginPath = os.path.normpath(os.path.join(
155156
os.path.split(os.path.dirname(__file__))[0], os.pardir))
@@ -202,7 +203,8 @@ def __init__(self):
202203
ReverseLineDirection(), SpatialIndex(), DefineProjection(),
203204
RectanglesOvalsDiamondsVariable(),
204205
RectanglesOvalsDiamondsFixed(), MergeLines(),
205-
BoundingBox(), Boundary(), PointOnSurface()
206+
BoundingBox(), Boundary(), PointOnSurface(),
207+
OffsetLine()
206208
]
207209

208210
if hasMatplotlib:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://ogr.maptools.org/ line_offset_bevel.xsd"
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>-1</gml:X><gml:Y>-2.292893218813453</gml:Y></gml:coord>
10+
<gml:coord><gml:X>10.29289321881345</gml:X><gml:Y>5.707106781186548</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:line_offset_bevel fid="lines.0">
16+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,3 8,3 8.292893218813452,3.707106781186547 10.292893218813452,5.707106781186548</gml:coordinates></gml:LineString></ogr:geometryProperty>
17+
</ogr:line_offset_bevel>
18+
</gml:featureMember>
19+
<gml:featureMember>
20+
<ogr:line_offset_bevel fid="lines.1">
21+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>-1,0 1,0</gml:coordinates></gml:LineString></ogr:geometryProperty>
22+
</ogr:line_offset_bevel>
23+
</gml:featureMember>
24+
<gml:featureMember>
25+
<ogr:line_offset_bevel fid="lines.2">
26+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1,0 1,2 2,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
27+
</ogr:line_offset_bevel>
28+
</gml:featureMember>
29+
<gml:featureMember>
30+
<ogr:line_offset_bevel fid="lines.3">
31+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3,2 5,2</gml:coordinates></gml:LineString></ogr:geometryProperty>
32+
</ogr:line_offset_bevel>
33+
</gml:featureMember>
34+
<gml:featureMember>
35+
<ogr:line_offset_bevel fid="lines.4">
36+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-2 10,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
37+
</ogr:line_offset_bevel>
38+
</gml:featureMember>
39+
<gml:featureMember>
40+
<ogr:line_offset_bevel fid="lines.5">
41+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5.292893218813452,-2.292893218813453 9.292893218813452,1.707106781186547</gml:coordinates></gml:LineString></ogr:geometryProperty>
42+
</ogr:line_offset_bevel>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:line_offset_bevel fid="lines.6">
46+
</ogr:line_offset_bevel>
47+
</gml:featureMember>
48+
</ogr:FeatureCollection>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
4+
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
5+
<xs:complexType name="FeatureCollectionType">
6+
<xs:complexContent>
7+
<xs:extension base="gml:AbstractFeatureCollectionType">
8+
<xs:attribute name="lockId" type="xs:string" use="optional"/>
9+
<xs:attribute name="scope" type="xs:string" use="optional"/>
10+
</xs:extension>
11+
</xs:complexContent>
12+
</xs:complexType>
13+
<xs:element name="line_offset_bevel" type="ogr:line_offset_bevel_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="line_offset_bevel_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
</xs:sequence>
20+
</xs:extension>
21+
</xs:complexContent>
22+
</xs:complexType>
23+
</xs:schema>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://ogr.maptools.org/ line_offset_mitre.xsd"
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>-1</gml:X><gml:Y>-2.292893218813453</gml:Y></gml:coord>
10+
<gml:coord><gml:X>10.29289321881345</gml:X><gml:Y>5.707106781186548</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:line_offset_mitre fid="lines.0">
16+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,3 8,3 8.0,3.414213562373094 10.292893218813452,5.707106781186548</gml:coordinates></gml:LineString></ogr:geometryProperty>
17+
</ogr:line_offset_mitre>
18+
</gml:featureMember>
19+
<gml:featureMember>
20+
<ogr:line_offset_mitre fid="lines.1">
21+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>-1,0 1,0</gml:coordinates></gml:LineString></ogr:geometryProperty>
22+
</ogr:line_offset_mitre>
23+
</gml:featureMember>
24+
<gml:featureMember>
25+
<ogr:line_offset_mitre fid="lines.2">
26+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1,0 1,3 2,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
27+
</ogr:line_offset_mitre>
28+
</gml:featureMember>
29+
<gml:featureMember>
30+
<ogr:line_offset_mitre fid="lines.3">
31+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3,2 5,2</gml:coordinates></gml:LineString></ogr:geometryProperty>
32+
</ogr:line_offset_mitre>
33+
</gml:featureMember>
34+
<gml:featureMember>
35+
<ogr:line_offset_mitre fid="lines.4">
36+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-2 10,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
37+
</ogr:line_offset_mitre>
38+
</gml:featureMember>
39+
<gml:featureMember>
40+
<ogr:line_offset_mitre fid="lines.5">
41+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5.292893218813452,-2.292893218813453 9.292893218813452,1.707106781186547</gml:coordinates></gml:LineString></ogr:geometryProperty>
42+
</ogr:line_offset_mitre>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:line_offset_mitre fid="lines.6">
46+
</ogr:line_offset_mitre>
47+
</gml:featureMember>
48+
</ogr:FeatureCollection>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
4+
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
5+
<xs:complexType name="FeatureCollectionType">
6+
<xs:complexContent>
7+
<xs:extension base="gml:AbstractFeatureCollectionType">
8+
<xs:attribute name="lockId" type="xs:string" use="optional"/>
9+
<xs:attribute name="scope" type="xs:string" use="optional"/>
10+
</xs:extension>
11+
</xs:complexContent>
12+
</xs:complexType>
13+
<xs:element name="line_offset_mitre" type="ogr:line_offset_mitre_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="line_offset_mitre_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
</xs:sequence>
20+
</xs:extension>
21+
</xs:complexContent>
22+
</xs:complexType>
23+
</xs:schema>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://ogr.maptools.org/ line_offset_round_negative.xsd"
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>-1</gml:X><gml:Y>-4</gml:Y></gml:coord>
10+
<gml:coord><gml:X>11.70710678118655</gml:X><gml:Y>4.292893218813452</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:line_offset_round_negative fid="lines.0">
16+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>11.707106781186548,4.292893218813452 10.0,2.585786437626905 10,2 9.98078528040323,1.804909677983872 9.923879532511286,1.61731656763491 9.831469612302543,1.444429766980398 9.707106781186548,1.292893218813453 9.555570233019605,1.168530387697455 9.38268343236509,1.076120467488713 9.195090322016128,1.01921471959677 9,1 6,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
17+
</ogr:line_offset_round_negative>
18+
</gml:featureMember>
19+
<gml:featureMember>
20+
<ogr:line_offset_round_negative fid="lines.1">
21+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1,-2 -1,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
22+
</ogr:line_offset_round_negative>
23+
</gml:featureMember>
24+
<gml:featureMember>
25+
<ogr:line_offset_round_negative fid="lines.2">
26+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>4,3 4,2 3.98078528040323,1.804909677983872 3.923879532511287,1.61731656763491 3.831469612302545,1.444429766980398 3.707106781186547,1.292893218813453 3.555570233019602,1.168530387697455 3.38268343236509,1.076120467488713 3.356009692300209,1.068029076900628 3.195090322016128,1.01921471959677 3,1 3,0</gml:coordinates></gml:LineString></ogr:geometryProperty>
27+
</ogr:line_offset_round_negative>
28+
</gml:featureMember>
29+
<gml:featureMember>
30+
<ogr:line_offset_round_negative fid="lines.3">
31+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5,0 3,0</gml:coordinates></gml:LineString></ogr:geometryProperty>
32+
</ogr:line_offset_round_negative>
33+
</gml:featureMember>
34+
<gml:featureMember>
35+
<ogr:line_offset_round_negative fid="lines.4">
36+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10,-4 7,-4</gml:coordinates></gml:LineString></ogr:geometryProperty>
37+
</ogr:line_offset_round_negative>
38+
</gml:featureMember>
39+
<gml:featureMember>
40+
<ogr:line_offset_round_negative fid="lines.5">
41+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>10.707106781186548,0.292893218813453 6.707106781186548,-3.707106781186547</gml:coordinates></gml:LineString></ogr:geometryProperty>
42+
</ogr:line_offset_round_negative>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:line_offset_round_negative fid="lines.6">
46+
</ogr:line_offset_round_negative>
47+
</gml:featureMember>
48+
</ogr:FeatureCollection>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
4+
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
5+
<xs:complexType name="FeatureCollectionType">
6+
<xs:complexContent>
7+
<xs:extension base="gml:AbstractFeatureCollectionType">
8+
<xs:attribute name="lockId" type="xs:string" use="optional"/>
9+
<xs:attribute name="scope" type="xs:string" use="optional"/>
10+
</xs:extension>
11+
</xs:complexContent>
12+
</xs:complexType>
13+
<xs:element name="line_offset_round_negative" type="ogr:line_offset_round_negative_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="line_offset_round_negative_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
</xs:sequence>
20+
</xs:extension>
21+
</xs:complexContent>
22+
</xs:complexType>
23+
</xs:schema>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://ogr.maptools.org/ line_offset_round_positive.xsd"
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>-1</gml:X><gml:Y>-2.292893218813453</gml:Y></gml:coord>
10+
<gml:coord><gml:X>10.29289321881345</gml:X><gml:Y>5.707106781186548</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:line_offset_round_positive fid="lines.0">
16+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,3 8,3 8.01921471959677,3.195090322016128 8.076120467488714,3.38268343236509 8.168530387697455,3.555570233019602 8.292893218813452,3.707106781186547 10.292893218813452,5.707106781186548</gml:coordinates></gml:LineString></ogr:geometryProperty>
17+
</ogr:line_offset_round_positive>
18+
</gml:featureMember>
19+
<gml:featureMember>
20+
<ogr:line_offset_round_positive fid="lines.1">
21+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>-1,0 1,0</gml:coordinates></gml:LineString></ogr:geometryProperty>
22+
</ogr:line_offset_round_positive>
23+
</gml:featureMember>
24+
<gml:featureMember>
25+
<ogr:line_offset_round_positive fid="lines.2">
26+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>1,0 1,2 1.01921471959677,2.195090322016128 1.076120467488713,2.38268343236509 1.168530387697455,2.555570233019602 1.292893218813453,2.707106781186547 1.444429766980398,2.831469612302545 1.61731656763491,2.923879532511287 1.804909677983872,2.98078528040323 2,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
27+
</ogr:line_offset_round_positive>
28+
</gml:featureMember>
29+
<gml:featureMember>
30+
<ogr:line_offset_round_positive fid="lines.3">
31+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3,2 5,2</gml:coordinates></gml:LineString></ogr:geometryProperty>
32+
</ogr:line_offset_round_positive>
33+
</gml:featureMember>
34+
<gml:featureMember>
35+
<ogr:line_offset_round_positive fid="lines.4">
36+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-2 10,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
37+
</ogr:line_offset_round_positive>
38+
</gml:featureMember>
39+
<gml:featureMember>
40+
<ogr:line_offset_round_positive fid="lines.5">
41+
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5.292893218813452,-2.292893218813453 9.292893218813452,1.707106781186547</gml:coordinates></gml:LineString></ogr:geometryProperty>
42+
</ogr:line_offset_round_positive>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:line_offset_round_positive fid="lines.6">
46+
</ogr:line_offset_round_positive>
47+
</gml:featureMember>
48+
</ogr:FeatureCollection>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
4+
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
5+
<xs:complexType name="FeatureCollectionType">
6+
<xs:complexContent>
7+
<xs:extension base="gml:AbstractFeatureCollectionType">
8+
<xs:attribute name="lockId" type="xs:string" use="optional"/>
9+
<xs:attribute name="scope" type="xs:string" use="optional"/>
10+
</xs:extension>
11+
</xs:complexContent>
12+
</xs:complexType>
13+
<xs:element name="line_offset_round_positive" type="ogr:line_offset_round_positive_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="line_offset_round_positive_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
</xs:sequence>
20+
</xs:extension>
21+
</xs:complexContent>
22+
</xs:complexType>
23+
</xs:schema>

‎python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,63 @@ tests:
582582
OUTPUT_LAYER:
583583
name: expected/point_on_line.gml
584584
type: vector
585+
586+
- algorithm: qgis:offsetline
587+
name: Offset line positive
588+
params:
589+
DISTANCE: 1.0
590+
INPUT_LAYER:
591+
name: lines.gml
592+
type: vector
593+
JOIN_STYLE: '0'
594+
MITRE_LIMIT: 2
595+
SEGMENTS: 8
596+
results:
597+
OUTPUT_LAYER:
598+
name: expected/line_offset_round_positive.gml
599+
type: vector
600+
601+
- algorithm: qgis:offsetline
602+
name: Offset line negative
603+
params:
604+
DISTANCE: -1.0
605+
INPUT_LAYER:
606+
name: lines.gml
607+
type: vector
608+
JOIN_STYLE: '0'
609+
MITRE_LIMIT: 2
610+
SEGMENTS: 8
611+
results:
612+
OUTPUT_LAYER:
613+
name: expected/line_offset_round_negative.gml
614+
type: vector
615+
616+
- algorithm: qgis:offsetline
617+
name: Offset line mitre
618+
params:
619+
DISTANCE: 1.0
620+
INPUT_LAYER:
621+
name: lines.gml
622+
type: vector
623+
JOIN_STYLE: '1'
624+
MITRE_LIMIT: 2
625+
SEGMENTS: 4
626+
results:
627+
OUTPUT_LAYER:
628+
name: expected/line_offset_mitre.gml
629+
type: vector
630+
631+
- algorithm: qgis:offsetline
632+
name: Offset line bevel
633+
params:
634+
DISTANCE: 1.0
635+
INPUT_LAYER:
636+
name: lines.gml
637+
type: vector
638+
JOIN_STYLE: '2'
639+
MITRE_LIMIT: 2
640+
SEGMENTS: 8
641+
results:
642+
OUTPUT_LAYER:
643+
name: expected/line_offset_bevel.gml
644+
type: vector

0 commit comments

Comments
 (0)
Please sign in to comment.