I'm busy evaluating the RadMap and controls which we will buy soon, at the moment I need help, can someone please help me get started with following.
I need to set-up a geo fence with one or many map markers that will alert, assert when the fence boundaries are crossed OR entered, so far I only am able to create shapes with markers and am unsure of how to progress with the fence boundary detection.
Thanks in advance.
I need to set-up a geo fence with one or many map markers that will alert, assert when the fence boundaries are crossed OR entered, so far I only am able to create shapes with markers and am unsure of how to progress with the fence boundary detection.
Thanks in advance.
4 Answers, 1 is accepted
0
Hello Yaghiyah,
I'm sorry, but I don't quite understand your question.
Can you supply some additional details on the issue which you are facing with the control, or the functionality which you are trying to achieve?
Regards,
Andrey Murzov
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
I'm sorry, but I don't quite understand your question.
Can you supply some additional details on the issue which you are facing with the control, or the functionality which you are trying to achieve?
Regards,
Andrey Murzov
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Yaghiyah
Top achievements
Rank 1
answered on 02 Aug 2014, 11:57 AM
Its been a few days its been very silent on the maps forums, I am still stuck and made "some" progress..
Ive looked at various algorithms and found this its the equation for testing if a point is inside a circle, firstly here is the algorithm..
Next I build the circle using like this..
Yet, no luck. when testing for a point inside a circle ..I will appreciate if someone / anyone can set me on the right path.
Ive looked at various algorithms and found this its the equation for testing if a point is inside a circle, firstly here is the algorithm..
public
static
bool
IsPointInCircle(Point centre,
double
radius, Point toTest)
{
// Is the point inside the circle? Sum the squares of the x-difference and
// y-difference from the centre, square-root it, and compare with the radius.
// (This is Pythagoras' theorem.)
double
dX = Math.Abs( toTest.X - centre.X);
double
dY = Math.Abs (toTest.Y - centre.Y);
double
sumOfSquares = dX * dX + dY * dY;
double
distance = Math.Sqrt(sumOfSquares);
return
(radius >= distance);
}
Next I build the circle using like this..
private
InformationLayer _currentLayer;
private
MapPath _circleMapPath;
void
DrawCircle()
{
// Create a new MapPath circle.
_circleMapPath =
new
MapPath
{
Fill =
new
SolidColorBrush(Colors.GreenYellow),
Stroke =
new
SolidColorBrush(Colors.Red),
StrokeThickness = 2,
Opacity = 0.4
};
// Create a Location Rectangle based on two location points.
_locationRect =
new
LocationRect(_originalLocation, _currentLocation) { MapControl = _map };
// Determine the Radius. XY for a Circle.
double
radius = MapGeometryHelper.MapDistance(_originalLocation , _currentLocation, _map);
_circleMapPath.Data =
new
MapEllipseGeometry
{
Center = _originalLocation,
RadiusX = radius,
RadiusY = radius
};
_currentLayer.Items.Add(_circleMapPath);
// Update with new path geometery.
_map.Items.Add(_currentLayer);
// Update map with new layer with updated geometry.
DrawCenterDotWithRadius();
}
private
void
DrawCenterDotWithRadius()
{
if
(_pointMapPath !=
null
)
_currentLayer.Items.Remove(_pointMapPath);
if
(_line !=
null
)
_currentLayer.Items.Remove(_line);
_pointMapPath =
new
MapPath
{
Stroke =
new
SolidColorBrush(Colors.Blue),
StrokeThickness = 1,
Data =
new
MapEllipseGeometry
{
Center = _originalLocation,
RadiusX = 0.1,
RadiusY = 0.1
},
};
_currentLayer.Items.Add(_pointMapPath);*/
_line =
new
MapLine
{
Point1 = _originalLocation,
Point2 = _currentLocation,
Fill =
new
SolidColorBrush(Colors.Red),
Stroke =
new
SolidColorBrush(Colors.Red),
StrokeThickness = 2
};
_currentLayer.Items.Add(_line);
}
Yet, no luck. when testing for a point inside a circle ..I will appreciate if someone / anyone can set me on the right path.
0
Hi Yaghiyah,
It is quite complex mathematical task to detect whether the given location is inside the arbitrary map region. The RadMap control doesn't provide functionality which can be used to solve this task for the map shapes which aren't visible in viewport. But if a map shape object is visible over the map, then you can use following method to detect whether specified location is inside the shape:
Regards,
It is quite complex mathematical task to detect whether the given location is inside the arbitrary map region. The RadMap control doesn't provide functionality which can be used to solve this task for the map shapes which aren't visible in viewport. But if a map shape object is visible over the map, then you can use following method to detect whether specified location is inside the shape:
private
bool
IsLocationInShape(MapShape shapeToTest, Location location)
{
bool
isInShape =
false
;
IEnumerable<
object
> list =
this
.InformationLayer.GetItemsInLocation(location);
foreach
(
object
item
in
list)
{
MapShape shape = item
as
MapShape;
if
(shape !=
null
&& shape == shapeToTest)
{
isInShape =
true
;
break
;
}
}
return
isInShape;
}
Regards,
Andrey Murzov
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Yaghiyah
Top achievements
Rank 1
answered on 04 Aug 2014, 09:28 AM
Hi Andrey
I think I might have solved problem for circular geometric shapes.
See here. http://math.stackexchange.com/questions/198764/how-to-know-if-a-point-is-inside-a-circle
I've adapted the concept and came up with this.
/// <summary>
/// Tests if a marker point location is "Within" or "Outside" a circular Geo-Fence.
/// </summary>
/// <param name="centre">The centre of the geo-fence circle presented as a location object, in Latitude and Longitude form.</param>
/// <param name="radius">The radius of the geo-fence circle in Km. 0.05 km = 50 meters, 50 meters is the maximum zoom level. </param>
/// <param name="marker">The map marker in question to test. </param>
/// <param name="map">The radmap map object.</param>
/// <param name="isPointInCircleTest">If true will perform a test inside circle, else test for marker point outside.</param>
/// <param name="boundaryDetect">True to test if maker point is on the geo-fence boundary, else don't include the geo-fence boundary in boundary scan.</param>
/// <returns>True if marker is inside geo-fence else marker is </returns>
public static bool CircleFenceTest(Location centre, double radius, Location marker, RadMap map, bool isPointInCircleTest, bool boundaryDetect)
{
double distance = MapGeometryHelper.MapDistance(centre, new Location(marker.Latitude, marker.Longitude), map)
.MapRound()
.KmToMeters();
double r = radius.KmToMeters()
.MapRound();
if (isPointInCircleTest)
{
if (boundaryDetect)
return (distance <= r);
return (distance < r);
}
if (boundaryDetect)
return (distance >= r);
return (distance > r);
}
I think I might have solved problem for circular geometric shapes.
See here. http://math.stackexchange.com/questions/198764/how-to-know-if-a-point-is-inside-a-circle
I've adapted the concept and came up with this.
/// <summary>
/// Tests if a marker point location is "Within" or "Outside" a circular Geo-Fence.
/// </summary>
/// <param name="centre">The centre of the geo-fence circle presented as a location object, in Latitude and Longitude form.</param>
/// <param name="radius">The radius of the geo-fence circle in Km. 0.05 km = 50 meters, 50 meters is the maximum zoom level. </param>
/// <param name="marker">The map marker in question to test. </param>
/// <param name="map">The radmap map object.</param>
/// <param name="isPointInCircleTest">If true will perform a test inside circle, else test for marker point outside.</param>
/// <param name="boundaryDetect">True to test if maker point is on the geo-fence boundary, else don't include the geo-fence boundary in boundary scan.</param>
/// <returns>True if marker is inside geo-fence else marker is </returns>
public static bool CircleFenceTest(Location centre, double radius, Location marker, RadMap map, bool isPointInCircleTest, bool boundaryDetect)
{
double distance = MapGeometryHelper.MapDistance(centre, new Location(marker.Latitude, marker.Longitude), map)
.MapRound()
.KmToMeters();
double r = radius.KmToMeters()
.MapRound();
if (isPointInCircleTest)
{
if (boundaryDetect)
return (distance <= r);
return (distance < r);
}
if (boundaryDetect)
return (distance >= r);
return (distance > r);
}