Programmatically adding geometry

Topics: General Topics, WinForms Controls
Apr 11, 2015 at 12:31 AM
My goal is to map a series of waypoints that describes an intended flight path for a UAV, and a few polygon obstacles. The waypoints and obstacles are currently stored in memory as arrays of objects (c# classes). The waypoint layer is intended to be a series of points connected by lines. The obstacle layer is intended to be a series of unconnected point/radius defined approximately circular polygons.

What would be the best approach to adding geometry to the waypoint layer and an obstacle layer?

What SharpMap.Data.Providers should I use?
Apr 12, 2015 at 6:59 PM
I got the following working for DrawObstacles() now I am working on changing the representation to display obstacle radius.
      private void DrawObstacles(List<Obstacle> obstacles)
        {
            SharpMap.Layers.VectorLayer VectorLayerObstacles
               = new VectorLayer("Obstacles");

            List<IGeometry> geometryList
                = new List<IGeometry>();

            GeometryServiceProvider.Instance
                = new NetTopologySuite.NtsGeometryServices();

            IGeometryFactory geometryFactory
                = GeometryServiceProvider.Instance.CreateGeometryFactory();

            foreach (Obstacle obstacle in obstacles)
            {
                IPoint point = geometryFactory.CreatePoint(obstacle.Coordinate);
                geometryList.Add(point);
            }

            VectorLayerObstacles.DataSource
                = new GeometryProvider(geometryList);

            mapBox.Map.Layers.Add(VectorLayerObstacles);

            Envelope envelope = VectorLayerObstacles.Envelope;
            envelope.ExpandBy(0.001D);
            mapBox.Map.ZoomToBox(envelope);
            mapBox.Refresh();
        }
Apr 12, 2015 at 9:27 PM
The obstacle radius problem is partially solved using the following:
                NetTopologySuite.Geometries.Point point 
                    = new NetTopologySuite.Geometries.Point(obstacle.Coordinate);

                featureDataRow.Geometry = point.Buffer(.001);
Now all I have to do is somehow convert obstacle radius values in either feet or meters to lat/lon degrees.
Coordinator
Apr 13, 2015 at 9:49 AM
You need to setup a coordinate transformation for you layer, then you can use radius in feet or meter.
If you cannot do that, have a look at http://williams.best.vwh.net/avform.htm#LL.