Skip to content

Commit

Permalink
GMap.NET.WindowsPresentation: apply danielkaneider optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
radioman committed May 11, 2015
1 parent 0e2a397 commit 60e678c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ internal GMapMarker()
/// <summary>
/// calls Dispose on shape if it implements IDisposable, sets shape to null and clears route
/// </summary>
public void Clear()
public virtual void Clear()
{
var s = (Shape as IDisposable);
if(s != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,48 @@ public GMapPolygon(IEnumerable<PointLatLng> points)
RegenerateShape(null);
}
}

public override void Clear()
{
base.Clear();
Points.Clear();
}

/// <summary>
/// regenerates shape of polygon
/// </summary>
public virtual void RegenerateShape(GMapControl map)
{
if (map != null)
{
Map = map;

if (Points.Count > 1)
if(map != null)
{
this.Map = map;
if(Points.Count > 1)
{
Position = Points[0];

var localPath = new List<System.Windows.Point>();
var offset = Map.FromLatLngToLocal(Points[0]);
foreach (var i in Points)
{
var p = Map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng));
localPath.Add(new System.Windows.Point(p.X - offset.X, p.Y - offset.Y));
}

var shape = map.CreatePolygonPath(localPath);

if (this.Shape != null && this.Shape is Path)
{
(this.Shape as Path).Data = shape.Data;
}
else
{
this.Shape = shape;
}
var localPath = new List<System.Windows.Point>(Points.Count);
var offset = Map.FromLatLngToLocal(Points[0]);
foreach(var i in Points)
{
var p = Map.FromLatLngToLocal(i);
localPath.Add(new System.Windows.Point(p.X - offset.X, p.Y - offset.Y));
}

var shape = map.CreatePolygonPath(localPath);

if(this.Shape is Path)
{
(this.Shape as Path).Data = shape.Data;
}
else
{
this.Shape = shape;
}
}
else
{
this.Shape = null;
this.Shape = null;
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public GMapRoute(IEnumerable<PointLatLng> points)
RegenerateShape(null);
}
}

public override void Clear()
{
base.Clear();
Points.Clear();
}

/// <summary>
/// regenerates shape of route
Expand All @@ -30,34 +36,32 @@ public virtual void RegenerateShape(GMapControl map)
{
if (map != null)
{
Map = map;
this.Map = map;

if (Points.Count > 1)
if(Points.Count > 1)
{
Position = Points[0];

var localPath = new List<System.Windows.Point>();
var offset = Map.FromLatLngToLocal(Points[0]);
foreach (var i in Points)
{
var p = Map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng));
localPath.Add(new System.Windows.Point(p.X - offset.X, p.Y - offset.Y));
}

var shape = map.CreateRoutePath(localPath);

if (this.Shape != null && this.Shape is Path)
{
(this.Shape as Path).Data = shape.Data;
}
else
{
this.Shape = shape;
}
var localPath = new List<System.Windows.Point>(Points.Count);
var offset = Map.FromLatLngToLocal(Points[0]);
foreach(var i in Points)
{
var p = Map.FromLatLngToLocal(i);
localPath.Add(new System.Windows.Point(p.X - offset.X, p.Y - offset.Y));
}

var shape = map.CreateRoutePath(localPath);

if(this.Shape is Path)
{
(this.Shape as Path).Data = shape.Data;
}
else
{
this.Shape = shape;
}
}
else
{
this.Shape = null;
this.Shape = null;
}
}
}
Expand Down

0 comments on commit 60e678c

Please sign in to comment.