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

2021-03-18 14:25

阅读:491

标签:str   height   earth   out   googl   generated   ring   list   lse   

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.getRow(),
                    (tile.getLevelNumber() + 3) 
                    );
            System.out.println(url);
            return new URL(url);
        }
    }
 
}

 

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

标签:str   height   earth   out   googl   generated   ring   list   lse   

原文地址:https://www.cnblogs.com/rainbow70626/p/12355296.html


评论


亲,登录后才可以留言!