Esempio n. 1
0
        // metric coordinates
        public static IFeatureSet CreateUserInputLayer(double lon, double lat, double radius, string workdir)
        {
            FeatureSet infs = new FeatureSet(DotSpatial.Topology.FeatureType.Point);

            infs.Projection = KnownCoordinateSystems.Projected.WorldSpheroid.Mercatorsphere;
            DotSpatial.Data.Feature center = new DotSpatial.Data.Feature(new Coordinate(lon, lat));
            infs.AddFeature(center);

            var fs = infs.Buffer(radius, false);

            fs.SaveAs(WORKSPACE_DIR + workdir + "/usr.shp", true);
            return(fs);
        }
Esempio n. 2
0
        public static IEnumerable <OCM.API.Common.LatLon> SearchPolygonFromPolyLine(List <OCM.API.Common.LatLon> points, double distanceKM)
        {
            List <OCM.API.Common.LatLon> polyPoints = new List <OCM.API.Common.LatLon>();

            //http://dotspatial.codeplex.com/wikipage?title=CycleThroughVerticesCS&referringTitle=Desktop_SampleCode

            //create feature set from points
            Feature    f  = new Feature();
            FeatureSet fs = new FeatureSet(f.FeatureType);

            Coordinate[] coord = new Coordinate[points.Count];
            for (int i = 0; i < points.Count; i++)
            {
                coord[i] = new Coordinate((double)points[i].Latitude, (double)points[i].Longitude);
            }
            LineString ls = new LineString(coord);

            f = new Feature(ls);
            fs.Features.Add(f);
            //fs.Buffer(distanceKM, false); //TODO: approx km to lat/long coord value
            IFeatureSet iF = fs.Buffer(0.02, false);

            //export polygon points

            Extent extent = new Extent(-180, -90, 180, 90);

            foreach (ShapeRange shape in iF.ShapeIndices)
            {
                //if (shape.Intersects(extent))
                foreach (PartRange part in shape.Parts)
                {
                    foreach (Vertex vertex in part)
                    {
                        // if (vertex.X > 0 && vertex.Y > 0)
                        {
                            // prepare export of polygon points

                            polyPoints.Add(new OCM.API.Common.LatLon {
                                Latitude = vertex.X, Longitude = vertex.Y
                            });
                        }
                    }
                }
            }

            return(polyPoints);
        }