Hello
Instead of using polygon in "flashing point style", may I know if it is possible to replace the polygon with a circle of radius 2 kilometre while the rest remain status quo? (i.e. users being alerted when a vehicle enters a prohibited area demarcated by a circle of radius 2 Kilometre)
Thank you in advance
Bai
Vehicle entering prohibited area
Hi Bai,
In fact a circle is a polygon, so what you need to modify is in the timer_Tick function, you can directly modify the polygon to your circle in this logic:
//At each new vehicle location, it checks if the vehicle is inside one of the zones.
//If it is, it enables flashingTimer.
bool isInside = false;
foreach (AreaBaseShape areaBaseShape in zones)
{
if (areaBaseShape.Contains(pointShape))
{
isInside = true;
break;
}
}
Regards,
Don
Thanks Don,
I figured by using ellipseShape, I am able to draw a circle of certain radius, but
(1) when the circle is plotted on the map, the radius seems incorrect. My codes are as follows:
double degreeLength = DecimalDegreesHelper.GetLongitudeDifferenceFromDistance(2.5, DistanceUnit.Mile, 40.51231); // 2.5 is the radius in mile
EllipseShape circleShape = new EllipseShape(ptCenter, degreeLength, GeographyUnit.DecimalDegree, DistanceUnit.Mile); // my mapunit is decimal degree
(2) How do I determine whether a PointShape is within the specified EllipseShape (i.e. how do I incorporate ellipseSHape into Flashing point Style)?
Bai
Hi Bai,
1. Our EllipseShape is drawn based on world coordinates but not screen coordinates, it’s related with your projection, so if you means the ellipse looks not so “circle”, that’s right. If you want to get a circle in screen, you can draw the circle in the equator, then move it to your target point. The other solution is you can choose a projection like 900913, which should get a better circle.
2. You can easily do that by our API like this:
EllipseShape es;
PointShape p;
es.Contains§; // 1
p.IsWithin(es); // 2
Regards,
Don
Hello Don,
Taking Tasmania as an example, the longitude = 146.3, and the latitude = -41.6 . The distance from east to west is approx. 190miles. When I set these values, the circle does not encompass the entire Tasmania. Is that correct ?
Regards,
Bai
Hi Bai,
As below is my test code, it looks the Tasmania can be complete covered by the ellipse shape:
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.DecimalDegree;
WorldMapKitWmsWpfOverlay wmk = new WorldMapKitWmsWpfOverlay();
Map1.Overlays.Add(wmk);
LayerOverlay overlay = new LayerOverlay();
Map1.Overlays.Add(overlay);
InMemoryFeatureLayer layer = new InMemoryFeatureLayer();
layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColors.White), new GeoSolidBrush(GeoColors.Transparent));
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
overlay.Layers.Add(layer);
EllipseShape es = new EllipseShape(new Feature(146.3, -41.6), 190, GeographyUnit.DecimalDegree, DistanceUnit.Mile);
layer.InternalFeatures.Add(new Feature(es));
Map1.CenterAt(new PointShape(146.3, -41.6));
Map1.CurrentScale = new ZoomLevelSet().ZoomLevel07.Scale;
Map1.Refresh();
}
Any question please let me know.
Regards,
Don
Hello Don
I have removed the following line and it works,
double degreeLength = DecimalDegreesHelper.GetLongitudeDifferenceFromDistance(2.5, DistanceUnit.Mile, 40.51231); // 2.5 is the radius in mile
Thank you,
Regards,
Bai
Hi Bai,
Very glad to hear it’s working for you.
Thanks,
Peter