mirror of
https://github.com/bvanroll/cs-map-project.git
synced 2025-09-01 21:32:42 +00:00
dit zou normaal gezien correcter moeten scalen, maar nu moet ik mijn scale methode nog fixen
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GeoJSON.Net.Geometry;
|
||||
|
||||
namespace Globals
|
||||
@@ -15,35 +14,38 @@ namespace Globals
|
||||
{
|
||||
PolygonPunten = polygonPunten;
|
||||
Naam = naam;
|
||||
VindMaximumEnMinimum(polygonPunten);
|
||||
UpdateMaximumEnMinimum();
|
||||
}
|
||||
|
||||
public MultiPolygonPunten(MultiPolygon multiPolygon, string naam = "")
|
||||
{
|
||||
Naam = naam;
|
||||
PolygonPunten = new List<PolygonPunten>();
|
||||
bool reverse = true;
|
||||
foreach (Polygon polygon in multiPolygon.Coordinates)
|
||||
{
|
||||
PolygonPunten.Add(new PolygonPunten(polygon, naam));
|
||||
}
|
||||
VindMaximumEnMinimum(PolygonPunten);
|
||||
bool sw = false;
|
||||
foreach (PolygonPunten p in PolygonPunten)
|
||||
{
|
||||
if (sw) p.Punten.Reverse();
|
||||
sw = !sw;
|
||||
PolygonPunten p = new PolygonPunten(polygon, naam, reverse);
|
||||
PolygonPunten.Add(p);
|
||||
reverse = !reverse; //reverse parameter voor polygonpunten is sneler dan
|
||||
UpdateMaximumEnMinimum(p);
|
||||
}
|
||||
}
|
||||
|
||||
private void VindMaximumEnMinimum(List<PolygonPunten> polygonPunten)
|
||||
private void UpdateMaximumEnMinimum(PolygonPunten polygon)
|
||||
{
|
||||
MaximumX = polygonPunten.Max(p => p.MaximumX);
|
||||
MaximumY = polygonPunten.Max(p => p.MaximumY);
|
||||
MinimumX = polygonPunten.Max(p => p.MinimumX);
|
||||
MinimumY = polygonPunten.Max(p => p.MinimumY);
|
||||
|
||||
if (polygon.MaximumX > MaximumX) MaximumX = polygon.MaximumX;
|
||||
else if (polygon.MinimumX < MinimumX) MinimumX = polygon.MinimumX;
|
||||
if (polygon.MaximumY > MaximumY) MaximumY = polygon.MaximumY;
|
||||
else if (polygon.MinimumY < MinimumY) MinimumY = polygon.MinimumY;
|
||||
}
|
||||
|
||||
public void UpdateMaximumEnMinimum()
|
||||
{
|
||||
foreach (PolygonPunten polygon in PolygonPunten)
|
||||
{
|
||||
UpdateMaximumEnMinimum(polygon);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Shapes;
|
||||
using GeoJSON.Net.Geometry;
|
||||
namespace Globals
|
||||
{
|
||||
@@ -17,36 +14,67 @@ namespace Globals
|
||||
{
|
||||
Punten = punten;
|
||||
Naam = naam;
|
||||
MaximumX = punten.Max(punt => punt.X);
|
||||
MaximumY = punten.Max(punt => punt.Y);
|
||||
MinimumX = punten.Min(punt => punt.X);
|
||||
MinimumY = punten.Min(punt => punt.Y);
|
||||
UpdateMaxEnMinPunt();
|
||||
}
|
||||
|
||||
public PolygonPunten(GeoJSON.Net.Geometry.Polygon p, string naam = "")
|
||||
public PolygonPunten(GeoJSON.Net.Geometry.Polygon polygon, string naam = "", bool reverse = true)
|
||||
{
|
||||
Naam = naam;
|
||||
Punten = new List<Punt>();
|
||||
foreach (LineString l in p.Coordinates)
|
||||
|
||||
foreach (LineString linestring in polygon.Coordinates)
|
||||
{
|
||||
foreach (Position pos in l.Coordinates)
|
||||
if (reverse)
|
||||
{
|
||||
Punt pu = new Punt(pos.Longitude, pos.Latitude, naam);
|
||||
if (!Punten.Contains(pu)) Punten.Add(pu); //dit vertraagd programma enorm, maar zorgt ervoor dat peuker beter werkt denk ik
|
||||
//de vertraging komt vooral door de .Contains methode, deze mag weggelaten worden voor snelheid maar peuker zal niet meer zo goed werken
|
||||
foreach (Position positie in linestring.Coordinates.Reverse()) //sneller om eerst te reversen dan tegen einde deze bewerking te doen
|
||||
{
|
||||
Punt punt = new Punt(positie.Longitude, positie.Latitude, naam);
|
||||
|
||||
if (!Punten.Contains(punt)) {
|
||||
Punten.Add(punt); //dit vertraagd programma enorm, maar zorgt ervoor dat peuker beter werkt denk ik
|
||||
UpdateMaxEnMinPunt(punt); //sneller dan eindigen met punten.max en punten.min
|
||||
}
|
||||
//de vertraging komt vooral door de .Contains methode, deze mag weggelaten worden voor snelheid maar peuker zal niet meer zo goed werken
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Position positie in linestring.Coordinates)
|
||||
{
|
||||
Punt punt = new Punt(positie.Longitude, positie.Latitude, naam);
|
||||
|
||||
if (!Punten.Contains(punt)) {
|
||||
Punten.Add(punt); //dit vertraagd programma enorm, maar zorgt ervoor dat peuker beter werkt denk ik
|
||||
UpdateMaxEnMinPunt(punt); //sneller dan eindigen met punten.max en punten.min
|
||||
}
|
||||
//de vertraging komt vooral door de .Contains methode, deze mag weggelaten worden voor snelheid maar peuker zal niet meer zo goed werken
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Punten.Reverse();
|
||||
MaximumX = Punten.Max(punt => punt.X);
|
||||
MaximumY = Punten.Max(punt => punt.Y);
|
||||
MinimumX = Punten.Min(punt => punt.X);
|
||||
MinimumY = Punten.Min(punt => punt.Y);
|
||||
}
|
||||
|
||||
private void UpdateMaxEnMinPunt(Punt punt)
|
||||
{
|
||||
if (punt.X > MaximumX) MaximumX = punt.X;
|
||||
else if (punt.X < MinimumX) MinimumX = punt.X;
|
||||
if (punt.Y > MaximumY) MaximumY = punt.Y;
|
||||
else if (punt.Y < MinimumY) MinimumY = punt.Y;
|
||||
}
|
||||
|
||||
public void UpdateMaxEnMinPunt()
|
||||
{
|
||||
foreach (Punt punt in Punten)
|
||||
{
|
||||
UpdateMaxEnMinPunt(punt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.Equals(Naam, "", StringComparison.Ordinal)) return "UNKNOWN";
|
||||
else return Naam;
|
||||
return Naam;
|
||||
}
|
||||
|
||||
public MultiPolygonPunten ToMultiPolygonPunten()
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Globals
|
||||
@@ -16,8 +12,8 @@ namespace Globals
|
||||
Naam = naam;
|
||||
if (Graden)
|
||||
{
|
||||
X = ConvertToRadians(x) * 100;
|
||||
Y = ConvertToRadians(y) * 100;
|
||||
X = ConvertToPercentage(x) * 100;
|
||||
Y = ConvertToPercentage(y) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -32,9 +28,10 @@ namespace Globals
|
||||
else return Naam;
|
||||
}
|
||||
|
||||
public double ConvertToRadians(double angle)
|
||||
public double ConvertToPercentage(double angle)
|
||||
{
|
||||
return (Math.PI / 180) * angle;
|
||||
if (angle < 0) angle += 360;
|
||||
return angle / 360;
|
||||
}
|
||||
|
||||
public Point ToPoint()
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -32,7 +32,7 @@ namespace Logica
|
||||
}
|
||||
|
||||
//oude schaalmethodes
|
||||
public PolygonPunten ScalePolygon(PolygonPunten polygon, double scaleX, double scaleY, double offsetX = 180, double offsetY = 180)
|
||||
public PolygonPunten ScalePolygon(PolygonPunten polygon, double scaleX, double scaleY, double offsetX = 0, double offsetY = 0)
|
||||
{
|
||||
double maxX = polygon.MaximumX - polygon.MinimumX;
|
||||
double maxY = polygon.MaximumY - polygon.MinimumY;
|
||||
@@ -59,8 +59,8 @@ namespace Logica
|
||||
}
|
||||
|
||||
//lat en long = graden, graden => coords (/360 * scale?
|
||||
private static Punt ScalePoint(double scaleX, double scaleY, Punt punt, double maxX = 360, double maxY = 360, double offsetX = 180, double
|
||||
offsetY = 180, double minX = 0, double minY = 0)
|
||||
private static Punt ScalePoint(double scaleX, double scaleY, Punt punt, double maxX = 1, double maxY = 1, double offsetX = 0, double
|
||||
offsetY = 0, double minX = 0, double minY = 0)
|
||||
{
|
||||
double x = punt.X - minX;
|
||||
x /= maxX;
|
||||
@@ -115,6 +115,8 @@ namespace Logica
|
||||
double maxY = multiPolygons.Max(m => m.MaximumY);
|
||||
double minX = multiPolygons.Min(m => m.MinimumX);
|
||||
double minY = multiPolygons.Min(m => m.MinimumY);
|
||||
maxX -= minX;
|
||||
maxY -= minY;
|
||||
List<MultiPolygonPunten> mpps = new List<MultiPolygonPunten>();
|
||||
foreach (MultiPolygonPunten mp in multiPolygons)
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,22 +2,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Globals;
|
||||
using Brush = System.Windows.Media.Brush;
|
||||
@@ -118,6 +106,19 @@ namespace opdracht2
|
||||
//als een land geselecteerd wordt in lijst runned deze functie
|
||||
|
||||
|
||||
|
||||
//voorbereiding van scale waarden.
|
||||
|
||||
double scaleX = (c.ActualHeight > c.ActualWidth) ? c.ActualWidth : c.ActualHeight;
|
||||
double scaleY = (c.ActualHeight > c.ActualWidth) ? c.ActualWidth : c.ActualHeight;
|
||||
scaleX /= 2;
|
||||
scaleY /= 2;
|
||||
double offsetX = scaleX; //vroeger c.ActualWidth/2
|
||||
double offsetY = scaleY;
|
||||
//dit zorgt voor evenredige scaling zonder stretching. als men wel stretching wilt gebruiken:
|
||||
// scaleX = c.ActualWidth;
|
||||
// scaleY = c.ActualHeight;
|
||||
|
||||
//is er meer dan 1 land geselecteerd
|
||||
if (lb.SelectedItems.Count >1)
|
||||
{
|
||||
@@ -135,7 +136,7 @@ namespace opdracht2
|
||||
}
|
||||
|
||||
//scale de polygon als de checkbox aan staat
|
||||
if (scale.IsChecked == true) mpps = pm.ScaleMultiPolygons(mpps, c.ActualWidth/2, c.ActualHeight/2, 0, 0);
|
||||
if (scale.IsChecked == true) mpps = pm.ScaleMultiPolygons(mpps, scaleX, scaleY, offsetX, offsetY);
|
||||
|
||||
foreach(MultiPolygonPunten mp in mpps)
|
||||
{
|
||||
@@ -170,7 +171,7 @@ namespace opdracht2
|
||||
Debug.WriteLine(lb.SelectedItem.GetType().Name); // voor debug redenen schrijf naam naar console
|
||||
c.Children.Clear(); // delete alle vorige afbeeldingen
|
||||
MultiPolygonPunten mp = (MultiPolygonPunten)lb.SelectedItem; //haal multipolygon uit lijst
|
||||
if (scale.IsChecked == true) mp = pm.ScaleMultiPolygon(mp, c.ActualWidth / 2, c.ActualHeight / 2, 0, 0); //schaal multipolygon
|
||||
if (scale.IsChecked == true) mp = pm.ScaleMultiPolygon(mp, scaleX, scaleY, offsetX, offsetY); //schaal multipolygon
|
||||
if (peuker.IsChecked == true) mp = pm.Peuker(mp, peukerPercent.Value/1000); // als peuker (puntvermindering) moet gebeuren, doe dit hier
|
||||
foreach (PolygonPunten pp in mp.PolygonPunten) //loop doorheen polygons in multipolygon
|
||||
{
|
||||
@@ -192,7 +193,8 @@ namespace opdracht2
|
||||
Debug.WriteLine(lb.SelectedItem.GetType().Name);
|
||||
c.Children.Clear(); //delete alle vorige afbeeldingen
|
||||
PolygonPunten p = (PolygonPunten)lb.SelectedItem; // haal land uit lijst
|
||||
if (scale.IsChecked == true) p = pm.ScalePolygon(p, c.ActualWidth/2, c.ActualHeight/2, 0, 0); // schaal polygon
|
||||
|
||||
if (scale.IsChecked == true) p = pm.ScalePolygon(p, scaleX, scaleY, offsetX, offsetY); // schaal polygon
|
||||
if (peuker.IsChecked == true) p = pm.Peuker(p, peukerPercent.Value / 1000); // peuker (puntvermindering)
|
||||
if (triangulate.IsChecked == true) //triangulation check
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,6 +5,7 @@
|
||||
},
|
||||
"projects": {
|
||||
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj",
|
||||
"projectName": "Datalaag",
|
||||
@@ -24,6 +25,7 @@
|
||||
}
|
||||
},
|
||||
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj",
|
||||
"projectName": "Globals",
|
||||
@@ -34,6 +36,7 @@
|
||||
}
|
||||
},
|
||||
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj",
|
||||
"projectName": "Logica",
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Beppe\.nuget\packages\</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "Zy6jypDVLiSwLfNswZHvoD7ul/+NOG2AgIE/eLzWMMgAaQ+TzAjn3Or2nqa6RpIYT9zQrkp/4+yCHo1D0FoSMQ==",
|
||||
"dgSpecHash": "p426YNxR+un7rXUpsV3S3g0htKyuFPUxB5pYHNl1fsHxje10LlIJDBLjupJb2IZCMEZ+Cv3TXWBEUMbbMYO5hA==",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\opdracht2\\opdracht2.csproj",
|
||||
"expectedPackageFiles": [
|
||||
|
Reference in New Issue
Block a user