[转]worldwind在线加载google地图,或者基于墨卡托投影的切片地图

package gis1;
 
import java.net.MalformedURLException;
import java.net.URL;
 
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.avlist.AVListImpl;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.layers.mercator.BasicMercatorTiledImageLayer;
import gov.nasa.worldwind.layers.mercator.MercatorSector;
import gov.nasa.worldwind.util.LevelSet;
import gov.nasa.worldwind.util.Tile;
import gov.nasa.worldwind.util.TileUrlBuilder;
 
public class GoogleLayer extends BasicMercatorTiledImageLayer{
 
    public GoogleLayer() {
        super(makeLevels());
        // TODO Auto-generated constructor stub
    }
 
    private static LevelSet makeLevels() {
        // TODO Auto-generated method stub
        AVList params = new AVListImpl();
 
        params.setValue(AVKey.TILE_WIDTH, 256);
        params.setValue(AVKey.TILE_HEIGHT, 256);
        params.setValue(AVKey.DATA_CACHE_NAME, "Earth/GoogleMap");
        params.setValue(AVKey.DATASET_NAME, "*");
        params.setValue(AVKey.FORMAT_SUFFIX, ".jpg");
        params.setValue(AVKey.NUM_LEVELS, 16);
        params.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
        params.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(Angle
                .fromDegrees(22.5d), Angle.fromDegrees(45d)));
        params.setValue(AVKey.SECTOR, new MercatorSector(-1.0, 1.0,
                Angle.NEG180, Angle.POS180));
        params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder());
 
        return new LevelSet(params);
    }
    private static class URLBuilder implements TileUrlBuilder
    {
        public URL getURL(Tile tile, String imageFormat)
                throws MalformedURLException
        {
            String url=String.format(
                    "http://www.google.cn/maps/vt?lyrs=s@183&gl=cn&x=%s&y=%s&z=%s",
                    tile.getColumn(),
                    (1 << (tile.getLevelNumber()) + 3) - 1 - tile.getRow(),
                    (tile.getLevelNumber() + 3) 
                    );
            System.out.println(url);
            return new URL(url);
        }
    }
 
}

 

[转]worldwind在线加载google地图,或者基于墨卡托投影的切片地图

上一篇:CVE-2019-1388 Windows UAC提权


下一篇:LeetCode OJ:Implement strStr()