mirror of
https://github.com/bvanroll/cs-map-project.git
synced 2025-08-29 20:02:43 +00:00
can you listen? pls
This commit is contained in:
31
Datalaag/MultiPolygonPunten.cs
Normal file
31
Datalaag/MultiPolygonPunten.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GeoJSON.Net.Geometry;
|
||||
|
||||
namespace Datalaag
|
||||
{
|
||||
public class MultiPolygonPunten
|
||||
{
|
||||
public List<PolygonPunten> PolygonPunten;
|
||||
|
||||
public string Naam;
|
||||
|
||||
|
||||
public MultiPolygonPunten(MultiPolygon multiPolygon, string naam = "")
|
||||
{
|
||||
PolygonPunten = new List<PolygonPunten>();
|
||||
Naam = naam;
|
||||
foreach (Polygon polygon in multiPolygon.Coordinates)
|
||||
{
|
||||
PolygonPunten.Add(new PolygonPunten(polygon, naam));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.Equals(Naam, "", StringComparison.Ordinal)) return "UNKNOWN";
|
||||
else return Naam;
|
||||
}
|
||||
}
|
||||
}
|
66
Datalaag/PolygonPunten.cs
Normal file
66
Datalaag/PolygonPunten.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GeoJSON.Net.Geometry;
|
||||
|
||||
namespace Datalaag
|
||||
{
|
||||
public class PolygonPunten
|
||||
{
|
||||
public double MinimumXWaarde, MinimumYWaarde, MaximumXWaarde, MaximumYWaarde;
|
||||
public List<Punt> Punten;
|
||||
public string Naam;
|
||||
|
||||
|
||||
public PolygonPunten(Polygon polygon, string naam = "")
|
||||
{
|
||||
Naam = naam;
|
||||
MinimumXWaarde = double.MaxValue;
|
||||
MinimumYWaarde = double.MaxValue;
|
||||
MaximumXWaarde = double.MinValue;
|
||||
MaximumYWaarde = double.MinValue;
|
||||
LeesPuntenVanPolygon(polygon);
|
||||
|
||||
}
|
||||
|
||||
public PolygonPunten(List<Punt> polygon, string naam = "")
|
||||
{
|
||||
Naam = naam;
|
||||
Punten = polygon;
|
||||
MaximumXWaarde = Punten.Max(p => p.X);
|
||||
MinimumXWaarde = Punten.Min(p => p.X);
|
||||
MaximumYWaarde = Punten.Max(p => p.Y);
|
||||
MinimumYWaarde = Punten.Min(p => p.Y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void LeesPuntenVanPolygon(Polygon polygon)
|
||||
{
|
||||
foreach (LineString lijn in polygon.Coordinates)
|
||||
{
|
||||
foreach (Position positie in lijn.Coordinates)
|
||||
{
|
||||
CheckMinMaxWaarden(positie);
|
||||
Punten.Add(new Punt(positie.Longitude, positie.Latitude, Naam));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckMinMaxWaarden(Position positie)
|
||||
{
|
||||
if (positie.Longitude > MaximumXWaarde) MaximumXWaarde = positie.Longitude;
|
||||
if (positie.Longitude < MinimumXWaarde) MinimumXWaarde = positie.Longitude;
|
||||
if (positie.Latitude > MaximumYWaarde) MaximumYWaarde = positie.Latitude;
|
||||
if (positie.Latitude < MinimumYWaarde) MinimumYWaarde = positie.Latitude;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.Equals(Naam, "", StringComparison.Ordinal)) return "UNKNOWN";
|
||||
else return Naam;
|
||||
}
|
||||
}
|
||||
}
|
22
Datalaag/Punt.cs
Normal file
22
Datalaag/Punt.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Datalaag
|
||||
{
|
||||
public class Punt
|
||||
{
|
||||
public double X, Y;
|
||||
public string Naam;
|
||||
public Punt(double x, double y, string naam = "")
|
||||
{
|
||||
Naam = naam;
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.Equals(Naam, "", StringComparison.Ordinal)) return "UNKNOWN";
|
||||
else return Naam;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user