首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有自定义wms瓷砖提供商的android地图视图

带有自定义wms瓷砖提供商的android地图视图
EN

Stack Overflow用户
提问于 2017-09-02 12:56:12
回答 1查看 690关注 0票数 0

我想加载我的wms服务器,以显示从那里的瓷砖。我使用carto/nutiteq,一切都很好,但我想要开源或免费许可。然后我尝试了osmdroid库,但是我无法实现我的wms,有人能帮我吗?

代码语言:javascript
复制
// 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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-02 22:29:59

您的url :4326中的坐标参考系统是lat/lon wgs84。然而,你所看到的方程看上去就像要从模糊的地图坐标转换到EPSG:900913的方程。

您的服务器支持那个CRS吗?尝试将CRS url参数切换到EPSG:900913,或者更改方程以计算所请求的瓷砖的坐标。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46014035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档