Skip to content

Commit

Permalink
Do not display null geometries (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
danjov authored Jul 5, 2022
1 parent e085bb1 commit 02137cd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
20 changes: 11 additions & 9 deletions src/ClientApp/src/components/MainMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,17 @@ export default function MainMap(props) {
let parsedFeatures;
let bohrungen = standorte?.flatMap((s) => s.bohrungen);
if (bohrungen.length) {
parsedFeatures = bohrungen.map(
(f) =>
new Feature({
geometry: new Point([f.geometrie.coordinates[0], f.geometrie.coordinates[1]]),
Id: f.id,
Bezeichnung: f.bezeichnung,
"Standort Id": f.standortId,
})
);
parsedFeatures = bohrungen
.filter((f) => f.geometrie)
.map(
(f) =>
new Feature({
geometry: new Point([f.geometrie.coordinates[0], f.geometrie.coordinates[1]]),
Id: f.id,
Bezeichnung: f.bezeichnung,
"Standort Id": f.standortId,
})
);
} else {
parsedFeatures = [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/EwsContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static void SeedData(this EwsContext context)
.RuleFor(o => o.HQualitaetId, f => 3)
.RuleFor(o => o.HQualitaet, _ => default!)
.RuleFor(o => o.HAblenkung, f => 9)
.RuleFor(o => o.Geometrie, f => new Point(new Coordinate(f.Random.Int(2592400, 2644800), f.Random.Int(1213500, 1261500)))) // Geometries in bounding box of Kanton Solothurn
.RuleFor(o => o.Geometrie, f => f.PickRandomParam(new Point(new Coordinate(f.Random.Int(2592400, 2644800), f.Random.Int(1213500, 1261500)))).OrNull(f, .05f)) // Geometries in bounding box of Kanton Solothurn
.RuleFor(o => o.StandortId, f => f.PickRandom(standorteRange))
.RuleFor(o => o.Bohrprofile, _ => default!);

Expand Down
2 changes: 1 addition & 1 deletion tests/ExportControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public async Task GetAsync()
var expectedHeader = "standort.standort_id,standort.bezeichnung,standort.bemerkung,standort.anzbohrloch,standort.gbnummer,standort.freigabe_afu,standort.afu_usr,standort.afu_date,bohrung.bohrung_id,bohrung.bezeichnung,bohrung.bemerkung,bohrung.datum,bohrung.durchmesserbohrloch,bohrung.ablenkung,bohrung.quali,bohrung.qualibem,bohrung.quelleref,bohrung.h_quali,bohrung.X,bohrung.Y,bohrprofil.bohrprofil_id,bohrprofil.datum,bohrprofil.bemerkung,bohrprofil.kote,bohrprofil.endtiefe,bohrprofil.tektonik,bohrprofil.fmfelso,bohrprofil.fmeto,bohrprofil.quali,bohrprofil.qualibem,bohrprofil.h_quali,bohrprofil.h_tektonik,bohrprofil.h_fmeto,bohrprofil.h_fmfelso,schicht.schicht_id,schicht.tiefe,schicht.quali,schicht.qualibem,schicht.bemerkung,schicht.h_quali,codeschicht.kurztext,codeschicht.text,codeschicht.sort,vorkommnis.vorkommnis_id,vorkommnis.typ,vorkommnis.tiefe,vorkommnis.bemerkung,vorkommnis.quali,vorkommnis.qualibem,vorkommnis.h_quali,vorkommnis.h_typ";

Assert.AreEqual(expectedHeader, response.Content.Split('\n')[0]);
Assert.AreEqual(31263, response.Content.Split('\n').Length);
Assert.AreEqual(31191, response.Content.Split('\n').Length);
}
}
12 changes: 6 additions & 6 deletions tests/StandortControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task GetAllAsync()
Assert.AreEqual(true, standortToTest.FreigabeAfu);
Assert.AreEqual(2575, standortToTest.Gemeinde);
Assert.AreEqual("iwbyrzqsabb8pd8ahyd2izkurkxu9xt5q60jndil", standortToTest.GrundbuchNr);
Assert.AreEqual(0, standortToTest.Bohrungen.Count);
Assert.AreEqual(1, standortToTest.Bohrungen.Count);
Assert.AreEqual("Carolyn_Lehner5", standortToTest.UserErstellung);
Assert.AreEqual("Kennith.Pollich", standortToTest.UserMutation);
Assert.AreEqual(new DateTime(2021, 3, 6).Date, standortToTest.AfuDatum!.Value.Date);
Expand All @@ -56,7 +56,7 @@ public async Task GetByStandortGrundbuchnummer()
Assert.AreEqual(false, standortToTest.FreigabeAfu);
Assert.AreEqual(2568, standortToTest.Gemeinde);
Assert.AreEqual("vkflnsvlswy1nfbg4kucmk1bwzaqt7c72mba55vu", standortToTest.GrundbuchNr);
Assert.AreEqual(3, standortToTest.Bohrungen.Count);
Assert.AreEqual(2, standortToTest.Bohrungen.Count);
Assert.AreEqual("Elijah_Schmeler31", standortToTest.UserErstellung);
Assert.AreEqual("Josefa_Effertz", standortToTest.UserMutation);
Assert.AreEqual(new DateTime(2021, 2, 12).Date, standortToTest.AfuDatum!.Value.Date);
Expand All @@ -80,7 +80,7 @@ public async Task GetByStandortBezeichnung()
Assert.AreEqual(false, standortToTest.FreigabeAfu);
Assert.AreEqual(2538, standortToTest.Gemeinde);
Assert.AreEqual("2ir0g1jdx6vfw8gpt27vr9keunmrxty6xwea94ce", standortToTest.GrundbuchNr);
Assert.AreEqual(1, standortToTest.Bohrungen.Count);
Assert.AreEqual(2, standortToTest.Bohrungen.Count);
Assert.AreEqual("Beverly.Zulauf", standortToTest.UserErstellung);
Assert.AreEqual("Dusty51", standortToTest.UserMutation);
Assert.AreEqual(new DateTime(2021, 11, 5).Date, standortToTest.AfuDatum!.Value.Date);
Expand All @@ -104,7 +104,7 @@ public async Task GetByErstellungsdatum()
Assert.AreEqual(false, standortToTest.FreigabeAfu);
Assert.AreEqual(2551, standortToTest.Gemeinde);
Assert.AreEqual("rcf2cbp8t8b4amsm2ght9xqh8o3kag52kt5959ag", standortToTest.GrundbuchNr);
Assert.AreEqual(4, standortToTest.Bohrungen.Count);
Assert.AreEqual(2, standortToTest.Bohrungen.Count);
Assert.AreEqual("Mamie_Gutmann", standortToTest.UserErstellung);
Assert.AreEqual("Ernestine21", standortToTest.UserMutation);
Assert.AreEqual(new DateTime(2021, 3, 29, 0, 0, 0, DateTimeKind.Utc).Date, standortToTest.AfuDatum!.Value.Date);
Expand Down Expand Up @@ -151,7 +151,7 @@ public async Task GetBySeveralParameters()
Assert.AreEqual(false, standortToTest.FreigabeAfu);
Assert.AreEqual(2475, standortToTest.Gemeinde);
Assert.AreEqual("wj7qafzqpk7xh0zkt6px3ujisxqqwxbloxeiljz3", standortToTest.GrundbuchNr);
Assert.AreEqual(3, standortToTest.Bohrungen.Count);
Assert.AreEqual(0, standortToTest.Bohrungen.Count);
Assert.AreEqual("Warren54", standortToTest.UserErstellung);
Assert.AreEqual("Abdullah61", standortToTest.UserMutation);
Assert.AreEqual(new DateTime(2021, 8, 31).Date, standortToTest.AfuDatum!.Value.Date);
Expand All @@ -176,7 +176,7 @@ public async Task GetWithEmptyStrings()
Assert.AreEqual(true, standortToTest.FreigabeAfu);
Assert.AreEqual(2575, standortToTest.Gemeinde);
Assert.AreEqual("iwbyrzqsabb8pd8ahyd2izkurkxu9xt5q60jndil", standortToTest.GrundbuchNr);
Assert.AreEqual(0, standortToTest.Bohrungen.Count);
Assert.AreEqual(1, standortToTest.Bohrungen.Count);
Assert.AreEqual("Carolyn_Lehner5", standortToTest.UserErstellung);
Assert.AreEqual("Kennith.Pollich", standortToTest.UserMutation);
Assert.AreEqual(new DateTime(2021, 3, 6).Date, standortToTest.AfuDatum!.Value.Date);
Expand Down

0 comments on commit 02137cd

Please sign in to comment.