Example #1
0
    private string CustomTrafficProviderReplaceToken(Match match)
    {
        string v = match.Value.ToLower().Trim('{', '}');

        if (OnReplaceTrafficURLToken != null)
        {
            string ret = OnReplaceTrafficURLToken(this, v);
            if (ret != null)
            {
                return(ret);
            }
        }

        if (v == "zoom")
        {
            return(zoom.ToString());
        }
        if (v == "x")
        {
            return(x.ToString());
        }
        if (v == "y")
        {
            return(y.ToString());
        }
        if (v == "quad")
        {
            return(OnlineMapsUtils.TileToQuadKey(x, y, zoom));
        }
        return(v);
    }
Example #2
0
    /// <summary>
    /// Get the relative path to the tile in the file cache.
    /// </summary>
    /// <param name="tile">Tile</param>
    /// <returns>Relative path to the tile in the file cache</returns>
    public StringBuilder GetShortTilePath(OnlineMapsTile tile)
    {
#if ALLOW_FILECACHE
        int startIndex = 0;
        StringBuilder stringBuilder = GetStringBuilder();

        OnlineMapsRasterTile rTile = tile as OnlineMapsRasterTile;

        int l = fileCacheTilePath.Length;
        for (int i = 0; i < l; i++)
        {
            char c = fileCacheTilePath[i];
            if (c == '{')
            {
                for (int j = i + 1; j < l; j++)
                {
                    c = fileCacheTilePath[j];
                    if (c == '}')
                    {
                        stringBuilder.Append(fileCacheTilePath.Substring(startIndex, i - startIndex));
                        string v = fileCacheTilePath.Substring(i + 1, j - i - 1).ToLower();
                        if (v == "pid") stringBuilder.Append(rTile.mapType.provider.id);
                        else if (v == "mid") stringBuilder.Append(rTile.mapType.id);
                        else if (v == "zoom" || v == "z") stringBuilder.Append(tile.zoom);
                        else if (v == "x") stringBuilder.Append(tile.x);
                        else if (v == "y") stringBuilder.Append(tile.y);
                        else if (v == "quad") OnlineMapsUtils.TileToQuadKey(tile.x, tile.y, tile.zoom, stringBuilder);
                        else if (v == "lng") stringBuilder.Append(rTile.language);
                        else if (v == "lbs") stringBuilder.Append(rTile.labels ? "le" : "ld");
                        else stringBuilder.Append(v);
                        i = j;
                        startIndex = j + 1;
                        break;
                    }
                }
            }
        }

        stringBuilder.Append(fileCacheTilePath.Substring(startIndex, l - startIndex));
        return stringBuilder;
#else
        return null;
#endif
    }
Example #3
0
    private void InitVirtualEarth()
    {
        string quad   = OnlineMapsUtils.TileToQuadKey(x, y, zoom);
        string server = "";

        if (type == 0 && !labels)
        {
            server = "https://ak.t0.tiles.virtualearth.net/tiles/a{0}.jpeg?mkt={1}&g=1457&n=z";
        }
        else if (type == 0 && labels)
        {
            server = "https://ak.dynamic.t0.tiles.virtualearth.net/comp/ch/{0}?mkt={1}&it=A,G,L,LA&og=30&n=z";
        }
        else if (type == 1)
        {
            server = "https://ak.dynamic.t0.tiles.virtualearth.net/comp/ch/{0}?mkt={1}&it=G,VE,BX,L,LA&og=30&n=z";
        }
        _url = String.Format(server, quad, language);
    }
Example #4
0
    private string CustomProviderReplaceToken(Match match)
    {
        string v = match.Value.ToLower().Trim('{', '}');

        if (v == "zoom")
        {
            return(zoom.ToString());
        }
        if (v == "x")
        {
            return(x.ToString());
        }
        if (v == "y")
        {
            return(y.ToString());
        }
        if (v == "quad")
        {
            return(OnlineMapsUtils.TileToQuadKey(x, y, zoom));
        }
        return(v);
    }
    /// <summary>
    /// Gets the URL to download the traffic texture.
    /// </summary>
    /// <param name="tile">Instence of tile.</param>
    /// <returns>URL to texture</returns>
    public string GetURL(OnlineMapsTile tile)
    {
        return(Regex.Replace(url, @"{\w+}", delegate(Match match)
        {
            string v = match.Value.ToLower().Trim('{', '}');

            if (OnlineMapsTile.OnReplaceTrafficURLToken != null)
            {
                string ret = OnlineMapsTile.OnReplaceTrafficURLToken(tile, v);
                if (ret != null)
                {
                    return ret;
                }
            }

            if (v == "zoom")
            {
                return tile.zoom.ToString();
            }
            if (v == "z")
            {
                return tile.zoom.ToString();
            }
            if (v == "x")
            {
                return tile.x.ToString();
            }
            if (v == "y")
            {
                return tile.y.ToString();
            }
            if (v == "quad")
            {
                return OnlineMapsUtils.TileToQuadKey(tile.x, tile.y, tile.zoom);
            }
            return v;
        }));
    }
Example #6
0
        private string GetURL(OnlineMapsTile tile, string url, bool labels)
        {
            url = Regex.Replace(url, @"{\w+}", delegate(Match match)
            {
                string v = match.Value.ToLower().Trim('{', '}');

                if (OnlineMapsTile.OnReplaceURLToken != null)
                {
                    string ret = OnlineMapsTile.OnReplaceURLToken(tile, v);
                    if (ret != null)
                    {
                        return(ret);
                    }
                }

                if (v == "zoom")
                {
                    return(tile.zoom.ToString());
                }
                if (v == "z")
                {
                    return(tile.zoom.ToString());
                }
                if (v == "x")
                {
                    return(tile.x.ToString());
                }
                if (v == "y")
                {
                    return(tile.y.ToString());
                }
                if (v == "quad")
                {
                    return(OnlineMapsUtils.TileToQuadKey(tile.x, tile.y, tile.zoom));
                }
                if (v == "lng")
                {
                    return(tile.language);
                }
                if (v == "ext")
                {
                    return(ext);
                }
                if (v == "prop")
                {
                    return(labels ? propWithLabels : propWithoutLabels);
                }
                if (v == "variant")
                {
                    return(labels ? variantWithLabels : variantWithoutLabels);
                }
                if (TryUseExtraFields(ref v))
                {
                    return(v);
                }
                return(v);
            });
            url = Regex.Replace(url, @"{rnd(\d+)-(\d+)}", delegate(Match match)
            {
                int v1 = int.Parse(match.Groups[1].Value);
                int v2 = int.Parse(match.Groups[2].Value);
                return(Random.Range(v1, v2 + 1).ToString());
            });
            if (logUrl)
            {
                Debug.Log(url);
            }
            return(url);
        }