Java Code Examples for com.nextgis.maplib.util.GeoConstants#MERCATOR_MAX

The following examples show how to use com.nextgis.maplib.util.GeoConstants#MERCATOR_MAX . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalTMSLayer.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public GeoEnvelope getExtents() {
    if(null == mLimits)
        return super.getExtents();
    Integer firstZoom = GeoConstants.DEFAULT_MAX_ZOOM;
    for(Integer key: mLimits.keySet()){
        if(key < firstZoom)
            firstZoom = key;
    }

    TileCacheLevelDescItem item = mLimits.get(firstZoom);

    if(null == item)
        return super.getExtents();

    double mapTileCount = 1 << firstZoom;
    double mapTileSize = GeoConstants.MERCATOR_MAX * 2 / mapTileCount;

    GeoEnvelope env = new GeoEnvelope();
    env.setMinX(item.getMinX() * mapTileSize - GeoConstants.MERCATOR_MAX);
    if(item.getMinX() == item.getMaxX())
        env.setMaxX((item.getMaxX() +1) * mapTileSize - GeoConstants.MERCATOR_MAX);
    else
        env.setMaxX(item.getMaxX() * mapTileSize - GeoConstants.MERCATOR_MAX);

    if(mTMSType == GeoConstants.TMSTYPE_OSM) {
        if(item.getMinY() == item.getMaxY())
            env.setMinY(GeoConstants.MERCATOR_MAX - (item.getMaxY() + 1) * mapTileSize);
        else
            env.setMinY(GeoConstants.MERCATOR_MAX - item.getMaxY() * mapTileSize);
        env.setMaxY(GeoConstants.MERCATOR_MAX - item.getMinY() * mapTileSize);
    } else {
        env.setMinY(item.getMinY() * mapTileSize - GeoConstants.MERCATOR_MAX);
        if(item.getMinY() == item.getMaxY())
            env.setMaxY((item.getMaxY() + 1) * mapTileSize - GeoConstants.MERCATOR_MAX);
        else
            env.setMaxY(item.getMaxY() * mapTileSize - GeoConstants.MERCATOR_MAX);
    }
    return env;
}
 
Example 2
Source File: MapDrawable.java    From android_maplib with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void zoomToExtent(GeoEnvelope envelope, float maxZoom) {
    if (envelope.isInit()) {
        double size = GeoConstants.MERCATOR_MAX * 2;
        double scale = Math.min(envelope.width() / size, envelope.height() / size);
        double zoom = MapUtil.lg(1 / scale);
        if (zoom < getMinZoom())
            zoom = getMinZoom();
        if (zoom > maxZoom)
            zoom = maxZoom;

        setZoomAndCenter((float) zoom, envelope.getCenter());
    }
}
 
Example 3
Source File: GeometryRTree.java    From android_maplib with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Node buildRoot(boolean asLeaf){
    return new Node(new GeoEnvelope(-GeoConstants.MERCATOR_MAX, GeoConstants.MERCATOR_MAX,
                                    -GeoConstants.MERCATOR_MAX, GeoConstants.MERCATOR_MAX),
                    asLeaf);
}