Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Port Hub Distance (points) to new API
Improvements: - handle different CRS between points and hubs - add unit test
- Loading branch information
1 parent
0930e18
commit fc1746e
Showing
7 changed files
with
260 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
python/plugins/processing/tests/testdata/custom/hub_points.gfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<GMLFeatureClassList> | ||
<GMLFeatureClass> | ||
<Name>hub_points</Name> | ||
<ElementPath>hub_points</ElementPath> | ||
<!--POINT--> | ||
<GeometryType>1</GeometryType> | ||
<SRSName>EPSG:4326</SRSName> | ||
<DatasetSpecificInfo> | ||
<FeatureCount>3</FeatureCount> | ||
<ExtentXMin>1.34481</ExtentXMin> | ||
<ExtentXMax>6.29897</ExtentXMax> | ||
<ExtentYMin>-1.25947</ExtentYMin> | ||
<ExtentYMax>2.27221</ExtentYMax> | ||
</DatasetSpecificInfo> | ||
<PropertyDefn> | ||
<Name>name</Name> | ||
<ElementPath>name</ElementPath> | ||
<Type>String</Type> | ||
<Width>6</Width> | ||
</PropertyDefn> | ||
</GMLFeatureClass> | ||
</GMLFeatureClassList> |
32 changes: 32 additions & 0 deletions
32
python/plugins/processing/tests/testdata/custom/hub_points.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?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_points.xsd" | ||
xmlns:ogr="http://ogr.maptools.org/" | ||
xmlns:gml="http://www.opengis.net/gml"> | ||
<gml:boundedBy> | ||
<gml:Box> | ||
<gml:coord><gml:X>1.344807662693645</gml:X><gml:Y>-1.259467184083282</gml:Y></gml:coord> | ||
<gml:coord><gml:X>6.298968246635251</gml:X><gml:Y>2.272211648033507</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:hub_points fid="hub_points.0"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.34480766269365,-1.25946718408328</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:name>point1</ogr:name> | ||
</ogr:hub_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_points fid="hub_points.1"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>6.29896824663525,0.138489020296281</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:name>point2</ogr:name> | ||
</ogr:hub_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_points fid="hub_points.2"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3.12290985247467,2.27221164803351</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:name>point3</ogr:name> | ||
</ogr:hub_points> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
37 changes: 37 additions & 0 deletions
37
python/plugins/processing/tests/testdata/expected/hub_distance_points.gfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<GMLFeatureClassList> | ||
<GMLFeatureClass> | ||
<Name>hub_distance_points</Name> | ||
<ElementPath>hub_distance_points</ElementPath> | ||
<!--POINT--> | ||
<GeometryType>1</GeometryType> | ||
<SRSName>EPSG:4326</SRSName> | ||
<DatasetSpecificInfo> | ||
<FeatureCount>9</FeatureCount> | ||
<ExtentXMin>0.00000</ExtentXMin> | ||
<ExtentXMax>8.00000</ExtentXMax> | ||
<ExtentYMin>-5.00000</ExtentYMin> | ||
<ExtentYMax>3.00000</ExtentYMax> | ||
</DatasetSpecificInfo> | ||
<PropertyDefn> | ||
<Name>id</Name> | ||
<ElementPath>id</ElementPath> | ||
<Type>Integer</Type> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>id2</Name> | ||
<ElementPath>id2</ElementPath> | ||
<Type>Integer</Type> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>HubName</Name> | ||
<ElementPath>HubName</ElementPath> | ||
<Type>String</Type> | ||
<Width>6</Width> | ||
</PropertyDefn> | ||
<PropertyDefn> | ||
<Name>HubDist</Name> | ||
<ElementPath>HubDist</ElementPath> | ||
<Type>Real</Type> | ||
</PropertyDefn> | ||
</GMLFeatureClass> | ||
</GMLFeatureClassList> |
95 changes: 95 additions & 0 deletions
95
python/plugins/processing/tests/testdata/expected/hub_distance_points.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ogr:FeatureCollection | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="" | ||
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:coord> | ||
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y></gml:coord> | ||
</gml:Box> | ||
</gml:boundedBy> | ||
|
||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.0"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>1</ogr:id> | ||
<ogr:id2>2</ogr:id2> | ||
<ogr:HubName>point1</ogr:HubName> | ||
<ogr:HubDist>254434.675423572</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.1"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>2</ogr:id> | ||
<ogr:id2>1</ogr:id2> | ||
<ogr:HubName>point3</ogr:HubName> | ||
<ogr:HubDist>82164.2455422206</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.2"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>3</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:HubName>point3</ogr:HubName> | ||
<ogr:HubDist>128622.227687308</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.3"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,2</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>4</ogr:id> | ||
<ogr:id2>2</ogr:id2> | ||
<ogr:HubName>point3</ogr:HubName> | ||
<ogr:HubDist>211142.486929284</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.4"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4,1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>5</ogr:id> | ||
<ogr:id2>1</ogr:id2> | ||
<ogr:HubName>point3</ogr:HubName> | ||
<ogr:HubDist>172016.876891364</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.5"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-5</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>6</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:HubName>point1</ogr:HubName> | ||
<ogr:HubDist>442487.532089586</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.6"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>7</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:HubName>point2</ogr:HubName> | ||
<ogr:HubDist>227856.24000978</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.7"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>8</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:HubName>point2</ogr:HubName> | ||
<ogr:HubDist>148835.564980152</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
<gml:featureMember> | ||
<ogr:hub_distance_points fid="points.8"> | ||
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-1</gml:coordinates></gml:Point></ogr:geometryProperty> | ||
<ogr:id>9</ogr:id> | ||
<ogr:id2>0</ogr:id2> | ||
<ogr:HubName>point1</ogr:HubName> | ||
<ogr:HubDist>152464.26003518</ogr:HubDist> | ||
</ogr:hub_distance_points> | ||
</gml:featureMember> | ||
</ogr:FeatureCollection> |
Oops, something went wrong.