Skip to content

Commit

Permalink
Port hub lines algorithm to c++
Browse files Browse the repository at this point in the history
Also:
- optimise a bit
- retain z/m values
- use point on surface for non-point layers, instead of
center of geometry bounding box
  • Loading branch information
nyalldawson committed Oct 12, 2017
1 parent cac171a commit cc19d0a
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 147 deletions.
5 changes: 0 additions & 5 deletions python/plugins/processing/algs/help/qgis.yaml
Expand Up @@ -236,11 +236,6 @@ qgis:generatepointspixelcentroidsalongline:
qgis:generatepointspixelcentroidsinsidepolygons:


qgis:hublines:
This algorithm creates hub and spoke diagrams with lines drawn from points on the Spoke Point layer to matching points in the Hub Point layer.

Determination of which hub goes with each point is based on a match between the Hub ID field on the hub points and the Spoke ID field on the spoke points.

qgis:hypsometriccurves: >
This algorithm computes hypsometric curves for an input Digital Elevation Model. Curves are produced as table files in an output folder specified by the user.

Expand Down
139 changes: 0 additions & 139 deletions python/plugins/processing/algs/qgis/HubLines.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 .Hillshade import Hillshade
from .HubDistanceLines import HubDistanceLines
from .HubDistancePoints import HubDistancePoints
from .HubLines import HubLines
from .HypsometricCurves import HypsometricCurves
from .IdwInterpolation import IdwInterpolation
from .ImportIntoPostGIS import ImportIntoPostGIS
Expand Down Expand Up @@ -216,7 +215,6 @@ def getAlgs(self):
Hillshade(),
HubDistanceLines(),
HubDistancePoints(),
HubLines(),
HypsometricCurves(),
IdwInterpolation(),
ImportIntoPostGIS(),
Expand Down
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ hub_lines_multi_to_z.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>-5</gml:Y><gml:Z>0</gml:Z></gml:coord>
<gml:coord><gml:X>7</gml:X><gml:Y>2</gml:Y><gml:Z>4</gml:Z></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:hub_lines_multi_to_z fid="points.3">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>5,2,0 2,2,2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:d>2</ogr:d>
<ogr:fid_2>points.2</ogr:fid_2>
<ogr:elev>2</ogr:elev>
</ogr:hub_lines_multi_to_z>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_multi_to_z fid="points.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>0,-5,0 1,1,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:d>3</ogr:d>
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:elev>3</ogr:elev>
</ogr:hub_lines_multi_to_z>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_multi_to_z fid="points.7">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>7,-1,0 0,-1,4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:d>4</ogr:d>
<ogr:fid_2>points.8</ogr:fid_2>
<ogr:elev>4</ogr:elev>
</ogr:hub_lines_multi_to_z>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,44 @@
<?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="hub_lines_multi_to_z" type="ogr:hub_lines_multi_to_z_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="hub_lines_multi_to_z_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="d" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="fid_2" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="elev" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ hub_lines_to_poly.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0.5</gml:X><gml:Y>0</gml:Y></gml:coord>
<gml:coord><gml:X>4.672552783109405</gml:X><gml:Y>5.588675623800385</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:hub_lines_to_poly fid="polys.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>0.5,0.5 1,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:name>aa</ogr:name>
<ogr:intval>1</ogr:intval>
<ogr:floatval>44.123456</ogr:floatval>
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:hub_lines_to_poly>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_to_poly fid="polys.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>2.5,5.5 1,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:name>bb</ogr:name>
<ogr:intval>1</ogr:intval>
<ogr:floatval>0.123</ogr:floatval>
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:hub_lines_to_poly>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_to_poly fid="polys.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>4,0 1,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:name>aa</ogr:name>
<ogr:intval>1</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:hub_lines_to_poly>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_to_poly fid="polys.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>2.94337811900192,4.92360844529751 1,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:name>bb</ogr:name>
<ogr:intval>1</ogr:intval>
<ogr:floatval>0.123</ogr:floatval>
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:hub_lines_to_poly>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_to_poly fid="polys.6">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>4.67255278310941,5.32264875239923 1,1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:name>bb</ogr:name>
<ogr:intval>1</ogr:intval>
<ogr:floatval>0.123</ogr:floatval>
<ogr:fid_2>points.0</ogr:fid_2>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:hub_lines_to_poly>
</gml:featureMember>
<gml:featureMember>
<ogr:hub_lines_to_poly fid="polys.8">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>3.12072936660269,5.58867562380038 3,3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:name>bb</ogr:name>
<ogr:intval>2</ogr:intval>
<ogr:floatval>0.123</ogr:floatval>
<ogr:fid_2>points.1</ogr:fid_2>
<ogr:id>2</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:hub_lines_to_poly>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,64 @@
<?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="hub_lines_to_poly" type="ogr:hub_lines_to_poly_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="hub_lines_to_poly_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="name" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="intval" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="floatval" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="fid_2" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="id2" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:totalDigits value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

0 comments on commit cc19d0a

Please sign in to comment.