Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updates...

  • Loading branch information...
commit 7474c50ee25b36187ed6ba533da260b22b1da083 1 parent 89909cd
@ahzf ahzf authored
View
3  Bragi/Bragi.csproj
@@ -107,6 +107,9 @@
<None Include="PolyfileReader\bremen.poly">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <None Include="PolyfileReader\germany.poly">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="PolyfileReader\hamburg.poly">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
View
240 Bragi/PolyfileReader/PolyfileReader.cs
@@ -120,52 +120,200 @@ public static void Start()
public void Run()
{
- var Filename = "rheinland-pfalz";
-
- var _StopwordFile = new StreamReader("PolyfileReader/" + Filename + ".poly");
-
- var Coordinates = (from _GeoCoordinate
- in _StopwordFile.GetLines().Skip(2)
- where _GeoCoordinate != "END"
- let tmp = GeoCoordinate.ParseString(_GeoCoordinate)
- select new GeoCoordinate(tmp.Longitude, tmp.Latitude)).ToList();
-
-
-
- var Output1 = new StreamWriter("PolyfileReader/" + Filename + ".data");
- var Array = new StringBuilder();
- Coordinates.ForEach(c => Array.AppendLine("\t\t\t{ " + c.Latitude.ToString("00.000000").Replace(",", ".") + ", " + c.Longitude.ToString("00.000000").Replace(",", ".") + " },"));
- Output1.WriteLine(Array.ToString());
- Output1.Flush();
- Output1.Close();
-
- var min_lat = (from c in Coordinates select c.Latitude ).Min();
- var min_lng = (from c in Coordinates select c.Longitude).Min();
- var max_lat = (from c in Coordinates select c.Latitude ).Max();
- var max_lng = (from c in Coordinates select c.Longitude).Max();
-
- var diff_lat = Math.Abs(min_lat - max_lat);
- var diff_lng = Math.Abs(min_lng - max_lng);
-
- var Points = (from coor
- in Coordinates.Skip(1)
- select GeoCalculations.WorldCoordinates_2_Screen(coor, 7)).ToList();
-
- var min_x = (from p in Points select p.Item1).Min();
- var min_y = (from p in Points select p.Item2).Min();
-
- var Language = new StringBuilder();
- var Output2 = new StreamWriter("PolyfileReader/" + Filename + ".geo");
- Language.AppendLine("From: " + max_lat.ToString("00.000000").Replace(",", ".") + ", " + min_lng.ToString("00.000000").Replace(",", "."));
- Language.AppendLine("To: " + min_lat.ToString("00.000000").Replace(",", ".") + ", " + max_lng.ToString("00.000000").Replace(",", "."));
- Language.AppendLine("Diff: " + diff_lat.ToString("00.000000").Replace(",", ".") + ", " + diff_lng.ToString("00.000000").Replace(",", "."));
- var FirstPoint = new Tuple<uint, uint>((Points.First().Item1 - min_x), (Points.First().Item2 - min_y));
- Language.Append("M " + FirstPoint.Item1 + " " + FirstPoint.Item2 + " L ");
- Points.Skip(1).ForEach(p => { Language.Append((p.Item1 - min_x) + " " + (p.Item2 - min_y) + " "); });
- Language.AppendLine("z");
- Output2.WriteLine(Language.ToString());
- Output2.Flush();
- Output2.Close();
+
+ //var _PolyMetaPipe = new PolyReaderMetaPipe(SearchPattern: "PolyfileReader/*.poly",
+ // SearchOption: SearchOption.TopDirectoryOnly);
+
+ //_PolyMetaPipe.SetSource(Directory.GetCurrentDirectory());
+
+ //_PolyMetaPipe.ForEach(s => Console.WriteLine(s));
+
+ foreach (var Filename in new DirectoryInfo(Directory.GetCurrentDirectory()).
+ EnumerateFiles("PolyfileReader/*.poly",
+ SearchOption.TopDirectoryOnly))
+ {
+
+ Console.WriteLine("Processing... " + Filename);
+
+ var Shapes = new Dictionary<UInt32, Tuple<List<GeoCoordinate>, Dictionary<UInt32, Tuple<List<Tuple<UInt64, UInt64>>, StringBuilder>>>>();
+
+ UInt32 Integer = 1;
+ UInt32 ShapeNumber = 1;
+ GeoCoordinate GeoCoordinate = null;
+
+ var min_lat = Double.MaxValue;
+ var min_lng = Double.MaxValue;
+ var max_lat = Double.MinValue;
+ var max_lng = Double.MinValue;
+
+ foreach (var line in new StreamReader("PolyfileReader/" + Filename).GetLines().Skip(1))
+ {
+
+ if (UInt32.TryParse(line, out Integer))
+ {
+ ShapeNumber = Integer;
+ Shapes.Add(ShapeNumber, new Tuple<List<GeoCoordinate>, Dictionary<UInt32, Tuple<List<Tuple<UInt64, UInt64>>, StringBuilder>>>(
+ new List<GeoCoordinate>(),
+ new Dictionary<UInt32, Tuple<List<Tuple<UInt64, UInt64>>, StringBuilder>>()));
+ }
+
+ else if (line == "END")
+ continue;
+
+ else if (GeoCoordinate.TryParseString(line, out GeoCoordinate))
+ {
+
+ // Polyfiles store lng lat!!!
+ Shapes[ShapeNumber].Item1.Add(new GeoCoordinate(GeoCoordinate.Longitude, GeoCoordinate.Latitude));
+
+ if (min_lat > GeoCoordinate.Longitude)
+ min_lat = GeoCoordinate.Longitude;
+
+ if (min_lng > GeoCoordinate.Latitude)
+ min_lng = GeoCoordinate.Latitude;
+
+ if (max_lat < GeoCoordinate.Longitude)
+ max_lat = GeoCoordinate.Longitude;
+
+ if (max_lng < GeoCoordinate.Latitude)
+ max_lng = GeoCoordinate.Latitude;
+
+ }
+
+ }
+
+
+ var Output1 = new StreamWriter("PolyfileReader/" + Filename.Name.Replace(".poly", ".data"));
+ var Array = new StringBuilder();
+
+ var Output2 = new StreamWriter("PolyfileReader/" + Filename.Name.Replace(".poly", ".geo"));
+ var Language = new StringBuilder();
+
+ Shapes.ForEach((shape) =>
+ {
+ Array.AppendLine(shape.Key.ToString());
+ shape.Value.Item1.ForEach(c =>
+ {
+ Array.AppendLine("\t\t\t{ " + c.Latitude.ToString("00.000000").Replace(",", ".") + ", " + c.Longitude.ToString("00.000000").Replace(",", ".") + " },");
+ });
+ });
+
+ Output1.WriteLine(Array.ToString());
+ Output1.Flush();
+ Output1.Close();
+
+
+ var diff_lat = Math.Abs(min_lat - max_lat);
+ var diff_lng = Math.Abs(min_lng - max_lng);
+
+ var min_resolution = 2U;
+ var max_resolution = 23U;
+
+ Output2.WriteLine("From: " + max_lat.ToString("00.000000").Replace(",", ".") + ", " + min_lng.ToString("00.000000").Replace(",", "."));
+ Output2.WriteLine("To: " + min_lat.ToString("00.000000").Replace(",", ".") + ", " + max_lng.ToString("00.000000").Replace(",", "."));
+ Output2.WriteLine("Diff: " + diff_lat.ToString("00.000000").Replace(",", ".") + ", " + diff_lng.ToString("00.000000").Replace(",", "."));
+ Output2.WriteLine("Resolution: " + min_resolution + " -> " + max_resolution);
+
+ Shapes.ForEach((shape) =>
+ {
+
+ for (var resolution = min_resolution; resolution <= max_resolution; resolution++)
+ {
+
+ shape.Value.Item2.Add(resolution, new Tuple<List<Tuple<UInt64, UInt64>>, StringBuilder>(new List<Tuple<UInt64, UInt64>>(), new StringBuilder()));
+
+ shape.Value.Item1.ForEach(coor =>
+ {
+
+ var XY = GeoCalculations.WorldCoordinates_2_Screen(coor, resolution);
+
+ //if (XY.Item1 < min_x) min_x = XY.Item1;
+ //if (XY.Item2 < min_y) min_y = XY.Item2;
+
+ shape.Value.Item2[resolution].Item1.Add(XY);
+
+ });
+
+ //var Char = "M ";
+
+ //shape.Value.Item2[resolution].Item1.ForEach(XY =>
+ //{
+ // shape.Value.Item2[resolution].Item2.Append(Char + (XY.Item1 - min_x) + " " + (XY.Item2 - min_y) + " ");
+ // if (Char == "L ") Char = "";
+ // if (Char == "M ") Char = "L ";
+ //});
+
+ //shape.Value.Item2[resolution].Item2.Append(" Z ");
+
+ }
+
+ });
+
+ var min_x = 0UL;
+ var min_y = 0UL;
+
+ for (var resolution = min_resolution; resolution <= max_resolution; resolution++)
+ {
+
+ min_x = UInt64.MaxValue;
+ min_y = UInt64.MaxValue;
+
+ Shapes.ForEach((shape) =>
+ {
+ shape.Value.Item2[resolution].Item1.ForEach(XY =>
+ {
+ if (XY.Item1 < min_x) min_x = XY.Item1;
+ if (XY.Item2 < min_y) min_y = XY.Item2;
+ });
+ });
+
+ Shapes.ForEach((shape) =>
+ {
+
+ var Char = "M ";
+
+ shape.Value.Item2[resolution].Item1.ForEach(XY =>
+ {
+ shape.Value.Item2[resolution].Item2.Append(Char + (XY.Item1 - min_x) + " " + (XY.Item2 - min_y) + " ");
+ if (Char == "L ") Char = "";
+ if (Char == "M ") Char = "L ";
+ });
+
+ shape.Value.Item2[resolution].Item2.Append("Z ");
+
+ });
+
+ }
+
+
+ var ShapeLanguage = String.Empty;
+
+ for (var resolution = min_resolution; resolution <= max_resolution; resolution++)
+ {
+ ShapeLanguage = "\"";
+ Shapes.ForEach((shape) => ShapeLanguage += shape.Value.Item2[resolution].Item2.ToString().Trim() + " ");
+ Output2.WriteLine(ShapeLanguage.TrimEnd() + "\",");
+ }
+
+
+ //var Points = (from coor
+ // in Coordinates.Skip(1)
+ // select GeoCalculations.WorldCoordinates_2_Screen(coor, 7)).ToList();
+
+ //var min_x = (from p in Points select p.Item1).Min();
+ //var min_y = (from p in Points select p.Item2).Min();
+
+
+ //var FirstPoint = new Tuple<uint, uint>((Points.First().Item1 - min_x), (Points.First().Item2 - min_y));
+ //Language.Append("M " + FirstPoint.Item1 + " " + FirstPoint.Item2 + " L ");
+ //Points.Skip(1).ForEach(p => { Language.Append((p.Item1 - min_x) + " " + (p.Item2 - min_y) + " "); });
+ //Language.AppendLine("z");
+
+ //Output2.WriteLine(Language.ToString());
+ Output2.Flush();
+ Output2.Close();
+
+ }
}
View
16,118 Bragi/PolyfileReader/germany.poly
16,118 additions, 0 deletions not shown
View
26 WPFDemos/AegirWPFMaps/MainWindow.xaml.cs
@@ -65,16 +65,22 @@ public MainWindow()
var feature4a = _FeatureLayer.AddFeature("malmö", 55.618691, 12.999573, 5, 5, Colors.Red);
var feature4b = _HeatmapLayer.AddFeature("malmö", 55.618691, 12.999573, 50, 50, Colors.Brown);
- var feature5a = _ShapeLayer.AddShape(new Thueringen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5b = _ShapeLayer.AddShape(new Bayern (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5c = _ShapeLayer.AddShape(new BadenWuerttemberg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5d = _ShapeLayer.AddShape(new Hessen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5e = _ShapeLayer.AddShape(new Saarland (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5f = _ShapeLayer.AddShape(new Sachsen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5g = _ShapeLayer.AddShape(new SachsenAnhalt (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5h = _ShapeLayer.AddShape(new Berlin (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5i = _ShapeLayer.AddShape(new NordrheinWestfalen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
- var feature5j = _ShapeLayer.AddShape(new RheinlandPfalz (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5a = _ShapeLayer.AddShape(new Thueringen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5b = _ShapeLayer.AddShape(new Bayern (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5c = _ShapeLayer.AddShape(new BadenWuerttemberg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5d = _ShapeLayer.AddShape(new Hessen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5e = _ShapeLayer.AddShape(new Saarland (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5f = _ShapeLayer.AddShape(new Sachsen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5g = _ShapeLayer.AddShape(new SachsenAnhalt (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ //var feature5h = _ShapeLayer.AddShape(new Berlin (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5i = _ShapeLayer.AddShape(new NordrheinWestfalen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5j = _ShapeLayer.AddShape(new RheinlandPfalz (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5k = _ShapeLayer.AddShape(new Hamburg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5l = _ShapeLayer.AddShape(new Bremen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5m = _ShapeLayer.AddShape(new Brandenburg (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5n = _ShapeLayer.AddShape(new SchleswigHolstein (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5o = _ShapeLayer.AddShape(new MecklenburgVorpommern (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
+ var feature5p = _ShapeLayer.AddShape(new Niedersachsen (Color.FromArgb(0xFF, 0xE0, 0xC0, 0x60), 1, Color.FromArgb(0x77, 0xE0, 0x60, 0x30)));
// Deutschland: 55.058315, 5.866399 => 47.270203, 15.041656
// Width: 7.788112 Height: 9.175257
Please sign in to comment.
Something went wrong with that request. Please try again.