Пример #1
0
        } // End Function GetPoints

        public static System.Collections.Generic.List <GeoPoint> GetPointList(string wayId)
        {
            System.Collections.Generic.List <GeoPoint> ls = new System.Collections.Generic.List <GeoPoint>();

            // https://www.openstreetmap.org/api/0.6/way/73685445
            OSM.API.v0_6.XML.OsmWayXml osm = OSM.API.v0_6.XML.OsmWayXml.FromUrl($"https://www.openstreetmap.org/api/0.6/way/{wayId}");

            foreach (OSM.API.v0_6.XML.Nd node in osm.Way.Nd)
            {
                string @ref = node.Ref;

                // https://www.openstreetmap.org/api/0.6/node/872697431
                OSM.API.v0_6.XML.OsmNodeXml nodeOSM = OSM.API.v0_6.XML.OsmNodeXml.FromUrl($"https://www.openstreetmap.org/api/0.6/node/{@ref}");
                System.Threading.Thread.Sleep(5000);
                decimal lat = nodeOSM.Node.Lat;
                decimal lon = nodeOSM.Node.Lon;

                ls.Add(new GeoPoint(lat, lon));
            } // Next node

            return(ls);
        } // End Function GetPointList
Пример #2
0
        // 44.1683810, 4.4460592
        // 44.1683805, 4.4459657
        // 44.1683790, 4.4459432
        // 44.1683733, 4.4458814
        // 44.1683669, 4.4458296
        // 44.1683617, 4.4457856
        // 44.1683591, 4.4457662
        // 44.1683644, 4.4457620
        // 44.1683701, 4.4457513
        // 44.1683717, 4.4457414
        // 44.1683693, 4.4457264
        // 44.1683641, 4.4457168
        // 44.1683579, 4.4457114
        // 44.1683500, 4.4457026
        // 44.1683423, 4.4456513
        // 44.1683320, 4.4456555
        // 44.1683273, 4.4456644
        // 44.1683220, 4.4456807
        // 44.1683197, 4.4457058
        // 44.1683171, 4.4457334
        // 44.1682368, 4.4457636
        // 44.1682231, 4.4457730
        // 44.1682109, 4.4457845
        // 44.1682283, 4.4458652
        // 44.1682552, 4.4458584
        // 44.1682988, 4.4460135
        // 44.1682068, 4.4460419
        // 44.1682026, 4.4460260
        // 44.1680923, 4.4460372
        // 44.1682116, 4.4458787
        // 44.1681763, 4.4458272
        // 44.1680972, 4.4459363
        // 44.1680783, 4.4460028
        // 44.1680590, 4.4460501
        // 44.1680488, 4.4461376
        // 44.1682454, 4.4460895
        // 44.1682537, 4.4461225
        // 44.1683810, 4.4460592


        public static string GetPoints(string wayId)
        {
            string polygonPoints = null;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // https://www.openstreetmap.org/api/0.6/way/73685445
            OSM.API.v0_6.XML.OsmWayXml osm = OSM.API.v0_6.XML.OsmWayXml.FromUrl($"https://www.openstreetmap.org/api/0.6/way/{wayId}");

            foreach (GeoPoint geopoint in GetPointList(wayId))
            {
                sb.Append(geopoint.Latitude);
                sb.Append(", ");
                sb.Append(geopoint.Longitude);
                sb.AppendLine();
            } // Next geopoint

            polygonPoints = sb.ToString();
            sb.Clear();
            sb = null;

            return(polygonPoints);
        } // End Function GetPoints