Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use geojson files instead of sqlite for PAL test suite
It's much more git friendly...
  • Loading branch information
nyalldawson committed Nov 27, 2019
1 parent 2bccde3 commit 175a075
Show file tree
Hide file tree
Showing 25 changed files with 213 additions and 15 deletions.
19 changes: 4 additions & 15 deletions tests/src/python/test_qgspallabeling_base.py
Expand Up @@ -71,7 +71,6 @@ class TestQgsPalLabeling(unittest.TestCase):

_TestDataDir = unitTestDataPath()
_PalDataDir = os.path.join(_TestDataDir, 'labeling')
_PalFeaturesDb = os.path.join(_PalDataDir, 'pal_features_v3.sqlite')
_TestFont = getTestFont() # Roman at 12 pt
""":type: QFont"""
_MapRegistry = None
Expand All @@ -90,12 +89,6 @@ def setUpClass(cls):
cls._Iface = get_iface()
cls._Canvas = cls._Iface.mapCanvas()

# verify that SpatiaLite provider is available
msg = '\nSpatialite provider not found, SKIPPING TEST SUITE'
# noinspection PyArgumentList
res = 'spatialite' in QgsProviderRegistry.instance().providerList()
assert res, msg

cls._TestFunction = ''
cls._TestGroup = ''
cls._TestGroupPrefix = ''
Expand Down Expand Up @@ -160,10 +153,8 @@ def getTestFont(cls):
def loadFeatureLayer(cls, table, chk=False):
if chk and cls._MapRegistry.mapLayersByName(table):
return
uri = QgsDataSourceUri()
uri.setDatabase(cls._PalFeaturesDb)
uri.setDataSource('', table, 'geometry')
vlayer = QgsVectorLayer(uri.uri(), table, 'spatialite')
vlayer = QgsVectorLayer('{}/{}.geojson'.format(cls._PalDataDir, table), table, 'ogr')
assert vlayer.isValid()
# .qml should contain only style for symbology
vlayer.loadNamedStyle(os.path.join(cls._PalDataDir,
'{0}.qml'.format(table)))
Expand All @@ -183,10 +174,8 @@ def loadFeatureLayer(cls, table, chk=False):
@classmethod
def aoiExtent(cls):
"""Area of interest extent, which matches output aspect ratio"""
uri = QgsDataSourceUri()
uri.setDatabase(cls._PalFeaturesDb)
uri.setDataSource('', 'aoi', 'geometry')
aoilayer = QgsVectorLayer(uri.uri(), 'aoi', 'spatialite')
aoilayer = QgsVectorLayer('{}/aoi.geojson'.format(cls._PalDataDir), 'aoi', 'ogr')
assert aoilayer.isValid()
return aoilayer.extent()

