本文整理汇总了Java中org.geomajas.layer.tile.TileCode类的典型用法代码示例。如果您正苦于以下问题:Java TileCode类的具体用法?Java TileCode怎么用?Java TileCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TileCode类属于org.geomajas.layer.tile包,在下文中一共展示了TileCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyConnectedOnce
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Execute a {@link TileFunction} in this tile and all connected tiles. Only tiles which are not yet included in
* updatedTiles are processed. Tiles are added in updatedTiles when processed. If these connected tiles are not yet
* part of the cache, then they will be fetched before applying the {@link TileFunction} on them.
*
* @param filter A filter that needs to be used in case connected tile need to be fetched.
* @param callback The {@link TileFunction} to execute on the connected tiles.
* @param updatedTiles list of already processed tiles to assure tiles are only processed once
*/
public void applyConnectedOnce(final String filter, final TileFunction<VectorTile> callback,
final Map<String, VectorTile> updatedTiles) {
apply(filter, new TileFunction<VectorTile>() {
public void execute(VectorTile tile) {
updatedTiles.put(tile.getCode().toString(), tile);
callback.execute(tile);
List<TileCode> tileCodes = tile.getCodes();
for (TileCode tileCode : tileCodes) {
if (!updatedTiles.containsKey(tileCode.toString())) {
VectorTile temp = tile.cache.addTile(tileCode);
updatedTiles.put(tileCode.toString(), temp);
temp.apply(filter, callback);
}
}
}
});
}
示例2: getTiles
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Update showing state.
*
* @param fireEvents Should events be fired if state changes?
*/
/*protected void updateShowing(boolean fireEvents) {
//setShowing(isVisible());
// don't do anything?
} */
private List<Tile> getTiles(WmsLayer wmsLayer, double resolution, org.geomajas.geometry.Bbox worldBounds) {
TileConfiguration tileConfig = wmsLayer.getTileConfiguration();
List<org.geomajas.gwt2.client.map.render.TileCode> codes = TileService.getTileCodesForBounds(tileConfig,
worldBounds, resolution);
List<Tile> tiles = new ArrayList<Tile>();
if (!codes.isEmpty()) {
double actualResolution = tileConfig.getResolution(codes.get(0).getTileLevel());
for (org.geomajas.gwt2.client.map.render.TileCode code : codes) {
org.geomajas.geometry.Bbox bounds = TileService.getWorldBoundsForTile(tileConfig, code);
Tile tile = new Tile(getScreenBounds(actualResolution, bounds));
tile.setCode(code);
tile.setUrl(WmsClient.getInstance().getWmsService().getMapUrl(wmsLayer.getConfiguration(),
bounds, tileConfig.getTileWidth(), tileConfig.getTileHeight()));
tiles.add(tile);
}
}
return tiles;
}
示例3: getTiles
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
private List<Tile> getTiles(WmsLayer layer, String crs, double resolution, Bbox worldBounds) {
TileConfiguration tileConfig = layer.getTileConfiguration();
Bbox maxBounds = layer.getMaxBounds();
worldBounds = BboxService.intersection(worldBounds, maxBounds);
List<Tile> tiles = new ArrayList<Tile>();
if (worldBounds != null) {
List<org.geomajas.gwt2.client.map.render.TileCode> codes = TileService.getTileCodesForBounds(tileConfig,
worldBounds, resolution);
if (!codes.isEmpty()) {
double actualResolution = tileConfig.getResolution(codes.get(0).getTileLevel());
for (org.geomajas.gwt2.client.map.render.TileCode code : codes) {
Bbox bounds = TileService.getWorldBoundsForTile(tileConfig, code);
Tile tile = new Tile(getScreenBounds(actualResolution, bounds));
tile.setCode(code);
tile.setUrl(WmsClient.getInstance().getWmsService().getMapUrl(layer.getConfiguration(),
bounds, tileConfig.getTileWidth(), tileConfig.getTileHeight()));
tiles.add(tile);
}
}
}
return tiles;
}
示例4: getTiles
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
private List<Tile> getTiles(AbstractTileBasedLayer layer, String crs, double resolution, Bbox worldBounds) {
TileConfiguration tileConfig = layer.getTileConfiguration();
Bbox maxBounds = layer.getMaxBounds();
worldBounds = BboxService.intersection(worldBounds, maxBounds);
List<Tile> tiles = new ArrayList<Tile>();
if (worldBounds != null) {
List<org.geomajas.gwt2.client.map.render.TileCode> codes = TileService.getTileCodesForBounds(tileConfig,
worldBounds, resolution);
if (!codes.isEmpty()) {
double actualResolution = tileConfig.getResolution(codes.get(0).getTileLevel());
for (org.geomajas.gwt2.client.map.render.TileCode code : codes) {
Bbox bounds = TileService.getWorldBoundsForTile(tileConfig, code);
Tile tile = new Tile(getScreenBounds(actualResolution, bounds));
tile.setCode(code);
TileRenderer tileRenderer = layer.getTileRenderer();
tile.setUrl(tileRenderer.getUrl(code));
tiles.add(tile);
}
}
}
return tiles;
}
示例5: testTileCodeComparator3on3
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
@Test
public void testTileCodeComparator3on3() {
List<TileCode> list = createTileCodes(0, 0, 3, 3);
TileCodeComparator tcc = new TileCodeComparator(1, 1);
Collections.sort(list, tcc);
Assert.assertArrayEquals(new TileCode[] {
new TileCode(0, 1, 1),
new TileCode(0, 0, 2), // maybe not 1,2 but 0,2
new TileCode(0, 1, 2),
new TileCode(0, 2, 2),
new TileCode(0, 2, 1),
new TileCode(0, 2, 0),
new TileCode(0, 1, 0),
new TileCode(0, 0, 0),
new TileCode(0, 0, 1),
}, list.toArray(new TileCode[0]));
}
示例6: testShuffeledTileCodeComparator3on3
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
@Test
public void testShuffeledTileCodeComparator3on3() {
List<TileCode> list = createShuffeledTileCodes(0, 0, 3, 3);
TileCodeComparator tcc = new TileCodeComparator(1, 1);
Collections.sort(list, tcc);
Assert.assertArrayEquals(new TileCode[] {
new TileCode(0, 1, 1),
new TileCode(0, 0, 2), // maybe not 1,2 but 0,2
new TileCode(0, 1, 2),
new TileCode(0, 2, 2),
new TileCode(0, 2, 1),
new TileCode(0, 2, 0),
new TileCode(0, 1, 0),
new TileCode(0, 0, 0),
new TileCode(0, 0, 1),
}, list.toArray(new TileCode[0]));
}
示例7: RasterTile
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Constructor for a raster tile.
*
* @param code tile code
* @param bbox bounding box
* @param url tile URL
* @param store raster layer store
*/
public RasterTile(TileCode code, Bbox bbox, String url, RasterLayerStore store) {
this.code = code;
this.bbox = bbox;
this.url = url;
this.store = store;
this.id = store.getLayer().getMapModel().getId() + "." + store.getLayer().getId() + "." + code.toString();
String styleStr = store.getLayer().getLayerInfo().getStyle();
}
示例8: fetch
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Fetch all data related to this tile.
*
* @param filter When fetching it is possible to filter the data with this filter object. Null otherwise.
* @param callback When this node's data comes from the server, it will be handled by this callback function.
*/
public void fetch(final String filter, final TileFunction<VectorTile> callback) {
final GetVectorTileRequest request = createRequest(filter);
GwtCommand command = new GwtCommand(GetVectorTileRequest.COMMAND);
command.setCommandRequest(request);
final VectorTile self = this;
lastRequest = request;
deferred = GwtCommandDispatcher.getInstance().execute(command,
new AbstractCommandCallback<GetVectorTileResponse>() {
public void execute(GetVectorTileResponse tileResponse) {
if (null == deferred || !deferred.isCancelled()) {
org.geomajas.layer.tile.VectorTile tile = tileResponse.getTile();
for (TileCode relatedTile : tile.getCodes()) {
codes.add(relatedTile);
}
code = tile.getCode();
contentType = tile.getContentType();
featureContent.setContent(tile.getFeatureContent());
labelContent.setContent(tile.getLabelContent());
try {
callback.execute(self);
} catch (Throwable t) {
Log.logError("VectorTile: error calling the callback after a fetch.", t);
}
}
deferred = null;
}
});
}
示例9: addTile
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Adds the tile with the specified code to the cache or returns the tile if it's already in the cache.
*
* @param tileCode
* A {@link TileCode} instance.
*/
public VectorTile addTile(TileCode tileCode) {
String code = tileCode.toString();
VectorTile tile = tiles.get(code);
if (tile == null) {
tile = new VectorTile(tileCode, calcBoundsForTileCode(tileCode), this);
tile.setPictureStyle(new PictureStyle(layer.getOpacity()));
tiles.put(code, tile);
}
return tile;
}
示例10: calcBoundsForTileCode
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Calculate the exact bounding box for a tile, given it's tile-code.
*
* @param tileCode
* tile code
* @return bbox for tile
*/
protected Bbox calcBoundsForTileCode(TileCode tileCode) {
// Calculate tile width and height for tileLevel=tileCode.getTileLevel()
double div = Math.pow(2, tileCode.getTileLevel());
double scale = layer.getMapModel().getMapView().getCurrentScale();
double tileWidth = Math.ceil((scale * layerBounds.getWidth()) / div) / scale;
double tileHeight = Math.ceil((scale * layerBounds.getHeight()) / div) / scale;
// Now calculate indices, and return bbox:
double x = layerBounds.getX() + tileCode.getX() * tileWidth;
double y = layerBounds.getY() + tileCode.getY() * tileHeight;
return new Bbox(x, y, tileWidth, tileHeight);
}
示例11: calcCodesForBounds
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* Saves the complete array of TileCode objects for the given bounds (and the current scale).
*
* @param bounds
* view bounds
* @return list of tiles in these bounds
*/
protected List<TileCode> calcCodesForBounds(Bbox bounds) {
// Calculate tile width and height for tileLevel=currentTileLevel
double div = Math.pow(2, currentTileLevel); // tile level must be correct!
double scale = layer.getMapModel().getMapView().getCurrentScale();
double tileWidth = Math.ceil((scale * layerBounds.getWidth()) / div) / scale;
double tileHeight = Math.ceil((scale * layerBounds.getHeight()) / div) / scale;
// For safety (to prevent division by 0):
List<TileCode> codes = new ArrayList<TileCode>();
if (tileWidth == 0 || tileHeight == 0) {
return codes;
}
// Calculate bounds relative to extents:
Bbox clippedBounds = bounds.intersection(layerBounds);
if (clippedBounds == null) {
Log.logError("Map bounds outside of layer extents, check the server configuration, it is incorrect.");
return codes;
}
double relativeBoundX = Math.abs(clippedBounds.getX() - layerBounds.getX());
double relativeBoundY = Math.abs(clippedBounds.getY() - layerBounds.getY());
currentMinX = (int) Math.floor(relativeBoundX / tileWidth);
currentMinY = (int) Math.floor(relativeBoundY / tileHeight);
currentMaxX = (int) Math.ceil((relativeBoundX + clippedBounds.getWidth()) / tileWidth) - 1;
currentMaxY = (int) Math.ceil((relativeBoundY + clippedBounds.getHeight()) / tileHeight) - 1;
// Now fill the list with the correct codes:
for (int x = currentMinX; x <= currentMaxX; x++) {
for (int y = currentMinY; y <= currentMaxY; y++) {
codes.add(new TileCode(currentTileLevel, x, y));
}
}
return codes;
}
示例12: buildUrl
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
@Override
public String buildUrl(TileCode tileCode, String baseTmsUrl) {
StringBuilder builder = new StringBuilder(baseTmsUrl);
if (!baseTmsUrl.endsWith("/")) {
builder.append("/");
}
builder.append(tileCode.getTileLevel());
builder.append("/");
builder.append(tileCode.getX());
builder.append("/");
builder.append(tileCode.getY());
builder.append(extension);
return builder.toString();
}
示例13: buildUrl
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
private static String buildUrl(TileCode tileCode, TileMap tileMap, String baseTmsUrl) {
if (tileCode == null || tileMap == null || baseTmsUrl == null) {
throw new IllegalArgumentException("All parameters are required");
}
StringBuilder builder;
// assuming they are ordered:
TileSet tileSet = tileMap.getTileSets().getTileSets().get(tileCode.getTileLevel());
String href = tileSet.getHref();
if (href.startsWith("http://") || href.startsWith("https://")) {
builder = new StringBuilder(href);
if (!href.endsWith("/")) {
builder.append("/");
}
} else {
builder = new StringBuilder(baseTmsUrl);
if (!baseTmsUrl.endsWith("/")) {
builder.append("/");
}
builder.append(href);
builder.append("/");
}
builder.append(tileCode.getX());
builder.append("/");
builder.append(tileCode.getY());
builder.append(".");
builder.append(tileMap.getTileFormat().getExtension());
return builder.toString();
}
示例14: parseTileCode
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
/**
* @param relativeUrl just the part with level/x/y.extension
* @return
*/
public static TileCode parseTileCode(String relativeUrl) {
TileCode tc = new TileCode();
StringTokenizer tokenizer = new StringTokenizer(relativeUrl, "/");
tc.setTileLevel(Integer.parseInt(tokenizer.nextToken()));
tc.setX(Integer.parseInt(tokenizer.nextToken()));
tc.setY(Integer.parseInt(tokenizer.nextToken().split("\\.")[0]));
return tc;
}
示例15: testBuildUrl1
import org.geomajas.layer.tile.TileCode; //导入依赖的package包/类
@Test
public void testBuildUrl1() throws TmsLayerException {
TmsLayer tmsLayer = new TmsLayer();
tmsLayer.setBaseTmsUrl("classpath:/org/geomajas/layer/tms/tileMapCapa1.xml");
TileMap tileMap = configurationService
.getCapabilities(tmsLayer);
TileMapUrlBuilder builder = new TileMapUrlBuilder(tileMap);
String url = builder.buildUrl(new TileCode(1, 2, 3), BASE_TMS_URL);
Assert.assertEquals("http://www.geomajas.org/tms/some_layer/href2/2/3.extension", url);
}