Skip to content

Commit

Permalink
Add second reference layer for topocolor algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 5, 2017
1 parent 9968962 commit c2559d8
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 3 deletions.
Expand Up @@ -41,7 +41,7 @@
<ogr:right>8.23935</ogr:right>
<ogr:bottom>-3.11331</ogr:bottom>
<ogr:id>11</ogr:id>
<ogr:color_id>5</ogr:color_id>
<ogr:color_id>4</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
Expand All @@ -52,7 +52,7 @@
<ogr:right>8.23935</ogr:right>
<ogr:bottom>-6.11331</ogr:bottom>
<ogr:id>12</ogr:id>
<ogr:color_id>4</ogr:color_id>
<ogr:color_id>5</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
Expand Down
@@ -0,0 +1,46 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>topocolor_polys</Name>
<ElementPath>topocolor_polys</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>11</FeatureCount>
<ExtentXMin>-0.76065</ExtentXMin>
<ExtentXMax>14.23935</ExtentXMax>
<ExtentYMin>-6.11331</ExtentYMin>
<ExtentYMax>5.88669</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>left</Name>
<ElementPath>left</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>top</Name>
<ElementPath>top</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>right</Name>
<ElementPath>right</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>bottom</Name>
<ElementPath>bottom</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>id</Name>
<ElementPath>id</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>color_id</Name>
<ElementPath>color_id</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
133 changes: 133 additions & 0 deletions python/plugins/processing/tests/testdata/expected/topocolor_polys2.gml
@@ -0,0 +1,133 @@
<?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.760650357995228</gml:X><gml:Y>-6.11330548926014</gml:Y></gml:coord>
<gml:coord><gml:X>14.2393496420048</gml:X><gml:Y>5.88669451073986</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-0.760650357995228,-0.113305489260142 2.23934964200477,-0.113305489260142 2.23934964200477,-3.11330548926014 -0.760650357995228,-3.11330548926014 -0.760650357995228,-0.113305489260142</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>-0.76065</ogr:left>
<ogr:top>-0.11331</ogr:top>
<ogr:right>2.23935</ogr:right>
<ogr:bottom>-3.11331</ogr:bottom>
<ogr:id>3</ogr:id>
<ogr:color_id>1</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-0.760650357995228,-3.11330548926014 2.23934964200477,-3.11330548926014 2.23934964200477,-6.11330548926014 -0.760650357995228,-6.11330548926014 -0.760650357995228,-3.11330548926014</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>-0.76065</ogr:left>
<ogr:top>-3.11331</ogr:top>
<ogr:right>2.23935</ogr:right>
<ogr:bottom>-6.11331</ogr:bottom>
<ogr:id>4</ogr:id>
<ogr:color_id>3</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.23934964200477,-0.113305489260142 8.23934964200477,-0.113305489260142 8.23934964200477,-3.11330548926014 5.23934964200477,-3.11330548926014 5.23934964200477,-0.113305489260142</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>5.23935</ogr:left>
<ogr:top>-0.11331</ogr:top>
<ogr:right>8.23935</ogr:right>
<ogr:bottom>-3.11331</ogr:bottom>
<ogr:id>11</ogr:id>
<ogr:color_id>5</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.23934964200477,-3.11330548926014 8.23934964200477,-3.11330548926014 8.23934964200477,-6.11330548926014 5.23934964200477,-6.11330548926014 5.23934964200477,-3.11330548926014</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>5.23935</ogr:left>
<ogr:top>-3.11331</ogr:top>
<ogr:right>8.23935</ogr:right>
<ogr:bottom>-6.11331</ogr:bottom>
<ogr:id>12</ogr:id>
<ogr:color_id>4</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>8.23934964200477,-3.11330548926014 11.2393496420048,-3.11330548926014 11.2393496420048,-6.11330548926014 8.23934964200477,-6.11330548926014 8.23934964200477,-3.11330548926014</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>8.23935</ogr:left>
<ogr:top>-3.11331</ogr:top>
<ogr:right>11.23935</ogr:right>
<ogr:bottom>-6.11331</ogr:bottom>
<ogr:id>16</ogr:id>
<ogr:color_id>3</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>11.2393496420048,-0.113305489260142 14.2393496420048,-0.113305489260142 14.2393496420048,-3.11330548926014 11.2393496420048,-3.11330548926014 11.2393496420048,-0.113305489260142</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>11.23935</ogr:left>
<ogr:top>-0.11331</ogr:top>
<ogr:right>14.23935</ogr:right>
<ogr:bottom>-3.11331</ogr:bottom>
<ogr:id>19</ogr:id>
<ogr:color_id>2</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.6">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>11.2393496420048,-3.11330548926014 14.2393496420048,-3.11330548926014 14.2393496420048,-6.11330548926014 11.2393496420048,-6.11330548926014 11.2393496420048,-3.11330548926014</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>11.23935</ogr:left>
<ogr:top>-3.11331</ogr:top>
<ogr:right>14.23935</ogr:right>
<ogr:bottom>-6.11331</ogr:bottom>
<ogr:id>20</ogr:id>
<ogr:color_id>5</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.7">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2.23934964200477,5.88669451073986 5.23934964200477,5.88669451073986 5.23934964200477,2.88669451073986 2.23934964200477,2.88669451073986 2.23934964200477,-0.113305489260142 -0.760650357995228,-0.113305489260142 -0.760650357995228,2.88669451073986 -0.760650357995228,5.88669451073986 2.23934964200477,5.88669451073986</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>2.23935</ogr:left>
<ogr:top>5.88669</ogr:top>
<ogr:right>5.23935</ogr:right>
<ogr:bottom>2.88669</ogr:bottom>
<ogr:id>5</ogr:id>
<ogr:color_id>3</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.8">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.23934964200477,2.88669451073986 8.23934964200477,2.88669451073986 11.2393496420048,2.88669451073986 11.2393496420048,-0.113305489260142 11.2393496420048,-3.11330548926014 8.23934964200477,-3.11330548926014 8.23934964200477,-0.113305489260142 5.23934964200477,-0.113305489260142 5.23934964200477,2.88669451073986</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>5.23935</ogr:left>
<ogr:top>2.88669</ogr:top>
<ogr:right>8.23935</ogr:right>
<ogr:id>10</ogr:id>
<ogr:color_id>1</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.9">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2.23934964200477,2.88669451073986 5.23934964200477,2.88669451073986 5.23934964200477,-0.113305489260142 5.23934964200477,-3.11330548926014 5.23934964200477,-6.11330548926014 2.23934964200477,-6.11330548926014 2.23934964200477,-3.11330548926014 2.23934964200477,-0.113305489260142 2.23934964200477,2.88669451073986</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>2.23935</ogr:left>
<ogr:top>2.88669</ogr:top>
<ogr:right>5.23935</ogr:right>
<ogr:id>6</ogr:id>
<ogr:color_id>2</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:topocolor_polys fid="adjacent_polys.10">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.23934964200477,5.88669451073986 8.23934964200477,5.88669451073986 11.2393496420048,5.88669451073986 14.2393496420048,5.88669451073986 14.2393496420048,2.88669451073986 14.2393496420048,-0.113305489260142 11.2393496420048,-0.113305489260142 11.2393496420048,2.88669451073986 8.23934964200477,2.88669451073986 5.23934964200477,2.88669451073986 5.23934964200477,5.88669451073986</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:left>5.23935</ogr:left>
<ogr:top>5.88669</ogr:top>
<ogr:right>8.23935</ogr:right>
<ogr:bottom>2.88669</ogr:bottom>
<ogr:id>9</ogr:id>
<ogr:color_id>4</ogr:color_id>
</ogr:topocolor_polys>
</gml:featureMember>
</ogr:FeatureCollection>
Expand Up @@ -2614,8 +2614,10 @@ tests:
MIN_COLORS: 4
results:
OUTPUT:
name: expected/topocolor_polys.gml
type: vector
name:
- expected/topocolor_polys.gml
- expected/topocolor_polys2.gml

- algorithm: qgis:topologicalcoloring
name: Topological coloring w/ min distance
Expand Down

0 comments on commit c2559d8

Please sign in to comment.