diff --git a/Geodatenbezug.Test/GdalAssert.cs b/Geodatenbezug.Test/GdalAssert.cs index b9ea875..a0d254c 100644 --- a/Geodatenbezug.Test/GdalAssert.cs +++ b/Geodatenbezug.Test/GdalAssert.cs @@ -21,7 +21,7 @@ internal static void AssertLayerFields(Layer resultLayer, List expectedL resultLayerFields.Add(resultLayerDefn.GetFieldDefn(i).GetName()); } - CollectionAssert.AreEqual(expectedLayerFields, resultLayerFields); + CollectionAssert.AreEquivalent(expectedLayerFields, resultLayerFields); } /// diff --git a/Geodatenbezug.Test/Geodatenbezug.Test.csproj b/Geodatenbezug.Test/Geodatenbezug.Test.csproj index 8d5805e..6315010 100644 --- a/Geodatenbezug.Test/Geodatenbezug.Test.csproj +++ b/Geodatenbezug.Test/Geodatenbezug.Test.csproj @@ -29,31 +29,34 @@ - + PreserveNewest PreserveNewest - + + PreserveNewest + + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + \ No newline at end of file diff --git a/Geodatenbezug.Test/Processors/BewirtschaftungseinheitProcessorTest.cs b/Geodatenbezug.Test/Processors/BewirtschaftungseinheitProcessorTest.cs index 6f0f248..69a379e 100644 --- a/Geodatenbezug.Test/Processors/BewirtschaftungseinheitProcessorTest.cs +++ b/Geodatenbezug.Test/Processors/BewirtschaftungseinheitProcessorTest.cs @@ -6,7 +6,7 @@ namespace Geodatenbezug.Processors; [TestClass] -[DeploymentItem("testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg", "testdata")] public class BewirtschaftungseinheitProcessorTest { private readonly Topic topic = new () @@ -42,7 +42,7 @@ public async Task RunGdalProcessingAsync() { loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); - processor.InputDataPath = "testdata\\lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg"; + processor.InputDataPath = "testdata\\lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg"; await processor.RunGdalProcessingAsync(); var inputSource = Ogr.Open(processor.InputDataPath, 0); @@ -71,7 +71,7 @@ public async Task RunGdalProcessingAsync() var firstBetriebInputFeature = betriebInputLayer.GetNextFeature(); betriebResultLayer.ResetReading(); var firstBetriebResultFeature = betriebResultLayer.GetNextFeature(); - Assert.AreEqual(firstBetriebInputFeature.GetFID(), firstBetriebResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstBetriebInputFeature.GetFieldAsInteger("t_id"), firstBetriebResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstBetriebInputFeature, firstBetriebResultFeature, "bezugsjahr"); Assert.AreEqual(firstBetriebInputFeature.GetFieldAsString("betriebsnummer"), firstBetriebResultFeature.GetFieldAsString("betriebsnummer")); Assert.AreEqual(firstBetriebInputFeature.GetFieldAsString("betriebsname"), firstBetriebResultFeature.GetFieldAsString("betriebsname")); @@ -107,7 +107,7 @@ public async Task RunGdalProcessingAsync() var firstBewirtschaftungseinheitInputFeature = bewirtschaftungseinheitInputLayer.GetNextFeature(); bewirtschaftungseinheitResultLayer.ResetReading(); var firstBewirtschaftungseinheitResultFeature = bewirtschaftungseinheitResultLayer.GetNextFeature(); - Assert.AreEqual(firstBewirtschaftungseinheitInputFeature.GetFID(), firstBewirtschaftungseinheitResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstBewirtschaftungseinheitInputFeature.GetFieldAsInteger("t_id"), firstBewirtschaftungseinheitResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstBewirtschaftungseinheitInputFeature, firstBewirtschaftungseinheitResultFeature, "bezugsjahr"); Assert.AreEqual(firstBewirtschaftungseinheitInputFeature.GetFieldAsInteger("ist_definitiv"), firstBewirtschaftungseinheitResultFeature.GetFieldAsInteger("ist_definitiv")); Assert.AreEqual(firstBewirtschaftungseinheitInputFeature.GetFieldAsString("betriebsnummer"), firstBewirtschaftungseinheitResultFeature.GetFieldAsString("betriebsnummer")); @@ -143,7 +143,7 @@ public async Task RunGdalProcessingAsync() var firstProduktionsstaetteInputFeature = produktionsstaetteInputLayer.GetNextFeature(); produktionsstaetteResultLayer.ResetReading(); var firstProduktionsstaetteResultFeature = produktionsstaetteResultLayer.GetNextFeature(); - Assert.AreEqual(firstProduktionsstaetteInputFeature.GetFID(), firstProduktionsstaetteResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstProduktionsstaetteInputFeature.GetFieldAsInteger("t_id"), firstProduktionsstaetteResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstProduktionsstaetteInputFeature, firstProduktionsstaetteResultFeature, "bezugsjahr"); Assert.AreEqual(firstProduktionsstaetteInputFeature.GetFieldAsString("ps_nr"), firstProduktionsstaetteResultFeature.GetFieldAsString("ps_nr")); Assert.AreEqual(firstProduktionsstaetteInputFeature.GetFieldAsString("ps_name"), firstProduktionsstaetteResultFeature.GetFieldAsString("ps_name")); diff --git a/Geodatenbezug.Test/Processors/BiodiversitaetsfoerderflaechenProcessorTest.cs b/Geodatenbezug.Test/Processors/BiodiversitaetsfoerderflaechenProcessorTest.cs index c20da4d..32674f0 100644 --- a/Geodatenbezug.Test/Processors/BiodiversitaetsfoerderflaechenProcessorTest.cs +++ b/Geodatenbezug.Test/Processors/BiodiversitaetsfoerderflaechenProcessorTest.cs @@ -6,7 +6,7 @@ namespace Geodatenbezug.Processors; [TestClass] -[DeploymentItem("testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_NE_202404191123.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_testdaten.gpkg", "testdata")] public class BiodiversitaetsfoerderflaechenProcessorTest { private readonly Topic topic = new () @@ -42,7 +42,7 @@ public async Task RunGdalProcessingAsync() { loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); - processor.InputDataPath = "testdata\\lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_NE_202404191123.gpkg"; + processor.InputDataPath = "testdata\\lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_testdaten.gpkg"; await processor.RunGdalProcessingAsync(); var inputSource = Ogr.Open(processor.InputDataPath, 0); @@ -81,13 +81,28 @@ public async Task RunGdalProcessingAsync() GdalAssert.AssertFieldType(qualitaetResultLayer, "beitragsberechtigt", FieldType.OFTInteger, FieldSubType.OFSTInt16); GdalAssert.AssertOnlyValidLnfCodes(qualitaetResultLayer); - GdalAssert.AssertOnlySinglePartGeometries(qualitaetResultLayer); + var t_ids = new List(); + qualitaetResultLayer.ResetReading(); + for (var i = 0; i < qualitaetResultLayer.GetFeatureCount(1); i++) + { + var feature = qualitaetResultLayer.GetNextFeature(); + t_ids.Add(feature.GetFieldAsInteger("t_id")); + } + + // Delete feature with invalid lnf_code + Assert.AreEqual(0, t_ids.FindAll(t_id => t_id == 550616).Count); + + // Feature with multipart geometry was split into three features + Assert.AreEqual(2, t_ids.FindAll(t_id => t_id == 584805).Count); + + // The first feature was deleted so we want to compare the second one + qualitaetInputLayer.GetNextFeature(); var firstQualitaetInputFeature = qualitaetInputLayer.GetNextFeature(); qualitaetResultLayer.ResetReading(); var firstQualitaetResultFeature = qualitaetResultLayer.GetNextFeature(); - Assert.AreEqual(firstQualitaetInputFeature.GetFID(), firstQualitaetResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstQualitaetInputFeature.GetFieldAsInteger("t_id"), firstQualitaetResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstQualitaetInputFeature, firstQualitaetResultFeature, "bezugsjahr"); Assert.AreEqual(firstQualitaetInputFeature.GetFieldAsInteger("anzahl_baeume"), firstQualitaetResultFeature.GetFieldAsInteger("anzahl_baeume")); Assert.AreEqual(firstQualitaetInputFeature.GetFieldAsInteger("ist_definitiv"), firstQualitaetResultFeature.GetFieldAsInteger("ist_definitiv")); @@ -130,24 +145,33 @@ public async Task RunGdalProcessingAsync() GdalAssert.AssertFieldType(vernetzungResultLayer, "verpflichtung_von", FieldType.OFTDateTime); GdalAssert.AssertFieldType(vernetzungResultLayer, "verpflichtung_bis", FieldType.OFTDateTime); GdalAssert.AssertFieldType(vernetzungResultLayer, "schnittzeitpunkt", FieldType.OFTDateTime); - GdalAssert.AssertFieldType(qualitaetResultLayer, "ist_definitiv", FieldType.OFTInteger, FieldSubType.OFSTInt16); - GdalAssert.AssertFieldType(qualitaetResultLayer, "beitragsberechtigt", FieldType.OFTInteger, FieldSubType.OFSTInt16); - GdalAssert.AssertFieldType(qualitaetResultLayer, "nhg", FieldType.OFTInteger, FieldSubType.OFSTInt16); + GdalAssert.AssertFieldType(vernetzungResultLayer, "ist_definitiv", FieldType.OFTInteger, FieldSubType.OFSTInt16); + GdalAssert.AssertFieldType(vernetzungResultLayer, "beitragsberechtigt", FieldType.OFTInteger, FieldSubType.OFSTInt16); - GdalAssert.AssertOnlyValidLnfCodes(qualitaetResultLayer); + GdalAssert.AssertOnlyValidLnfCodes(vernetzungResultLayer); + GdalAssert.AssertOnlySinglePartGeometries(vernetzungResultLayer); + t_ids = new List(); + vernetzungResultLayer.ResetReading(); + for (var i = 0; i < vernetzungResultLayer.GetFeatureCount(1); i++) + { + var feature = vernetzungResultLayer.GetNextFeature(); + t_ids.Add(feature.GetFieldAsInteger("t_id")); + } - GdalAssert.AssertOnlySinglePartGeometries(qualitaetResultLayer); + // Delete feature with invalid lnf_code + Assert.AreEqual(0, t_ids.FindAll(t_id => t_id == 914572).Count); var firstVernetzungInputFeature = vernetzungInputLayer.GetNextFeature(); vernetzungResultLayer.ResetReading(); var firstVernetzungResultFeature = vernetzungResultLayer.GetNextFeature(); - Assert.AreEqual(firstVernetzungInputFeature.GetFID(), firstVernetzungResultFeature.GetFieldAsInteger("t_id")); + var tid = firstVernetzungInputFeature.GetFieldAsInteger("t_id"); + Assert.AreEqual(firstVernetzungInputFeature.GetFieldAsInteger("t_id"), firstVernetzungResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstVernetzungInputFeature, firstVernetzungResultFeature, "bezugsjahr"); Assert.AreEqual(firstVernetzungInputFeature.GetFieldAsInteger("anzahl_baeume"), firstVernetzungResultFeature.GetFieldAsInteger("anzahl_baeume")); Assert.AreEqual(firstVernetzungInputFeature.GetFieldAsInteger("ist_definitiv"), firstVernetzungResultFeature.GetFieldAsInteger("ist_definitiv")); GdalAssert.AssertDateTime(firstVernetzungInputFeature, firstVernetzungResultFeature, "verpflichtung_von"); - GdalAssert.AssertDateTime(firstQualitaetInputFeature, firstQualitaetResultFeature, "verpflichtung_bis"); - GdalAssert.AssertDateTime(firstVernetzungInputFeature, firstQualitaetResultFeature, "schnittzeitpunkt"); + GdalAssert.AssertDateTime(firstVernetzungInputFeature, firstVernetzungResultFeature, "verpflichtung_bis"); + GdalAssert.AssertDateTime(firstVernetzungInputFeature, firstVernetzungResultFeature, "schnittzeitpunkt"); Assert.AreEqual(firstVernetzungInputFeature.GetFieldAsInteger("beitragsberechtigt"), firstVernetzungResultFeature.GetFieldAsInteger("beitragsberechtigt")); Assert.AreEqual(firstVernetzungInputFeature.GetFieldAsInteger("lnf_code"), firstVernetzungResultFeature.GetFieldAsInteger("lnf_code")); Assert.AreEqual(firstVernetzungInputFeature.GetFieldAsString("identifikator"), firstVernetzungResultFeature.GetFieldAsString("identifikator")); diff --git a/Geodatenbezug.Test/Processors/NutzungsflaechenProcessorTest.cs b/Geodatenbezug.Test/Processors/NutzungsflaechenProcessorTest.cs index 44d1d6b..84e2b05 100644 --- a/Geodatenbezug.Test/Processors/NutzungsflaechenProcessorTest.cs +++ b/Geodatenbezug.Test/Processors/NutzungsflaechenProcessorTest.cs @@ -7,8 +7,8 @@ namespace Geodatenbezug.Processors; [TestClass] -[DeploymentItem("testdata/lwb_nutzungsflaechen_v2_0_lv95_NE_202404191123.gpkg", "testdata")] -[DeploymentItem("testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_nutzungsflaechen_v2_0_lv95_testdaten.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg", "testdata")] public class NutzungsflaechenProcessorTest { private readonly Topic topic = new () @@ -74,7 +74,6 @@ public async Task RunGdalProcessingAsync() { loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); loggerMock.Setup(LogLevel.Information, $"Kopiere Features aus dem GPKG in die GDB"); - loggerMock.Setup(LogLevel.Information, $"Filtere LNF-Codes"); loggerMock.Setup(LogLevel.Information, $"Lade Nutzungsart-Katalog von https://models.geo.admin.ch/BLW/LWB_Nutzungsflaechen_Kataloge_V2_0.xml"); loggerMock.Setup(LogLevel.Information, $"Erstelle temporären Nutzungsartlayer"); loggerMock.Setup(LogLevel.Information, $"Erstelle temporären Bewirtschaftungslayer"); @@ -82,11 +81,10 @@ public async Task RunGdalProcessingAsync() loggerMock.Setup(LogLevel.Information, $"Lösche initialen Nutzungsflächenlayer"); loggerMock.Setup(LogLevel.Information, $"Erstelle neuen Nutzungsflächenlayer"); loggerMock.Setup(LogLevel.Information, $"Kopiere Features vom Joined Layer zum neuen Nutzungsflächenlayer"); - loggerMock.Setup(LogLevel.Information, $"Konvertiere Multi- zu Singlepart-Geometrien"); loggerMock.Setup(LogLevel.Information, $"Lösche temporäre Layer"); - processor.InputDataPath = "testdata\\lwb_nutzungsflaechen_v2_0_lv95_NE_202404191123.gpkg"; - processor.BewirtschaftungseinheitDataPath = "testdata\\lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg"; + processor.InputDataPath = "testdata\\lwb_nutzungsflaechen_v2_0_lv95_testdaten.gpkg"; + processor.BewirtschaftungseinheitDataPath = "testdata\\lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg"; await processor.RunGdalProcessingAsync(); var layerName = "nutzungsflaechen"; @@ -127,14 +125,27 @@ public async Task RunGdalProcessingAsync() GdalAssert.AssertFieldType(resultLayer, "bff_qualitaet_1", FieldType.OFTInteger, FieldSubType.OFSTInt16); GdalAssert.AssertOnlyValidLnfCodes(resultLayer); - GdalAssert.AssertOnlySinglePartGeometries(resultLayer); + var t_ids = new List(); + resultLayer.ResetReading(); + for (var i = 0; i < resultLayer.GetFeatureCount(1); i++) + { + var feature = resultLayer.GetNextFeature(); + t_ids.Add(feature.GetFieldAsInteger("t_id")); + } + + // Delete feature with invalid lnf_code + Assert.AreEqual(0, t_ids.FindAll(t_id => t_id == 6225522).Count); + + // Feature with multipart geometry was split into three features + Assert.AreEqual(3, t_ids.FindAll(t_id => t_id == 6225610).Count); + var firstInputFeature = inputLayer.GetNextFeature(); resultLayer.ResetReading(); var firstResultFeature = resultLayer.GetNextFeature(); - Assert.AreEqual(firstInputFeature.GetFID(), firstResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstInputFeature.GetFieldAsInteger("t_id"), firstResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstInputFeature, firstResultFeature, "bezugsjahr"); Assert.AreEqual(firstInputFeature.GetFieldAsInteger("lnf_code"), firstResultFeature.GetFieldAsInteger("lnf_code")); Assert.AreEqual(firstInputFeature.GetFieldAsString("code_programm"), firstResultFeature.GetFieldAsString("code_programm")); @@ -144,13 +155,13 @@ public async Task RunGdalProcessingAsync() Assert.AreEqual(firstInputFeature.GetFieldAsInteger("flaeche_m2"), firstResultFeature.GetFieldAsInteger("flaeche_m2")); Assert.AreEqual(firstInputFeature.GetFieldAsString("kanton"), firstResultFeature.GetFieldAsString("kanton")); Assert.AreEqual(0, firstResultFeature.GetFieldAsInteger("bff_qualitaet_1")); - Assert.AreEqual("Ackerfläche", firstResultFeature.GetFieldAsString("hauptkategorie_de")); - Assert.AreEqual("Terres cultivées", firstResultFeature.GetFieldAsString("hauptkategorie_fr")); - Assert.AreEqual("Superficie coltiva", firstResultFeature.GetFieldAsString("hauptkategorie_it")); - Assert.AreEqual("Sommergerste", firstResultFeature.GetFieldAsString("nutzung_de")); - Assert.AreEqual("Orge de printemps", firstResultFeature.GetFieldAsString("nutzung_fr")); - Assert.AreEqual("Orzo primaverile", firstResultFeature.GetFieldAsString("nutzung_it")); - Assert.AreEqual("NE65020007", firstResultFeature.GetFieldAsString("betriebsnummer")); + Assert.AreEqual("Reben", firstResultFeature.GetFieldAsString("hauptkategorie_de")); + Assert.AreEqual("Vignobles", firstResultFeature.GetFieldAsString("hauptkategorie_fr")); + Assert.AreEqual("Vigna", firstResultFeature.GetFieldAsString("hauptkategorie_it")); + Assert.AreEqual("Reben", firstResultFeature.GetFieldAsString("nutzung_de")); + Assert.AreEqual("Vignes", firstResultFeature.GetFieldAsString("nutzung_fr")); + Assert.AreEqual("Vigna", firstResultFeature.GetFieldAsString("nutzung_it")); + Assert.AreEqual("BEB102228", firstResultFeature.GetFieldAsString("betriebsnummer")); Assert.AreEqual(string.Empty, firstResultFeature.GetFieldAsString("bur_nr")); GdalAssert.AssertGeometry(firstInputFeature, firstResultFeature); } diff --git a/Geodatenbezug.Test/Processors/PerimeterLnSfProcessorTest.cs b/Geodatenbezug.Test/Processors/PerimeterLnSfProcessorTest.cs index e0b3dc2..0c90229 100644 --- a/Geodatenbezug.Test/Processors/PerimeterLnSfProcessorTest.cs +++ b/Geodatenbezug.Test/Processors/PerimeterLnSfProcessorTest.cs @@ -6,7 +6,8 @@ namespace Geodatenbezug.Processors; [TestClass] -[DeploymentItem("testdata/lwb_perimeter_ln_sf_v2_0_lv95_NE_202404191123.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten_invalid_geometry.gpkg", "testdata")] public class PerimeterLnSfProcessorTest { private readonly Topic topic = new () @@ -42,7 +43,7 @@ public async Task RunGdalProcessingAsync() { loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); - processor.InputDataPath = "testdata\\lwb_perimeter_ln_sf_v2_0_lv95_NE_202404191123.gpkg"; + processor.InputDataPath = "testdata\\lwb_perimeter_ln_sf_v2_0_lv95_testdaten.gpkg"; await processor.RunGdalProcessingAsync(); var layerName = "perimeter_ln_sf"; @@ -68,11 +69,13 @@ public async Task RunGdalProcessingAsync() GdalAssert.AssertFieldType(resultLayer, "bezugsjahr", FieldType.OFTDateTime); GdalAssert.AssertOnlySinglePartGeometries(resultLayer); + Assert.AreEqual(2, inputLayer.GetFeatureCount(0)); + Assert.AreEqual(3, resultLayer.GetFeatureCount(0)); var firstInputFeature = inputLayer.GetNextFeature(); resultLayer.ResetReading(); var firstResultFeature = resultLayer.GetNextFeature(); - Assert.AreEqual(firstInputFeature.GetFID(), firstResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstInputFeature.GetFieldAsInteger("t_id"), firstResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstInputFeature, firstResultFeature, "bezugsjahr"); Assert.AreEqual(firstInputFeature.GetFieldAsString("typ"), firstResultFeature.GetFieldAsString("typ")); Assert.AreEqual(firstInputFeature.GetFieldAsString("identifikator"), firstResultFeature.GetFieldAsString("identifikator")); @@ -80,4 +83,13 @@ public async Task RunGdalProcessingAsync() Assert.AreEqual(firstInputFeature.GetFieldAsString("kanton"), firstResultFeature.GetFieldAsString("kanton")); GdalAssert.AssertGeometry(firstInputFeature, firstResultFeature); } + + [TestMethod] + public async Task RunGdalProcessingAsyncInvalidGeometry() + { + loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); + + processor.InputDataPath = "testdata\\lwb_perimeter_ln_sf_v2_0_lv95_testdaten_invalid_geometry.gpkg"; + await Assert.ThrowsExceptionAsync(processor.RunGdalProcessingAsync); + } } diff --git a/Geodatenbezug.Test/Processors/PerimeterTerrassenrebenProcessorTest.cs b/Geodatenbezug.Test/Processors/PerimeterTerrassenrebenProcessorTest.cs index 3426387..710c597 100644 --- a/Geodatenbezug.Test/Processors/PerimeterTerrassenrebenProcessorTest.cs +++ b/Geodatenbezug.Test/Processors/PerimeterTerrassenrebenProcessorTest.cs @@ -6,7 +6,7 @@ namespace Geodatenbezug.Processors; [TestClass] -[DeploymentItem("testdata/lwb_perimeter_terrassenreben_v2_0_lv95_NE_202404191123.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_perimeter_terrassenreben_v2_0_lv95_testdaten.gpkg", "testdata")] public class PerimeterTerrassenrebenProcessorTest { private readonly Topic topic = new () @@ -42,7 +42,7 @@ public async Task RunGdalProcessingAsync() { loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); - processor.InputDataPath = "testdata\\lwb_perimeter_terrassenreben_v2_0_lv95_NE_202404191123.gpkg"; + processor.InputDataPath = "testdata\\lwb_perimeter_terrassenreben_v2_0_lv95_testdaten.gpkg"; await processor.RunGdalProcessingAsync(); var layerName = "perimeter_terrassenreben"; @@ -73,7 +73,7 @@ public async Task RunGdalProcessingAsync() var firstInputFeature = inputLayer.GetNextFeature(); resultLayer.ResetReading(); var firstResultFeature = resultLayer.GetNextFeature(); - Assert.AreEqual(firstInputFeature.GetFID(), firstResultFeature.GetFieldAsInteger("t_id")); + Assert.AreEqual(firstInputFeature.GetFieldAsInteger("t_id"), firstResultFeature.GetFieldAsInteger("t_id")); GdalAssert.AssertDateTime(firstInputFeature, firstResultFeature, "bezugsjahr"); GdalAssert.AssertDateTime(firstInputFeature, firstResultFeature, "aenderungsdatum"); Assert.AreEqual(firstInputFeature.GetFieldAsString("identifikator"), firstResultFeature.GetFieldAsString("identifikator")); diff --git a/Geodatenbezug.Test/Processors/RebbaukatasterProcessorTest.cs b/Geodatenbezug.Test/Processors/RebbaukatasterProcessorTest.cs index 8a69fdd..8de1846 100644 --- a/Geodatenbezug.Test/Processors/RebbaukatasterProcessorTest.cs +++ b/Geodatenbezug.Test/Processors/RebbaukatasterProcessorTest.cs @@ -6,7 +6,7 @@ namespace Geodatenbezug.Processors; [TestClass] -[DeploymentItem("testdata/lwb_rebbaukataster_v2_0_lv95_NE_202404191123.gpkg", "testdata")] +[DeploymentItem("testdata/lwb_rebbaukataster_v2_0_lv95_testdaten.gpkg", "testdata")] public class RebbaukatasterProcessorTest { private readonly Topic topic = new () @@ -42,7 +42,7 @@ public async Task RunGdalProcessingAsync() { loggerMock.Setup(LogLevel.Information, $"Starte GDAL-Prozessierung"); - processor.InputDataPath = "testdata\\lwb_rebbaukataster_v2_0_lv95_NE_202404191123.gpkg"; + processor.InputDataPath = "testdata\\lwb_rebbaukataster_v2_0_lv95_testdaten.gpkg"; await processor.RunGdalProcessingAsync(); var layerName = "rebbaukataster"; diff --git a/Geodatenbezug.Test/testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg b/Geodatenbezug.Test/testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg deleted file mode 100644 index 6068e67..0000000 Binary files a/Geodatenbezug.Test/testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_NE_202404191123.gpkg and /dev/null differ diff --git a/Geodatenbezug.Test/testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg b/Geodatenbezug.Test/testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg new file mode 100644 index 0000000..4d937ac Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_bewirtschaftungseinheit_v2_0_lv95_testdaten.gpkg differ diff --git a/Geodatenbezug.Test/testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_NE_202404191123.gpkg b/Geodatenbezug.Test/testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_NE_202404191123.gpkg deleted file mode 100644 index 1a77fc2..0000000 Binary files a/Geodatenbezug.Test/testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_NE_202404191123.gpkg and /dev/null differ diff --git a/Geodatenbezug.Test/testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_testdaten.gpkg b/Geodatenbezug.Test/testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_testdaten.gpkg new file mode 100644 index 0000000..b2382a2 Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_biodiversitaetsfoerderflaechen_v2_0_lv95_testdaten.gpkg differ diff --git a/Geodatenbezug.Test/testdata/lwb_nutzungsflaechen_v2_0_lv95_NE_202404191123.gpkg b/Geodatenbezug.Test/testdata/lwb_nutzungsflaechen_v2_0_lv95_NE_202404191123.gpkg deleted file mode 100644 index 08188f9..0000000 Binary files a/Geodatenbezug.Test/testdata/lwb_nutzungsflaechen_v2_0_lv95_NE_202404191123.gpkg and /dev/null differ diff --git a/Geodatenbezug.Test/testdata/lwb_nutzungsflaechen_v2_0_lv95_testdaten.gpkg b/Geodatenbezug.Test/testdata/lwb_nutzungsflaechen_v2_0_lv95_testdaten.gpkg new file mode 100644 index 0000000..d4618e8 Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_nutzungsflaechen_v2_0_lv95_testdaten.gpkg differ diff --git a/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_NE_202404191123.gpkg b/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_NE_202404191123.gpkg deleted file mode 100644 index 48c91b1..0000000 Binary files a/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_NE_202404191123.gpkg and /dev/null differ diff --git a/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten.gpkg b/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten.gpkg new file mode 100644 index 0000000..488aad3 Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten.gpkg differ diff --git a/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten_invalid_geometry.gpkg b/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten_invalid_geometry.gpkg new file mode 100644 index 0000000..6760af9 Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_perimeter_ln_sf_v2_0_lv95_testdaten_invalid_geometry.gpkg differ diff --git a/Geodatenbezug.Test/testdata/lwb_perimeter_terrassenreben_v2_0_lv95_testdaten.gpkg b/Geodatenbezug.Test/testdata/lwb_perimeter_terrassenreben_v2_0_lv95_testdaten.gpkg new file mode 100644 index 0000000..b4ceec2 Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_perimeter_terrassenreben_v2_0_lv95_testdaten.gpkg differ diff --git a/Geodatenbezug.Test/testdata/lwb_rebbaukataster_v2_0_lv95_NE_202404191123.gpkg b/Geodatenbezug.Test/testdata/lwb_rebbaukataster_v2_0_lv95_NE_202404191123.gpkg deleted file mode 100644 index 9ac7514..0000000 Binary files a/Geodatenbezug.Test/testdata/lwb_rebbaukataster_v2_0_lv95_NE_202404191123.gpkg and /dev/null differ diff --git a/Geodatenbezug.Test/testdata/lwb_rebbaukataster_v2_0_lv95_testdaten.gpkg b/Geodatenbezug.Test/testdata/lwb_rebbaukataster_v2_0_lv95_testdaten.gpkg new file mode 100644 index 0000000..930b22c Binary files /dev/null and b/Geodatenbezug.Test/testdata/lwb_rebbaukataster_v2_0_lv95_testdaten.gpkg differ diff --git a/Geodatenbezug/Processors/BewirtschaftungseinheitProcessor.cs b/Geodatenbezug/Processors/BewirtschaftungseinheitProcessor.cs index 4612616..c6d1c0d 100644 --- a/Geodatenbezug/Processors/BewirtschaftungseinheitProcessor.cs +++ b/Geodatenbezug/Processors/BewirtschaftungseinheitProcessor.cs @@ -18,20 +18,17 @@ protected override Task ProcessTopicAsync() { bezugsjahrFieldDefinition.GetName(), bezugsjahrFieldDefinition }, }; - var betriebLayer = CreateGdalLayer("betrieb", fieldTypeConversions); + var betriebLayer = CreateGdalLayer("betrieb", fieldTypeConversions, false, true); betriebLayer.CopyFeatures(); - betriebLayer.ConvertMultiPartToSinglePartGeometry(); - var produktionsstaetteLayer = CreateGdalLayer("produktionsstaette", fieldTypeConversions); + var produktionsstaetteLayer = CreateGdalLayer("produktionsstaette", fieldTypeConversions, false, true); produktionsstaetteLayer.CopyFeatures(); - produktionsstaetteLayer.ConvertMultiPartToSinglePartGeometry(); using var isDefinitivFieldDefinition = new FieldDefn("ist_definitiv", FieldType.OFTInteger); isDefinitivFieldDefinition.SetSubType(FieldSubType.OFSTInt16); fieldTypeConversions.Add(isDefinitivFieldDefinition.GetName(), isDefinitivFieldDefinition); - var bewirtschaftungseinheitLayer = CreateGdalLayer("bewirtschaftungseinheit", fieldTypeConversions, ["identifikator_be"]); + var bewirtschaftungseinheitLayer = CreateGdalLayer("bewirtschaftungseinheit", fieldTypeConversions, ["identifikator_be"], false, true); bewirtschaftungseinheitLayer.CopyFeatures(); - bewirtschaftungseinheitLayer.ConvertMultiPartToSinglePartGeometry(); return Task.CompletedTask; } diff --git a/Geodatenbezug/Processors/BiodiversitaetsfoerderflaechenProcessor.cs b/Geodatenbezug/Processors/BiodiversitaetsfoerderflaechenProcessor.cs index e9f6ebb..437eb62 100644 --- a/Geodatenbezug/Processors/BiodiversitaetsfoerderflaechenProcessor.cs +++ b/Geodatenbezug/Processors/BiodiversitaetsfoerderflaechenProcessor.cs @@ -30,18 +30,14 @@ protected override Task ProcessTopicAsync() { beitragsberechtigtFieldDefinition.GetName(), beitragsberechtigtFieldDefinition }, }; - var bffVernetzungFlaechenLayer = CreateGdalLayer("bff_vernetzung_flaechen", fieldTypeConversions); + var bffVernetzungFlaechenLayer = CreateGdalLayer("bff_vernetzung_flaechen", fieldTypeConversions, true, true); bffVernetzungFlaechenLayer.CopyFeatures(); - bffVernetzungFlaechenLayer.FilterLnfCodes(); - bffVernetzungFlaechenLayer.ConvertMultiPartToSinglePartGeometry(); using var nhgFieldDefinition = new FieldDefn("nhg", FieldType.OFTInteger); nhgFieldDefinition.SetSubType(FieldSubType.OFSTInt16); fieldTypeConversions.Add(nhgFieldDefinition.GetName(), nhgFieldDefinition); - var bffQualitaet2FlaechenLayer = CreateGdalLayer("bff_qualitaet_2_flaechen", fieldTypeConversions); + var bffQualitaet2FlaechenLayer = CreateGdalLayer("bff_qualitaet_2_flaechen", fieldTypeConversions, true, true); bffQualitaet2FlaechenLayer.CopyFeatures(); - bffQualitaet2FlaechenLayer.FilterLnfCodes(); - bffQualitaet2FlaechenLayer.ConvertMultiPartToSinglePartGeometry(); return Task.CompletedTask; } diff --git a/Geodatenbezug/Processors/GdalLayer.cs b/Geodatenbezug/Processors/GdalLayer.cs index a55a502..f33c07f 100644 --- a/Geodatenbezug/Processors/GdalLayer.cs +++ b/Geodatenbezug/Processors/GdalLayer.cs @@ -13,6 +13,9 @@ public class GdalLayer private readonly Layer inputLayer; private readonly Layer processingLayer; + private readonly bool filterLnfCodes; + private readonly bool convertMultiToSinglePartGeometries; + /// /// The for the input data. /// @@ -21,11 +24,14 @@ public class GdalLayer /// /// Initializes a new instance of the class. /// - public GdalLayer(Layer inputLayer, Layer processingLayer, Dictionary fieldTypeConversions, List fieldsToDrop) + public GdalLayer(Layer inputLayer, Layer processingLayer, Dictionary fieldTypeConversions, List fieldsToDrop, bool filterLnfCodes, bool convertMultiToSinglePartGeometries) { this.inputLayer = inputLayer; this.processingLayer = processingLayer; + this.filterLnfCodes = filterLnfCodes; + this.convertMultiToSinglePartGeometries = convertMultiToSinglePartGeometries; + var inputLayerDefinition = inputLayer.GetLayerDefn(); using var tIdFieldDefinition = new FieldDefn(TIdFieldName, FieldType.OFTString); @@ -63,9 +69,18 @@ public void CopyFeatures() for (var i = 0; i < inputLayer.GetFeatureCount(1); i++) { var inputFeature = inputLayer.GetNextFeature(); + + if (filterLnfCodes) + { + var lnfCode = inputFeature.GetFieldAsInteger("lnf_code"); + if ((lnfCode >= 921 && lnfCode <= 928) || lnfCode == 950 || lnfCode == 951) + { + continue; + } + } + var processingLayerDefinition = processingLayer.GetLayerDefn(); using var newFeature = new Feature(processingLayerDefinition); - newFeature.SetGeometry(inputFeature.GetGeometryRef()); for (var j = 0; j < processingLayerDefinition.GetFieldCount(); j++) { @@ -119,23 +134,44 @@ public void CopyFeatures() } } - processingLayer.CreateFeature(newFeature); - } - } + if (!inputFeature.GetGeometryRef().IsValid()) + { + throw new InvalidGeometryException(newFeature.GetFieldAsInteger(TIdFieldName)); + } - /// - /// Remove features from the layer that have a specific LNF code (921-928, 950, 951). - /// - public void FilterLnfCodes() - { - processingLayer.FilterLnfCodes(); - } + newFeature.SetGeometry(inputFeature.GetGeometryRef()); - /// - /// Convert multipart geometries to singlepart geometries. - /// - public void ConvertMultiPartToSinglePartGeometry() - { - processingLayer.ConvertMultiPartToSinglePartGeometry(); + if (convertMultiToSinglePartGeometries) + { + var geometry = newFeature.GetGeometryRef(); + if (geometry.GetGeometryCount() > 1) + { + for (var j = 0; j < geometry.GetGeometryCount(); j++) + { + var singlePartGeometry = geometry.GetGeometryRef(j); + var singlePartGeometryType = singlePartGeometry.GetGeometryType(); + if (singlePartGeometry.IsValid() && (singlePartGeometryType == wkbGeometryType.wkbPolygon || singlePartGeometryType == wkbGeometryType.wkbCurvePolygon)) + { + using var newSinglePartFeature = newFeature.Clone(); + newSinglePartFeature.SetFID(-1); + newSinglePartFeature.SetGeometry(singlePartGeometry); + processingLayer.CreateFeature(newSinglePartFeature); + } + else + { + throw new InvalidGeometryException(newFeature.GetFieldAsInteger(TIdFieldName)); + } + } + } + else + { + processingLayer.CreateFeature(newFeature); + } + } + else + { + processingLayer.CreateFeature(newFeature); + } + } } } diff --git a/Geodatenbezug/Processors/InvalidGeometryException.cs b/Geodatenbezug/Processors/InvalidGeometryException.cs new file mode 100644 index 0000000..98f98d5 --- /dev/null +++ b/Geodatenbezug/Processors/InvalidGeometryException.cs @@ -0,0 +1,49 @@ +namespace Geodatenbezug.Processors; + +/// +/// The exception that is thrown when a geometry is invalid. +/// +public class InvalidGeometryException : Exception +{ + /// + /// Initializes a new instance of the class. + /// + public InvalidGeometryException() + { + } + + /// + /// Initializes a new instance of the class with a specified feature ID. + /// + /// The feature ID. + public InvalidGeometryException(int featureId) + : base(BuildMessage(featureId)) + { + } + + /// + /// Initializes a new instance of the class with a specified message. + /// + /// The message. + public InvalidGeometryException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class with a specified message and inner exception. + /// + /// The message. + /// The inner exception. + public InvalidGeometryException(string message, Exception innerException) + : base(message, innerException) + { + } + + /// + /// Returns the message with the specified feature ID. + /// + /// The feature ID. + /// The exception message. + internal static string BuildMessage(int featureId) => $"Invalid geometry for feature with ID {featureId}"; +} diff --git a/Geodatenbezug/Processors/LayerExtensions.cs b/Geodatenbezug/Processors/LayerExtensions.cs deleted file mode 100644 index e9f97b1..0000000 --- a/Geodatenbezug/Processors/LayerExtensions.cs +++ /dev/null @@ -1,52 +0,0 @@ -using OSGeo.OGR; - -namespace Geodatenbezug.Processors; - -/// -/// Provides extension methods for . -/// -public static class LayerExtensions -{ - /// - /// Remove features from the layer that have a specific LNF code (921-928, 950, 951). - /// - public static void FilterLnfCodes(this Layer layer) - { - layer.ResetReading(); - for (var i = 0; i < layer.GetFeatureCount(1); i++) - { - var feature = layer.GetNextFeature(); - var lnfCode = feature.GetFieldAsInteger("lnf_code"); - if ((lnfCode >= 921 && lnfCode <= 928) || lnfCode == 950 || lnfCode == 951) - { - layer.DeleteFeature(feature.GetFID()); - } - } - } - - /// - /// Convert multipart geometries to singlepart geometries. - /// - public static void ConvertMultiPartToSinglePartGeometry(this Layer layer) - { - layer.ResetReading(); - for (var i = 0; i < layer.GetFeatureCount(1); i++) - { - var feature = layer.GetNextFeature(); - var geometry = feature.GetGeometryRef(); - - if (geometry.GetGeometryCount() > 1) - { - for (var j = 0; j < geometry.GetGeometryCount(); j++) - { - using var newFeature = feature.Clone(); - newFeature.SetFID(-1); - newFeature.SetGeometry(geometry.GetGeometryRef(j)); - layer.CreateFeature(newFeature); - } - - layer.DeleteFeature(feature.GetFID()); - } - } - } -} diff --git a/Geodatenbezug/Processors/NutzungsflaechenProcessor.cs b/Geodatenbezug/Processors/NutzungsflaechenProcessor.cs index 88ed5b6..72b5c97 100644 --- a/Geodatenbezug/Processors/NutzungsflaechenProcessor.cs +++ b/Geodatenbezug/Processors/NutzungsflaechenProcessor.cs @@ -77,11 +77,9 @@ protected async override Task ProcessTopicAsync() "schnittzeitpunkt", }; - var nutzungsflaechenTempLayer = CreateGdalLayer(NutzungsflaechenLayerName, fieldTypeConversions, fieldsToDrop); + var nutzungsflaechenTempLayer = CreateGdalLayer(NutzungsflaechenLayerName, fieldTypeConversions, fieldsToDrop, true, true); Logger.LogInformation($"{Topic.TopicTitle} ({Topic.Canton}): Kopiere Features aus dem GPKG in die GDB"); nutzungsflaechenTempLayer.CopyFeatures(); - Logger.LogInformation($"{Topic.TopicTitle} ({Topic.Canton}): Filtere LNF-Codes"); - nutzungsflaechenTempLayer.FilterLnfCodes(); // Create a temporary layer with data from the nutzungsart catalog await CreateNutzungsartLayerAsync().ConfigureAwait(false); @@ -176,9 +174,6 @@ protected async override Task ProcessTopicAsync() nutzungsflaechenLayer.CreateFeature(newFeature); } - Logger.LogInformation($"{Topic.TopicTitle} ({Topic.Canton}): Konvertiere Multi- zu Singlepart-Geometrien"); - nutzungsflaechenLayer.ConvertMultiPartToSinglePartGeometry(); - Logger.LogInformation($"{Topic.TopicTitle} ({Topic.Canton}): Lösche temporäre Layer"); // Delete the temporary work layers diff --git a/Geodatenbezug/Processors/PerimeterLnSfProcessor.cs b/Geodatenbezug/Processors/PerimeterLnSfProcessor.cs index ad488ee..9eb4b27 100644 --- a/Geodatenbezug/Processors/PerimeterLnSfProcessor.cs +++ b/Geodatenbezug/Processors/PerimeterLnSfProcessor.cs @@ -17,9 +17,8 @@ protected override Task ProcessTopicAsync() { { bezugsJahrFieldDefinition.GetName(), bezugsJahrFieldDefinition }, }; - var perimeterLnSfLayer = CreateGdalLayer("perimeter_ln_sf", fieldTypeConversions); + var perimeterLnSfLayer = CreateGdalLayer("perimeter_ln_sf", fieldTypeConversions, false, true); perimeterLnSfLayer.CopyFeatures(); - perimeterLnSfLayer.ConvertMultiPartToSinglePartGeometry(); return Task.CompletedTask; } diff --git a/Geodatenbezug/Processors/PerimeterTerrassenrebenProcessor.cs b/Geodatenbezug/Processors/PerimeterTerrassenrebenProcessor.cs index 171a166..c4996f6 100644 --- a/Geodatenbezug/Processors/PerimeterTerrassenrebenProcessor.cs +++ b/Geodatenbezug/Processors/PerimeterTerrassenrebenProcessor.cs @@ -20,9 +20,8 @@ protected override Task ProcessTopicAsync() { aenderungsdatumFieldDefinition.GetName(), aenderungsdatumFieldDefinition }, }; - var perimeterTerrassenrebenLayer = CreateGdalLayer("perimeter_terrassenreben", fieldTypeConversions); + var perimeterTerrassenrebenLayer = CreateGdalLayer("perimeter_terrassenreben", fieldTypeConversions, false, true); perimeterTerrassenrebenLayer.CopyFeatures(); - perimeterTerrassenrebenLayer.ConvertMultiPartToSinglePartGeometry(); return Task.CompletedTask; } diff --git a/Geodatenbezug/Processors/RebbaukatasterProcessor.cs b/Geodatenbezug/Processors/RebbaukatasterProcessor.cs index 31b901c..98e8bf5 100644 --- a/Geodatenbezug/Processors/RebbaukatasterProcessor.cs +++ b/Geodatenbezug/Processors/RebbaukatasterProcessor.cs @@ -18,9 +18,8 @@ protected override Task ProcessTopicAsync() { aenderungsdatumFieldDefinition.GetName(), aenderungsdatumFieldDefinition }, }; - var rebbaukatasterLayer = CreateGdalLayer("rebbaukataster", fieldTypeConversions); + var rebbaukatasterLayer = CreateGdalLayer("rebbaukataster", fieldTypeConversions, false, true); rebbaukatasterLayer.CopyFeatures(); - rebbaukatasterLayer.ConvertMultiPartToSinglePartGeometry(); return Task.CompletedTask; } diff --git a/Geodatenbezug/Processors/TopicProcessor.cs b/Geodatenbezug/Processors/TopicProcessor.cs index c5b5769..7b1c7df 100644 --- a/Geodatenbezug/Processors/TopicProcessor.cs +++ b/Geodatenbezug/Processors/TopicProcessor.cs @@ -211,15 +211,15 @@ protected internal async Task RunGdalProcessingAsync() /// /// Creates a new GDAL layer for processing. /// - public GdalLayer CreateGdalLayer(string layerName, Dictionary? fieldTypeConversions) + public GdalLayer CreateGdalLayer(string layerName, Dictionary? fieldTypeConversions, bool filterLnfCodes, bool convertMultiToSinglePartGeometries) { - return CreateGdalLayer(layerName, fieldTypeConversions, []); + return CreateGdalLayer(layerName, fieldTypeConversions, [], filterLnfCodes, convertMultiToSinglePartGeometries); } /// /// Creates a new GDAL layer for processing. /// - public GdalLayer CreateGdalLayer(string layerName, Dictionary? fieldTypeConversions, List fieldsToDrop) + public GdalLayer CreateGdalLayer(string layerName, Dictionary? fieldTypeConversions, List fieldsToDrop, bool filterLnfCodes, bool convertMultiToSinglePartGeometries) { var inputLayer = InputDataSource.GetLayerByName(layerName); @@ -229,7 +229,7 @@ public GdalLayer CreateGdalLayer(string layerName, Dictionary var processingLayer = ProcessingDataSource.CreateLayer(layerName, inputLayer.GetSpatialRef(), geometryType, []); fieldTypeConversions ??= []; - return new GdalLayer(inputLayer, processingLayer, fieldTypeConversions, fieldsToDrop); + return new GdalLayer(inputLayer, processingLayer, fieldTypeConversions, fieldsToDrop, filterLnfCodes, convertMultiToSinglePartGeometries); } ///