开发者

How to create a buffer and determine what is inside the buffer of a mapPolyLine? c#

i'm trying to create a buffer around a MapPolyLine to determine if there's anything inside the mapPolyLine. Below is the code for the MapPolyLine:

    private void routeService_CalculateRouteCompleted(object sender, CalculateRouteCompletedEventArgs e)

    {
         // If the route calculate was a success and contains a route, then draw the route on the map.
            if ((e.Result.ResponseSumma开发者_Python百科ry.StatusCode == BingMapRouteService.ResponseStatusCode.Success) & (e.Result.Result.Legs.Count != 0))
            {
                // Set properties of the route line you want to draw.
                System.Windows.Media.Color routeColor = Colors.Blue;
                SolidColorBrush routeBrush = new SolidColorBrush(routeColor);
                //MapPolyline routeLine = new MapPolyline();
                App.routeLine.Locations = new LocationCollection();
                App.routeLine.Stroke = routeBrush;
                App.routeLine.Opacity = 0.65;
                App.routeLine.StrokeThickness = 5.0;


                // Retrieve the route points that define the shape of the route.
                foreach (Location p in e.Result.Result.RoutePath.Points)
                {
                    App.routeLine.Locations.Add(new GeoCoordinate(p.Latitude, p.Longitude));

                }

How do i get the coordinates of the buffer of the MapPolyLine (using only Bing Map API without ARCGIS extension)?


Well, think of it this way: A buffer in GIS is a polygon. The only way it's going to be useful to see if points are inside it or not is to be able to create that shape (whether you display it or not) and run whatever point-in-a-polygon analysis is available to you. (I don't know if Bing Maps offers that functionality). Ideally, I'd go about it by drawing arcs at the endpoints (using them as the arcs' centers), then join them with line segments following the contours of the polyline). You will need to determine slope and intersection for each polyline point to do this. Or better put, what the intersections are for lines that are offset a certain distance (whether in screen coordinates or Mercator) from the polyline points. Once that's done, you may have a suitable polygon, although the point-in-polygon code I've worked with would not work with the arcs. You'd likely need to approximate those with straightline segments.

I feel your pain on this one as I too would not want to encumber the app with the ArcGIS DLLs, despite their functionality. And I realize this a barebones outline of what needs to be done. But it is what I would set out to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