@@ -1266,8 +1266,8 @@ def test(self):
12661266 cursor .execute ("INSERT INTO n2k VALUES (50, 0, 8, 'comment1', NULL, ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
12671267 cursor .execute ("INSERT INTO n2k VALUES (51, 0, 8, NULL, 'comment2', ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
12681268
1269- cursor .execute ("INSERT INTO n2k VALUES (52, 0, 8, 'comment1 nok ', NULL, ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
1270- cursor .execute ("INSERT INTO n2k VALUES (53, 0, 8, NULL, 'comment2 nok ', ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
1269+ cursor .execute ("INSERT INTO n2k VALUES (52, 0, 8, 'comment_nok1 ', NULL, ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
1270+ cursor .execute ("INSERT INTO n2k VALUES (53, 0, 8, NULL, 'comment_nok2 ', ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
12711271 cursor .execute ("INSERT INTO n2k VALUES (54, 0, 8, NULL, NULL, ST_MakeEnvelope(60, 0, 61, 1, 4326));" )
12721272
12731273 self .params .update ({"layer_defs" : {"n2k" : {"pg_layer_name" : "n2k" ,
@@ -1457,8 +1457,8 @@ def test(self):
14571457
14581458
14591459class Test_mml (VectorCheckTestCase ):
1460- def test (self ):
1461- from qc_tool . vector . mml import run_check
1460+ def setUp (self ):
1461+ super (). setUp ()
14621462 self .params .update ({"layer_defs" : {"mml" : {"pg_layer_name" : "mml" ,
14631463 "pg_fid_name" : "fid" ,
14641464 "fid_display_name" : "row number" }},
@@ -1467,19 +1467,49 @@ def test(self):
14671467 "filter_code" : "1" ,
14681468 "mml" : 10. ,
14691469 "step_nr" : 1 })
1470- cursor = self .params ["connection_manager" ].get_connection ().cursor ()
1471- cursor .execute ("CREATE TABLE mml (fid integer, code char(1), geom geometry(Polygon, 4326));" )
1472- cursor .execute ("INSERT INTO mml VALUES (1, NULL, ST_MakeEnvelope(0, 0, 5, 1, 4326));" )
1473- cursor .execute ("INSERT INTO mml VALUES (2, '1', ST_MakeEnvelope(0, 0, 5, 1, 4326));" )
1474- cursor .execute ("INSERT INTO mml VALUES (3, '1', ST_MakeEnvelope(0, 0, 9.999, 1, 4326));" )
1475- cursor .execute ("INSERT INTO mml VALUES (4, '1', ST_MakeEnvelope(0, 0, 10, 1, 4326));" )
1476- cursor .execute ("INSERT INTO mml VALUES (5, '1', ST_MakeEnvelope(0, 0, 11, 1, 4326));" )
1477- cursor .execute ("INSERT INTO mml VALUES (6, '2', ST_MakeEnvelope(0, 0, 5, 1, 4326));" )
1470+ self .cursor = self .params ["connection_manager" ].get_connection ().cursor ()
1471+ self .cursor .execute ("CREATE TABLE mml (fid integer, code char(1), geom geometry(Polygon, 4326));" )
1472+
1473+ def test (self ):
1474+ from qc_tool .vector .mml import run_check
1475+ self .cursor .execute ("INSERT INTO mml VALUES (1, NULL, ST_MakeEnvelope(0, 0, 5, 1, 4326));" )
1476+ self .cursor .execute ("INSERT INTO mml VALUES (2, '1', ST_MakeEnvelope(0, 0, 5, 1, 4326));" )
1477+ self .cursor .execute ("INSERT INTO mml VALUES (3, '1', ST_MakeEnvelope(0, 0, 9.999, 1, 4326));" )
1478+ self .cursor .execute ("INSERT INTO mml VALUES (4, '1', ST_MakeEnvelope(0, 0, 10, 1, 4326));" )
1479+ self .cursor .execute ("INSERT INTO mml VALUES (5, '1', ST_MakeEnvelope(0, 0, 11, 1, 4326));" )
1480+ self .cursor .execute ("INSERT INTO mml VALUES (6, '2', ST_MakeEnvelope(0, 0, 5, 1, 4326));" )
1481+ status = self .status_class ()
1482+ run_check (self .params , status )
1483+ self .assertEqual ("ok" , status .status )
1484+ self .cursor .execute ("SELECT fid FROM s01_mml_warning ORDER BY fid;" )
1485+ self .assertListEqual ([(2 ,), (3 ,)], self .cursor .fetchall ())
1486+
1487+ def test_arch (self ):
1488+ """The plain box does not pass the check, however, if we make an arch from it, the check passes."""
1489+ from qc_tool .vector .mml import run_check
1490+ self .cursor .execute ("INSERT INTO mml VALUES (1, '1', ST_Difference(ST_MakeEnvelope(0, 0, 9.999, 1, 4326),"
1491+ " ST_MakeEnvelope(0.5, 0, 9.5, 0.5, 4326)));" )
1492+ status = self .status_class ()
1493+ run_check (self .params , status )
1494+ self .assertEqual ("ok" , status .status )
1495+ self .cursor .execute ("SELECT fid FROM s01_mml_warning ORDER BY fid;" )
1496+ self .assertListEqual ([], self .cursor .fetchall ())
1497+
1498+ def test_inner_ring (self ):
1499+ """If there are two inner rings intersecting in a point, then ST_ApproximateMedialAxis() raises error:
1500+
1501+ psycopg2.InternalError: straight skeleton of Polygon with touching interior rings is not implemented
1502+
1503+ Adapted implementation ignores inner rings, so this test should pass with ok status."""
1504+ from qc_tool .vector .mml import run_check
1505+ self .cursor .execute ("INSERT INTO mml VALUES (1, '1', ST_Difference(ST_Difference(ST_MakeEnvelope(0, 0, 4, 4, 4326),"
1506+ " ST_MakeEnvelope(1, 0, 2, 2, 4326)),"
1507+ " ST_MakeEnvelope(2, 2, 3, 3, 4326)));" )
14781508 status = self .status_class ()
14791509 run_check (self .params , status )
14801510 self .assertEqual ("ok" , status .status )
1481- cursor .execute ("SELECT fid FROM s01_mml_warning ORDER BY fid;" )
1482- self .assertListEqual ([(2 ,), ( 3 ,) ], cursor .fetchall ())
1511+ self . cursor .execute ("SELECT fid FROM s01_mml_warning ORDER BY fid;" )
1512+ self .assertListEqual ([(1 ,) ], self . cursor .fetchall ())
14831513
14841514
14851515class Test_overlap (VectorCheckTestCase ):
0 commit comments