Exemplo n.º 1
0
    /// <summary>
    /// Calculates the north-east (top-left) GCS minLat and maxLat
    /// to get the maxLat and maxLon of the current chunk
    /// </summary>
    public GCS getNorthEastGCS()
    {
        USlippyTile result = new USlippyTile(x, y, zoom);

        result.x += 1;
        result.y -= 1;
        if (result.x < 0 || result.y < 0)
        {
            return(null);
        }
        return(result.getGCS());
    }
Exemplo n.º 2
0
    /// <summary>
    /// Uses the OpenStreetMap API to get the desired data in a latitude and longitude bounds.
    /// </summary>
    /// <param name="tile">tile x, y and zoom</param>
    /// <returns>An XML with the OSM data</returns>
    public static XmlDocument getOSMXML(USlippyTile tile)
    {
        XmlDocument xml = new XmlDocument();

        using (WebClient client = new WebClient())
        {
            //tile.y
            USlippyTile copy = new USlippyTile(tile.x, tile.y, tile.zoom);
            copy.y += 1;
            GCS gcs = copy.getGCS();
            /// North-East USlippyTile's GCS
            GCS gcsNE = copy.getNorthEastGCS();
            //              # LefttLon #LowLat   #RightLon #HiLat
            //chunkLimits = [2.13078,  41.48236, 2.13454,  41.48593]
            string url = OSMApiCall + gcs.lon + "," + gcs.lat + "," + gcsNE.lon + "," + gcsNE.lat;
            xml.LoadXml(client.DownloadString(url));
        }
        return(xml);
    }