Search in sources :

Example 1 with WmtsTileGridOptions

use of ol.tilegrid.WmtsTileGridOptions in project gwt-ol3 by TDesjardins.

the class WmtsExample method createWmtsTileGrid.

/**
 * Creates a WMTS tilegrid.
 *
 * @param projection projection of the grid
 * @return WMTS tilegrid
 */
private TileGrid createWmtsTileGrid(Projection projection) {
    WmtsTileGridOptions wmtsTileGridOptions = OLFactory.createOptions();
    double[] resolutions = new double[14];
    String[] matrixIds = new String[14];
    double width = projection.getExtent().getWidth();
    double matrixWidth = width / 256;
    for (int i = 0; i < 14; i++) {
        resolutions[i] = matrixWidth / Math.pow(2, i);
        matrixIds[i] = String.valueOf(i);
    }
    Coordinate tileGridOrigin = projection.getExtent().getTopLeft();
    wmtsTileGridOptions.setOrigin(tileGridOrigin);
    wmtsTileGridOptions.setResolutions(resolutions);
    wmtsTileGridOptions.setMatrixIds(matrixIds);
    return new WmtsTileGrid(wmtsTileGridOptions);
}
Also used : Coordinate(ol.Coordinate) WmtsTileGridOptions(ol.tilegrid.WmtsTileGridOptions) WmtsTileGrid(ol.tilegrid.WmtsTileGrid)

Aggregations

Coordinate (ol.Coordinate)1 WmtsTileGrid (ol.tilegrid.WmtsTileGrid)1 WmtsTileGridOptions (ol.tilegrid.WmtsTileGridOptions)1