2017-09-02 58 views
0

我想加載我的wms服務器,從那裏顯示瓷磚。我用卡特/ nutiteq和一切都很好,但我想要它的開源或免費許可證。然後我嘗試osmdroid庫,但我不能實現我的wms任何人都可以幫助我?android mapview與自定義wms瓷磚供應商

// Web Mercator n/w corner of the map. 
private static final double[] TILE_ORIGIN = {-20037508.34789244, 20037508.34789244}; 
//array indexes for that data 
private static final int ORIG_X = 0; 
private static final int ORIG_Y = 1; // 
private static String mLayername = ""; 

// Size of square world map in meters, using WebMerc projection. 
private static final double MAP_SIZE = 20037508.34789244 * 2; 

// array indexes for array to hold bounding boxes. 
protected static final int MINX = 0; 
protected static final int MAXX = 1; 
protected static final int MINY = 2; 
protected static final int MAXY = 3; 
private String layer = ""; 

/** 
* Constructor 
* 
* @param aName a human-friendly name for this tile source 
* @param aBaseUrl the base url(s) of the tile server used when constructing the url to download the tiles http://sedac.ciesin.columbia.edu/geoserver/wms 
*/ 
public WMSTileProvider(String aName, String[] aBaseUrl, String layername) { 
    super(aName, 8, 22, 255, "image/png", aBaseUrl); 
    mLayername = layername; 
} 


final String WMS_FORMAT_STRING = 
     "http://dev.shiveh.com/shiveh?service=WMS&request=GetMap&layers=Shiveh%3AShivehGSLD256&styles=&format=image%2Fpng&transparent=false&version=1.1.1&height=256&width=256&srs=EPSG%3A4326&bbox="; 
protected double[] getBoundingBox(int x, int y, int zoom) { 
    double tileSize = MAP_SIZE/Math.pow(2, zoom); 
    double minx = TILE_ORIGIN[ORIG_X] + x * tileSize; 
    double maxx = TILE_ORIGIN[ORIG_X] + (x + 1) * tileSize; 
    double miny = TILE_ORIGIN[ORIG_Y] - (y + 1) * tileSize; 
    double maxy = TILE_ORIGIN[ORIG_Y] - y * tileSize; 

    double[] bbox = new double[4]; 
    bbox[MINX] = minx; 
    bbox[MINY] = miny; 
    bbox[MAXX] = maxx; 
    bbox[MAXY] = maxy; 

    return bbox; 
} 

回答

1

你的url中的座標參考系統EPSG:4326這是緯度/經度wgs84。然而,你看起來像公式從滑動地圖座標轉換爲EPSG:900913。

您的服務器是否支持CRS?嘗試將CRS url參數切換到EPSG:900913或更改公式以計算請求的瓦片的座標