@classmethod
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/testdata/labeling/aoi.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "aoi",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "ftype": "single" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 606510.0, 4827130.0 ], [ 612510.0, 4827130.0 ], [ 612510.0, 4823130.0 ], [ 606510.0, 4823130.0 ], [ 606510.0, 4827130.0 ] ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/background.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "background",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 606410.0, 4827230.0 ], [ 612610.0, 4827230.0 ], [ 612610.0, 4823030.0 ], [ 606410.0, 4823030.0 ], [ 606410.0, 4827230.0 ] ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Single lines" }, "geometry": { "type": "LineString", "coordinates": [ [ 612282.318212545476854, 4826234.140458336099982 ], [ 610745.488644124008715, 4825848.293587189167738 ], [ 609258.830247395671904, 4825235.910047871060669 ], [ 608067.917609855532646, 4824335.72664128895849 ], [ 607264.296386997681111, 4823602.060766691341996 ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line_placement_1.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line_placement_1",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Line" }, "geometry": { "type": "LineString", "coordinates": [ [ 607117.534246575203724, 4826577.945205479860306 ], [ 609553.150685028638691, 4824142.328767025843263 ], [ 611725.06849324866198, 4826314.246575245633721 ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line_placement_2.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line_placement_2",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Line" }, "geometry": { "type": "LineString", "coordinates": [ [ 607453.150684931431897, 4823730.0 ], [ 610559.999999931431375, 4823730.0 ], [ 611460.428077493561432, 4826703.506674493663013 ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line_placement_3.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line_placement_3",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Line" }, "geometry": { "type": "LineString", "coordinates": [ [ 607311.340640217182226, 4824518.681955846957862 ], [ 609078.934229813399725, 4824364.978165446780622 ], [ 609757.298244976671413, 4824478.650941438041627 ], [ 610445.459184597362764, 4824406.597502299584448 ], [ 611819.985158607596532, 4824352.169516246765852 ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line_placement_4.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line_placement_4",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Line" }, "geometry": { "type": "LineString", "coordinates": [ [ 607097.746179585345089, 4824810.116741687990725 ], [ 608690.182953546755016, 4824838.939126737415791 ], [ 608690.182953546755016, 4825206.424536112695932 ], [ 610037.629454591078684, 4825206.424536112695932 ], [ 610023.218262066598982, 4824867.761511785909534 ], [ 612076.813196813105606, 4824882.172704311087728 ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/line_placement_5.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "line_placement_5",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Line" }, "geometry": { "type": "LineString", "coordinates": [ [ 607352.7724662006367, 4824328.486790974624455 ], [ 609088.260067327762954, 4824267.234287405386567 ], [ 609108.677568517508917, 4824702.807646119967103 ], [ 609278.823411765159108, 4823974.58343701902777 ], [ 609374.1050839839736, 4824879.759323097765446 ], [ 609564.668428421369754, 4824029.030106858350337 ], [ 609809.67844269820489, 4824866.147655637934804 ], [ 609857.319278807612136, 4824049.447608048096299 ], [ 610061.494290704838932, 4824498.632634222507477 ], [ 611130.010186300729401, 4824491.826800492592156 ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/multi_polygon.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "multi_polygon",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "ftype": null, "text": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 606977.505720823770389, 4826619.702517162077129 ], [ 608787.494279176229611, 4826612.25400457624346 ], [ 608802.391304347780533, 4825733.329519449733198 ], [ 606962.608695652219467, 4825785.469107550568879 ], [ 606977.505720823770389, 4826619.702517162077129 ] ] ], [ [ [ 609845.183066361583769, 4825487.528604118153453 ], [ 609889.874141876469366, 4825487.528604118153453 ], [ 609882.425629290635698, 4824876.750572081655264 ], [ 609837.734553775750101, 4824884.199084667488933 ], [ 609845.183066361583769, 4825487.528604118153453 ] ] ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/narrow_polygon.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "narrow_polygon",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 609880.990502035361715, 4825629.640434192493558 ], [ 609689.511533242883161, 4824037.971506105735898 ], [ 609761.316146540106274, 4824026.004070556722581 ], [ 609940.827679782989435, 4825605.705563093535602 ], [ 609880.990502035361715, 4825629.640434192493558 ] ] ] } }
]
}
Binary file removed tests/testdata/labeling/pal_features_v3.sqlite
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/testdata/labeling/point.geojson
@@ -0,0 +1,12 @@
{
"type": "FeatureCollection",
"name": "point",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Single point" }, "geometry": { "type": "Point", "coordinates": [ 609510.0, 4825130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } }
]
}
13 changes: 13 additions & 0 deletions tests/testdata/labeling/point2.geojson
@@ -0,0 +1,13 @@
{
"type": "FeatureCollection",
"name": "point2",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Single point" }, "geometry": { "type": "Point", "coordinates": [ 609510.0, 4825130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 6, "text": null }, "geometry": { "type": "Point", "coordinates": [ 610668.038585209171288, 4825535.144694533199072 ] } }
]
}
13 changes: 13 additions & 0 deletions tests/testdata/labeling/point3.geojson
@@ -0,0 +1,13 @@
{
"type": "FeatureCollection",
"name": "point3",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Single point" }, "geometry": { "type": "Point", "coordinates": [ 609510.0, 4825130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 6, "text": null }, "geometry": { "type": "Point", "coordinates": [ 610668.038585209171288, 4825535.144694533199072 ] } }
]
}
12 changes: 12 additions & 0 deletions tests/testdata/labeling/point_ordered_obstacle1.geojson
@@ -0,0 +1,12 @@
{
"type": "FeatureCollection",
"name": "point_ordered_obstacle1",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 6, "text": null }, "geometry": { "type": "Point", "coordinates": [ 610039.71758664958179, 4825202.785622593015432 ] } }
]
}
13 changes: 13 additions & 0 deletions tests/testdata/labeling/point_ordered_obstacle2.geojson
@@ -0,0 +1,13 @@
{
"type": "FeatureCollection",
"name": "point_ordered_obstacle2",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 610024.582451514434069, 4825316.299136105924845 ] } },
{ "type": "Feature", "properties": { "pkuid": 6, "text": null }, "geometry": { "type": "Point", "coordinates": [ 608884.27436422300525, 4825340.561010303907096 ] } }
]
}
14 changes: 14 additions & 0 deletions tests/testdata/labeling/point_ordered_obstacle3.geojson
@@ -0,0 +1,14 @@
{
"type": "FeatureCollection",
"name": "point_ordered_obstacle3",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 610039.71758664958179, 4825202.785622593015432 ] } },
{ "type": "Feature", "properties": { "pkuid": 6, "text": null }, "geometry": { "type": "Point", "coordinates": [ 608899.409499358152971, 4825227.047496790997684 ] } },
{ "type": "Feature", "properties": { "pkuid": 7, "text": null }, "geometry": { "type": "Point", "coordinates": [ 610039.71758664958179, 4824984.428754813969135 ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/point_ordered_obstacle_top.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "point_ordered_obstacle_top",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": null }, "geometry": { "type": "Point", "coordinates": [ 609522.130937098874711, 4825235.13478819001466 ] } }
]
}
12 changes: 12 additions & 0 deletions tests/testdata/labeling/point_ordered_placement.geojson
@@ -0,0 +1,12 @@
{
"type": "FeatureCollection",
"name": "point_ordered_placement",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "text": "Single point" }, "geometry": { "type": "Point", "coordinates": [ 609510.0, 4825130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 2, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 3, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4823130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 4, "text": null }, "geometry": { "type": "Point", "coordinates": [ 612510.0, 4827130.0 ] } },
{ "type": "Feature", "properties": { "pkuid": 5, "text": null }, "geometry": { "type": "Point", "coordinates": [ 606510.0, 4827130.0 ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/polygon_perimeter.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "polygon_perimeter",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "rowid": 1, "pkuid": 1, "ftype": null, "text": "Polygon" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 607622.397260273923166, 4823643.698630136437714 ], [ 611665.136986301396973, 4823643.698630136437714 ], [ 611665.136986301396973, 4826398.310502283275127 ], [ 607622.397260273923166, 4826398.310502283275127 ], [ 607622.397260273923166, 4823643.698630136437714 ] ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/polygon_rule_based.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "polygon_rule_based",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "ftype": null, "text": "Polygon" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 606835.983981693396345, 4826969.782608695328236 ], [ 606880.675057208281942, 4823387.048054919578135 ], [ 612184.016018306603655, 4823327.459954232908785 ], [ 612161.670480549219064, 4826984.679633866995573 ], [ 606835.983981693396345, 4826969.782608695328236 ] ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/polygon_small.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "polygon_small",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "rowid": 1, "pkuid": 1, "ftype": null, "text": "Polygon" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 609296.963470319635235, 4824822.831050228327513 ], [ 610198.652968036476523, 4824822.831050228327513 ], [ 610198.652968036476523, 4825238.995433789677918 ], [ 609296.963470319635235, 4825238.995433789677918 ], [ 609296.963470319635235, 4824822.831050228327513 ] ] ] } }
]
}
8 changes: 8 additions & 0 deletions tests/testdata/labeling/polygon_with_hole.geojson
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "polygon_with_hole",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32613" } },
"features": [
{ "type": "Feature", "properties": { "pkuid": 1, "ftype": null, "text": "Polygon" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 606835.983981693396345, 4826969.782608695328236 ], [ 606880.675057208281942, 4823387.048054919578135 ], [ 612184.016018306603655, 4823327.459954232908785 ], [ 612161.670480549219064, 4826984.679633866995573 ], [ 606835.983981693396345, 4826969.782608695328236 ] ], [ [ 606925.366132723051123, 4826917.643020594492555 ], [ 606955.160183066385798, 4824370.251716247759759 ], [ 612116.979405034217052, 4824347.906178489327431 ], [ 612072.288329519447871, 4826872.951945079490542 ], [ 606925.366132723051123, 4826917.643020594492555 ] ] ] } }
]
}

0 comments on commit 175a075

Please sign in to comment.