示例#1
0
        /// <summary>
        /// Returns the way with the given id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SimpleWay WayGet(long id)
        {
            string response = this.DoApiCall(false, string.Format(
                "/api/0.6/way/{0}", id), Method.GET, null);

            if (response != null && response.Trim().Length > 0)
            {
                XmlReaderSource xml_source = new XmlReaderSource(XmlReader.Create(new StringReader(response)));
                OsmDocument osm = new OsmDocument(xml_source);
                Osm.Xml.v0_6.way xml_way = (osm.Osm as OsmSharp.Osm.Xml.v0_6.osm).way[0];
                return this.Convertv6XmlWay(xml_way);
            }
            return null;
        }
示例#2
0
        /// <summary>
        /// Gets the changeset information with the given id from the API. Does not include the actual changes.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public SimpleChangeSetInfo ChangeSetGet(long id)
        {
            string response = this.DoApiCall(false, string.Format(
                "/api/0.6/changeset/{0}", id), Method.GET, null);

            if (response != null && response.Trim().Length > 0)
            {
                XmlReaderSource xml_source = new XmlReaderSource(XmlReader.Create(new StringReader(response)));
                OsmDocument osm = new OsmDocument(xml_source);
                Osm.Xml.v0_6.changeset xml_node = (osm.Osm as OsmSharp.Osm.Xml.v0_6.osm).changeset[0];
                return this.Convertv6XmlChangeSet(xml_node);
            }
            return null;
        }
示例#3
0
        /// <summary>
        /// Gets the API's capabilities.
        /// </summary>
        /// <returns></returns>
        public APICapabilities GetCapabilities()
        {
            if (_api_capabilities == null)
            { // get the capabilities from the api.
                string response = this.DoApiCall(false, "/api/capabilities", Method.GET, null);

                if (response != null && response.Trim().Length > 0)
                {
                    // de-serialize response.-
                    XmlReaderSource xml_source = new XmlReaderSource(XmlReader.Create(new StringReader(response)));
                    OsmDocument osm = new OsmDocument(xml_source);
                    Osm.Xml.v0_6.api api = (osm.Osm as OsmSharp.Osm.Xml.v0_6.osm).api;

                    // capabilities.
                    _api_capabilities = new APICapabilities();
                    if (api.area.maximumSpecified)
                    {
                        _api_capabilities.AreaMaximum = api.area.maximum;
                    }
                    if (api.changesets.maximum_elementsSpecified)
                    {
                        _api_capabilities.ChangeSetsMaximumElement = api.changesets.maximum_elements;
                    }
                    if (api.timeout.secondsSpecified)
                    {
                        _api_capabilities.TimeoutSeconds = api.timeout.seconds;
                    }
                    if (api.tracepoints.per_pageSpecified)
                    {
                        _api_capabilities.TracePointsPerPage = api.tracepoints.per_page;
                    }
                    if (api.version.maximumSpecified)
                    {
                        _api_capabilities.VersionMaximum = api.version.maximum;
                    }
                    if (api.version.minimumSpecified)
                    {
                        _api_capabilities.VersionMinimum = api.version.minimum;
                    }
                    if (api.waynodes.maximumSpecified)
                    {
                        _api_capabilities.WayNodesMaximum = api.waynodes.maximum;
                    }

                    return _api_capabilities;
                }
                return null;
            }
            return _api_capabilities;
        }
示例#4
0
        /// <summary>
        /// Returns all objects within the given bounding box.
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public List<SimpleOsmGeo> BoundingBoxGet(Tools.Math.Geo.GeoCoordinateBox box)
        {
            string response = this.DoApiCall(false, string.Format(
                "/api/0.6/map?bbox={0},{1},{2},{3}",
                    box.MinLon.ToString(System.Globalization.CultureInfo.InvariantCulture),
                    box.MinLat.ToString(System.Globalization.CultureInfo.InvariantCulture),
                    box.MaxLon.ToString(System.Globalization.CultureInfo.InvariantCulture),
                    box.MaxLat.ToString(System.Globalization.CultureInfo.InvariantCulture)), Method.GET, null);

            if (response != null && response.Trim().Length > 0)
            {
                XmlReaderSource xml_source = new XmlReaderSource(XmlReader.Create(new StringReader(response)));
                OsmDocument osm = new OsmDocument(xml_source);

                List<SimpleOsmGeo> box_objects = new List<SimpleOsmGeo>();
                OsmSharp.Osm.Xml.v0_6.osm xml_osm = (osm.Osm as OsmSharp.Osm.Xml.v0_6.osm);
                if (xml_osm.node != null)
                {
                    foreach (Osm.Xml.v0_6.node xml_node in xml_osm.node)
                    {
                        box_objects.Add(this.Convertv6XmlNode(xml_node));
                    }
                }
                if (xml_osm.way != null)
                {
                    foreach (Osm.Xml.v0_6.way xml_way in xml_osm.way)
                    {
                        box_objects.Add(this.Convertv6XmlWay(xml_way));
                    }
                }
                if (xml_osm.relation != null)
                {
                    foreach (Osm.Xml.v0_6.relation xml_relation in xml_osm.relation)
                    {
                        box_objects.Add(this.Convertv6XmlRelation(xml_relation));
                    }
                }
                return box_objects;
            }
            return null;
        }