コード例 #1
0
 def test_append_cons(self):
     exp = QgsExpression("nature = 'openAirPool'")
     request = QgsFeatureRequest(exp)
     feat = next(self.layer.getFeatures(request))
     self.assertNotEqual(feat, None)
     layer = ConsLayer()
     layer.rename = {}
     layer.append(self.layer)
     feat = next(layer.getFeatures(request))
     self.assertNotEqual(feat, None)
コード例 #2
0
 def setUp(self):
     fn = "test/fixtures/cons.shp"
     self.fixture = QgsVectorLayer(fn, "building", "ogr")
     self.assertTrue(self.fixture.isValid(), "Loading fixture")
     fn = "test_layer.shp"
     ConsLayer.create_shp(fn, self.fixture.crs())
     self.layer = ConsLayer(fn, "zoning", "ogr")
     self.assertTrue(self.layer.isValid(), "Init QGIS")
     self.layer.append(self.fixture, rename="")
     self.assertEqual(self.layer.featureCount(),
                      self.fixture.featureCount())
コード例 #3
0
 def test_append_othercons(self):
     layer = ConsLayer()
     self.assertTrue(layer.isValid(), "Init QGIS")
     fn = "test/fixtures/othercons.gml"
     fixture = QgsVectorLayer(fn, "building", "ogr")
     self.assertTrue(fixture.isValid())
     layer.append(fixture)
     feature = next(fixture.getFeatures())
     new_fet = next(layer.getFeatures())
     self.assertEqual(feature["constructionNature"], new_fet["nature"])
     self.assertEqual(feature["localId"], new_fet["localId"])
コード例 #4
0
 def test_append_buildingpart(self):
     layer = ConsLayer()
     self.assertTrue(layer.isValid(), "Init QGIS")
     fn = "test/fixtures/buildingpart.gml"
     fixture = QgsVectorLayer(fn, "building", "ogr")
     self.assertTrue(fixture.isValid())
     layer.append(fixture)
     feature = next(fixture.getFeatures())
     new_fet = next(layer.getFeatures())
     self.assertEqual(feature["numberOfFloorsAboveGround"],
                      new_fet["lev_above"])
     self.assertEqual(feature["localId"], new_fet["localId"])
コード例 #5
0
ファイル: test_parcel.py プロジェクト: OSM-es/CatAtom2Osm
 def setUp(self):
     fn = "test/fixtures/parcel.gpkg|layername=parcel"
     self.parcel = ParcelLayer("38012")
     fixture = QgsVectorLayer(fn, "parcel", "ogr")
     self.assertTrue(fixture.isValid(), "Loading fixture")
     self.parcel.append(fixture)
     self.assertEqual(self.parcel.featureCount(), 186)
     fn = "test/fixtures/cons.gpkg|layername=cons"
     fixture2 = QgsVectorLayer(fn, "cons", "ogr")
     self.building = ConsLayer("MultiPolygon", "cons", "memory")
     self.building.append(fixture2)
     self.assertTrue(self.building.isValid(), "Loading fixture")
コード例 #6
0
 def test_simplify2(self):
     layer = ConsLayer()
     fn = "test/fixtures/38023.buildingpart.gml"
     fixture1 = QgsVectorLayer(fn, "building", "ogr")
     self.assertTrue(fixture1.isValid(), "Loading fixture")
     layer.append(fixture1, rename="")
     self.assertEqual(layer.featureCount(), fixture1.featureCount())
     fn = "test/fixtures/38023.buildingpart.gml"
     fixture2 = QgsVectorLayer(fn, "buildingpart", "ogr")
     self.assertTrue(fixture2.isValid(), "Loading fixture")
     layer.append(fixture2, rename="")
     self.assertEqual(
         layer.featureCount(),
         fixture1.featureCount() + fixture2.featureCount(),
     )
     layer.remove_outside_parts()
     layer.explode_multi_parts()
     layer.topology()
     layer.simplify()
     for feat in layer.getFeatures():
         geom = feat.geometry()
         self.assertTrue(geom.isGeosValid(), feat["localId"])
     layer.merge_building_parts()