All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.meteoinfo.data.mapdata.webmap.BingHybridMapInfo Maven / Gradle / Ivy

There is a newer version: 3.8
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.meteoinfo.data.mapdata.webmap;

/**
 *
 * @author yaqiang
 */
public class BingHybridMapInfo extends TileFactoryInfo {
    // 
    private String version = "1173";
    private String clientKey = null;
    // 
    // 

    /**
     * Constructor
     */
    public BingHybridMapInfo() {
        super("BingHybridMap", 1, 17, 19,
                256, true, true, // tile size is 256 and x/y orientation is normal
                "http://ecn.t%1$d.tiles.virtualearth.net/tiles/h%2$s.jpeg?g=%3$s&mkt=%4$s&n=z%5$s",
                "x", "y", "z");
    }
//    // 
//    // 
//    // 
//    // 

    @Override
    public String getTileUrl(int x, int y, int zoom) {
        zoom = this.getTotalMapZoom() - zoom;
        int serverNum = this.getServerNum(x, y, 4);
        String key = this.tileXYToQuadKey(x, y, zoom);
        String ckey = this.clientKey;
        if (ckey == null)
            ckey = "";
        String url = String.format(this.baseURL, serverNum, key, version, this.getLanguage(), zoom, x, y);
        return url;
    }
    
    /// 
      /// Converts tile XY coordinates into a QuadKey at a specified level of detail.
      /// 
      /// Tile X coordinate.
      /// Tile Y coordinate.
      /// Level of detail, from 1 (lowest detail)
      /// to 23 (highest detail).
      /// A string containing the QuadKey.
      private String tileXYToQuadKey(long tileX, long tileY, int levelOfDetail)
      {
         StringBuilder quadKey = new StringBuilder();
         for(int i = levelOfDetail; i > 0; i--)
         {
            char digit = '0';
            int mask = 1 << (i - 1);
            if((tileX & mask) != 0)
            {
               digit++;
            }
            if((tileY & mask) != 0)
            {
               digit++;
               digit++;
            }
            quadKey.append(digit);
         }
         return quadKey.toString();
      }
    // 
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy