Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[FEATURE][processing] Add line sinuosity to "Export Geometry Info"
Adds line sinuosity and straight distance to the stats calculated by "Export Geometry Info" Fixes #12376
- Loading branch information
Showing
with
213 additions
and 2 deletions.
- +17 −2 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
- +66 −0 python/plugins/processing/tests/testdata/expected/export_line_info.gml
- +41 −0 python/plugins/processing/tests/testdata/expected/export_line_info.xsd
- +36 −0 python/plugins/processing/tests/testdata/expected/export_multiline_info.gml
- +29 −0 python/plugins/processing/tests/testdata/expected/export_multiline_info.xsd
- +24 −0 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ogr:FeatureCollection | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://ogr.maptools.org/ export_line_info.xsd" | ||
xmlns:ogr="http://ogr.maptools.org/" | ||
xmlns:gml="http://www.opengis.net/gml"> | ||
<gml:boundedBy> | ||
<gml:Box> | ||
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord> | ||
<gml:coord><gml:X>11</gml:X><gml:Y>5</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.0"> | ||
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,2 9,2 9,3 11,5</gml:coordinates></gml:LineString></ogr:geometryProperty> | ||
<ogr:length>6.82842712474619</ogr:length> | ||
<ogr:straightdis>5.8309518948453</ogr:straightdis> | ||
<ogr:sinuosity>1.1710655906427</ogr:sinuosity> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.1"> | ||
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>-1,-1 1,-1</gml:coordinates></gml:LineString></ogr:geometryProperty> | ||
<ogr:length>2</ogr:length> | ||
<ogr:straightdis>2</ogr:straightdis> | ||
<ogr:sinuosity>1</ogr:sinuosity> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.2"> | ||
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>2,0 2,2 3,2 3,3</gml:coordinates></gml:LineString></ogr:geometryProperty> | ||
<ogr:length>4</ogr:length> | ||
<ogr:straightdis>3.16227766016838</ogr:straightdis> | ||
<ogr:sinuosity>1.26491106406735</ogr:sinuosity> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.3"> | ||
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3,1 5,1</gml:coordinates></gml:LineString></ogr:geometryProperty> | ||
<ogr:length>2</ogr:length> | ||
<ogr:straightdis>2</ogr:straightdis> | ||
<ogr:sinuosity>1</ogr:sinuosity> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.4"> | ||
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-3 10,-3</gml:coordinates></gml:LineString></ogr:geometryProperty> | ||
<ogr:length>3</ogr:length> | ||
<ogr:straightdis>3</ogr:straightdis> | ||
<ogr:sinuosity>1</ogr:sinuosity> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.5"> | ||
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,-3 10,1</gml:coordinates></gml:LineString></ogr:geometryProperty> | ||
<ogr:length>5.65685424949238</ogr:length> | ||
<ogr:straightdis>5.65685424949238</ogr:straightdis> | ||
<ogr:sinuosity>1</ogr:sinuosity> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_line_info fid="lines.6"> | ||
</ogr:export_line_info> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
@@ -0,0 +1,41 @@ | ||
<?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="export_line_info" type="ogr:export_line_info_Type" substitutionGroup="gml:_Feature"/> | ||
<xs:complexType name="export_line_info_Type"> | ||
<xs:complexContent> | ||
<xs:extension base="gml:AbstractFeatureType"> | ||
<xs:sequence> | ||
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/> | ||
<xs:element name="length" nillable="true" minOccurs="0" maxOccurs="1"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:decimal"> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="straightdis" nillable="true" minOccurs="0" maxOccurs="1"> | ||
<xs:simpleType> | ||
<xs:restriction base="xs:decimal"> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
</xs:element> | ||
<xs:element name="sinuosity" 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> |
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ogr:FeatureCollection | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://ogr.maptools.org/ export_multiline_info.xsd" | ||
xmlns:ogr="http://ogr.maptools.org/" | ||
xmlns:gml="http://www.opengis.net/gml"> | ||
<gml:boundedBy> | ||
<gml:Box> | ||
<gml:coord><gml:X>-1</gml:X><gml:Y>-1</gml:Y></gml:coord> | ||
<gml:coord><gml:X>5.58042226487524</gml:X><gml:Y>4.119769673704415</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:export_multiline_info fid="lines.1"> | ||
<ogr:geometryProperty><gml:MultiLineString srsName="EPSG:4326"><gml:lineStringMember><gml:LineString><gml:coordinates>-1,-1 1,-1</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></ogr:geometryProperty> | ||
<ogr:length>2</ogr:length> | ||
</ogr:export_multiline_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_multiline_info fid="lines.2"> | ||
<ogr:geometryProperty><gml:MultiLineString srsName="EPSG:4326"><gml:lineStringMember><gml:LineString><gml:coordinates>3,1 5,1</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates>5.02418426103647,2.4147792706334 5,1</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></ogr:geometryProperty> | ||
<ogr:length>3.41498595862145</ogr:length> | ||
</ogr:export_multiline_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_multiline_info fid="lines.3"> | ||
</ogr:export_multiline_info> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:export_multiline_info fid="lines.4"> | ||
<ogr:geometryProperty><gml:MultiLineString srsName="EPSG:4326"><gml:lineStringMember><gml:LineString><gml:coordinates>2,0 2,2 3,2 3,3</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates>2.94433781190019,4.04721689059501 5.4595009596929,4.11976967370441</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates>3,3 5.58042226487524,2.9468330134357</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString></ogr:geometryProperty> | ||
<ogr:length>9.09717929727474</ogr:length> | ||
</ogr:export_multiline_info> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
@@ -0,0 +1,29 @@ | ||
<?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="export_multiline_info" type="ogr:export_multiline_info_Type" substitutionGroup="gml:_Feature"/> | ||
<xs:complexType name="export_multiline_info_Type"> | ||
<xs:complexContent> | ||
<xs:extension base="gml:AbstractFeatureType"> | ||
<xs:sequence> | ||
<xs:element name="geometryProperty" type="gml:MultiLineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/> | ||
<xs:element name="length" 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> |