Exemple #1
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);
        }
Exemple #2
0
        public APICapabilities GetCapabilities()
        {
            if (this._api_capabilities != null)
            {
                return(this._api_capabilities);
            }
            string s = this.DoApiCall(false, "/api/capabilities", APIConnection.Method.GET, (byte[])null);

            if (s == null || s.Trim().Length <= 0)
            {
                return((APICapabilities)null);
            }
            api api = (new OsmDocument((IXmlSource) new XmlReaderSource(XmlReader.Create((TextReader) new StringReader(s)))).Osm as osm).api;

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