Skip to content
Permalink
Browse files

Avoid duplicate geometry columns, invalid geometry column name in gda…

…l points along lines alg
  • Loading branch information
nyalldawson committed Aug 15, 2017
1 parent 3d1be95 commit aece517c508671e5e6602ad1ae264c90b63b6d87
@@ -74,6 +74,7 @@ def group(self):
return self.tr('Vector geoprocessing')

def getConsoleCommands(self, parameters, context, feedback):
fields = self.parameterAsSource(parameters, self.INPUT, context).fields()
ogrLayer, layername = self.getOgrCompatibleSource(self.INPUT, parameters, context, feedback)

distance = str(self.parameterAsDouble(parameters, self.DISTANCE, context))
@@ -84,6 +85,13 @@ def getConsoleCommands(self, parameters, context, feedback):
output, format = GdalUtils.ogrConnectionStringAndFormat(outFile, context)
options = self.parameterAsString(parameters, self.OPTIONS, context)

other_fields = []
for f in fields:
if f.name() == geometry:
continue

other_fields.append(f.name())

arguments = []
if format:
arguments.append('-f {}'.format(format))
@@ -94,7 +102,11 @@ def getConsoleCommands(self, parameters, context, feedback):
arguments.append(geometry)
arguments.append(',')
arguments.append(distance)
arguments.append('),*')
arguments.append(')')
arguments.append('AS')
arguments.append(geometry)
arguments.append(',')
arguments.append(','.join(other_fields))
arguments.append('FROM')
arguments.append(layername)
arguments.append('"')
@@ -1,12 +1,12 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>points_along_lines</Name>
<ElementPath>points_along_lines</ElementPath>
<Name>SELECT</Name>
<ElementPath>SELECT</ElementPath>
<!--POINT-->
<GeometryType>1</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>7</FeatureCount>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-0.50000</ExtentXMin>
<ExtentXMax>7.75000</ExtentXMax>
<ExtentYMin>-3.00000</ExtentYMin>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xsi:schemaLocation="http://ogr.maptools.org/ points_along_lines.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
@@ -12,37 +12,33 @@
</gml:boundedBy>

<gml:featureMember>
<ogr:points_along_lines fid="lines.0">
<ogr:SELECT fid="lines.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.70710678118655,2.0</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_along_lines>
</ogr:SELECT>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines fid="lines.1">
<ogr:SELECT fid="lines.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.5,-1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_along_lines>
</ogr:SELECT>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines fid="lines.2">
<ogr:SELECT fid="lines.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,1</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_along_lines>
</ogr:SELECT>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines fid="lines.3">
<ogr:SELECT fid="lines.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.5,1.0</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_along_lines>
</ogr:SELECT>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines fid="lines.4">
<ogr:SELECT fid="lines.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.75,-3.0</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_along_lines>
</ogr:SELECT>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines fid="lines.5">
<ogr:SELECT fid="lines.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-2</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_along_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:points_along_lines fid="lines.6">
</ogr:points_along_lines>
</ogr:SELECT>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -102,6 +102,7 @@ tests:
OUTPUT:
name: expected/gdal/points_along_lines.gml
type: vector
pk: fid
compare:
ignore_crs_check: true

0 comments on commit aece517

Please sign in to comment.
You can’t perform that action at this time.