本文整理汇总了Java中org.mapsforge.core.model.Tile.TILE_SIZE属性的典型用法代码示例。如果您正苦于以下问题:Java Tile.TILE_SIZE属性的具体用法?Java Tile.TILE_SIZE怎么用?Java Tile.TILE_SIZE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mapsforge.core.model.Tile
的用法示例。
在下文中一共展示了Tile.TILE_SIZE属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeOutOfTileAreaLabels
/**
* This method removes the area labels, that are not visible in the actual tile.
*
* @param areaLabels
* area Labels from the actual tile
*/
private void removeOutOfTileAreaLabels(List<PointTextContainer> areaLabels) {
for (int i = 0; i < areaLabels.size(); i++) {
this.label = areaLabels.get(i);
if (this.label.x > Tile.TILE_SIZE) {
areaLabels.remove(i);
i--;
} else if (this.label.y - this.label.boundary.height() > Tile.TILE_SIZE) {
areaLabels.remove(i);
i--;
} else if (this.label.x + this.label.boundary.width() < 0.0f) {
areaLabels.remove(i);
i--;
} else if (this.label.y + this.label.boundary.height() < 0.0f) {
areaLabels.remove(i);
i--;
}
}
}
示例2: removeOutOfTileLabels
/**
* This method removes the labels, that are not visible in the actual tile.
*
* @param labels
* Labels from the actual tile
*/
private void removeOutOfTileLabels(List<PointTextContainer> labels) {
for (int i = 0; i < labels.size();) {
this.label = labels.get(i);
if (this.label.x - this.label.boundary.width() / 2 > Tile.TILE_SIZE) {
labels.remove(i);
this.label = null;
} else if (this.label.y - this.label.boundary.height() > Tile.TILE_SIZE) {
labels.remove(i);
this.label = null;
} else if ((this.label.x - this.label.boundary.width() / 2 + this.label.boundary.width()) < 0.0f) {
labels.remove(i);
this.label = null;
} else if (this.label.y < 0.0f) {
labels.remove(i);
this.label = null;
} else {
i++;
}
}
}
示例3: removeOutOfTileSymbols
/**
* This method removes the Symbols, that are not visible in the actual tile.
*
* @param symbols
* Symbols from the actual tile
*/
private void removeOutOfTileSymbols(List<SymbolContainer> symbols) {
for (int i = 0; i < symbols.size();) {
this.symbolContainer = symbols.get(i);
if (this.symbolContainer.point.x > Tile.TILE_SIZE) {
symbols.remove(i);
} else if (this.symbolContainer.point.y > Tile.TILE_SIZE) {
symbols.remove(i);
} else if (this.symbolContainer.point.x + this.symbolContainer.symbol.getWidth() < 0.0f) {
symbols.remove(i);
} else if (this.symbolContainer.point.y + this.symbolContainer.symbol.getHeight() < 0.0f) {
symbols.remove(i);
} else {
i++;
}
}
}
示例4: getPriority
/**
* Calculates the priority for the given tile based on the current position and zoom level of the supplied MapView.
* The smaller the distance from the tile center to the MapView center, the higher its priority. If the zoom level
* of a tile differs from the zoom level of the MapView, its priority decreases.
*
* @param tile
* the tile whose priority should be calculated.
* @param mapView
* the MapView whose current position and zoom level define the priority of the tile.
* @return the current priority of the tile. A smaller number means a higher priority.
*/
static double getPriority(Tile tile, MapView mapView) {
byte tileZoomLevel = tile.zoomLevel;
// calculate the center coordinates of the tile
long tileCenterPixelX = tile.getPixelX() + (Tile.TILE_SIZE >> 1);
long tileCenterPixelY = tile.getPixelY() + (Tile.TILE_SIZE >> 1);
double tileCenterLongitude = MercatorProjection.pixelXToLongitude(tileCenterPixelX, tileZoomLevel);
double tileCenterLatitude = MercatorProjection.pixelYToLatitude(tileCenterPixelY, tileZoomLevel);
// calculate the Euclidian distance from the MapView center to the tile center
MapPosition mapPosition = mapView.getMapViewPosition().getMapPosition();
GeoPoint geoPoint = mapPosition.geoPoint;
double longitudeDiff = geoPoint.longitude - tileCenterLongitude;
double latitudeDiff = geoPoint.latitude - tileCenterLatitude;
double euclidianDistance = Math.sqrt(longitudeDiff * longitudeDiff + latitudeDiff * latitudeDiff);
if (mapPosition.zoomLevel == tileZoomLevel) {
return euclidianDistance;
}
int zoomLevelDiff = Math.abs(mapPosition.zoomLevel - tileZoomLevel);
double scaleFactor = Math.pow(2, zoomLevelDiff);
double scaledEuclidianDistance;
if (mapPosition.zoomLevel < tileZoomLevel) {
scaledEuclidianDistance = euclidianDistance * scaleFactor;
} else {
scaledEuclidianDistance = euclidianDistance / scaleFactor;
}
double zoomLevelPenalty = zoomLevelDiff * ZOOM_LEVEL_PENALTY;
return scaledEuclidianDistance * zoomLevelPenalty;
}
示例5: getTilePixelCoordinates
private static Point[][] getTilePixelCoordinates() {
Point point1 = new Point(0, 0);
Point point2 = new Point(Tile.TILE_SIZE, 0);
Point point3 = new Point(Tile.TILE_SIZE, Tile.TILE_SIZE);
Point point4 = new Point(0, Tile.TILE_SIZE);
return new Point[][] { { point1, point2, point3, point4, point1 } };
}
示例6: tileXToLongitudeTest
@Test
public void tileXToLongitudeTest() {
for (byte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
double longitude = MercatorProjection.tileXToLongitude(0, zoomLevel);
Assert.assertEquals(CoordinatesUtil.LONGITUDE_MIN, longitude, 0);
long tileX = MercatorProjection.getMapSize(zoomLevel) / Tile.TILE_SIZE;
longitude = MercatorProjection.tileXToLongitude(tileX, zoomLevel);
Assert.assertEquals(CoordinatesUtil.LONGITUDE_MAX, longitude, 0);
}
}
示例7: tileYToLatitudeTest
@Test
public void tileYToLatitudeTest() {
for (byte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) {
double latitude = MercatorProjection.tileYToLatitude(0, zoomLevel);
Assert.assertEquals(MercatorProjection.LATITUDE_MAX, latitude, 0);
long tileY = MercatorProjection.getMapSize(zoomLevel) / Tile.TILE_SIZE;
latitude = MercatorProjection.tileYToLatitude(tileY, zoomLevel);
Assert.assertEquals(MercatorProjection.LATITUDE_MIN, latitude, 0);
}
}
示例8: drawBitmap
/**
* Draws a tile bitmap at the right position on the MapView bitmap.
*
* @param tile
* the corresponding tile for the bitmap.
* @param bitmap
* the bitmap to be drawn.
* @return true if the tile is visible and the bitmap was drawn, false otherwise.
*/
public boolean drawBitmap(Tile tile, Bitmap bitmap) {
MapPosition mapPosition = this.mapView.getMapViewPosition().getMapPosition();
synchronized (this) {
if (tile.zoomLevel != mapPosition.zoomLevel) {
// the tile doesn't fit to the current zoom level
return false;
} else if (this.mapView.isZoomAnimatorRunning()) {
// do not disturb the ongoing animation
return false;
}
GeoPoint geoPoint = mapPosition.geoPoint;
double pixelLeft = MercatorProjection.longitudeToPixelX(geoPoint.longitude, mapPosition.zoomLevel);
double pixelTop = MercatorProjection.latitudeToPixelY(geoPoint.latitude, mapPosition.zoomLevel);
pixelLeft -= this.width >> 1;
pixelTop -= this.height >> 1;
if (pixelLeft - tile.getPixelX() > Tile.TILE_SIZE || pixelLeft + this.width < tile.getPixelX()) {
// no horizontal intersection
return false;
} else if (pixelTop - tile.getPixelY() > Tile.TILE_SIZE || pixelTop + this.height < tile.getPixelY()) {
// no vertical intersection
return false;
}
if (!this.matrix.isIdentity()) {
// change the current MapView bitmap
this.mapViewBitmap2.eraseColor(MAP_VIEW_BACKGROUND);
this.mapViewCanvas.setBitmap(this.mapViewBitmap2);
// draw the previous MapView bitmap on the current MapView bitmap
this.mapViewCanvas.drawBitmap(this.mapViewBitmap1, this.matrix, null);
this.matrix.reset();
// swap the two MapView bitmaps
Bitmap mapViewBitmapSwap = this.mapViewBitmap1;
this.mapViewBitmap1 = this.mapViewBitmap2;
this.mapViewBitmap2 = mapViewBitmapSwap;
}
// draw the tile bitmap at the correct position
float left = (float) (tile.getPixelX() - pixelLeft);
float top = (float) (tile.getPixelY() - pixelTop);
this.mapViewCanvas.drawBitmap(bitmap, left, top, null);
return true;
}
}
示例9: removeAreaLabelsInAlreadyDrawnAreas
/**
* Removes the are labels from the actual list, that would be rendered in a Tile that has already be drawn.
*
* @param areaLabels
* current area Labels, that will be displayed
*/
void removeAreaLabelsInAlreadyDrawnAreas(List<PointTextContainer> areaLabels) {
Tile lefttmp = new Tile(this.currentTile.tileX - 1, this.currentTile.tileY, this.currentTile.zoomLevel);
Tile righttmp = new Tile(this.currentTile.tileX + 1, this.currentTile.tileY, this.currentTile.zoomLevel);
Tile uptmp = new Tile(this.currentTile.tileX, this.currentTile.tileY - 1, this.currentTile.zoomLevel);
Tile downtmp = new Tile(this.currentTile.tileX, this.currentTile.tileY + 1, this.currentTile.zoomLevel);
boolean up;
boolean left;
boolean right;
boolean down;
this.tmp = this.dependencyTable.get(lefttmp);
left = this.tmp == null ? false : this.tmp.drawn;
this.tmp = this.dependencyTable.get(righttmp);
right = this.tmp == null ? false : this.tmp.drawn;
this.tmp = this.dependencyTable.get(uptmp);
up = this.tmp == null ? false : this.tmp.drawn;
this.tmp = this.dependencyTable.get(downtmp);
down = this.tmp == null ? false : this.tmp.drawn;
PointTextContainer label;
for (int i = 0; i < areaLabels.size(); i++) {
label = areaLabels.get(i);
if (up && label.y - label.boundary.height() < 0.0f) {
areaLabels.remove(i);
i--;
continue;
}
if (down && label.y > Tile.TILE_SIZE) {
areaLabels.remove(i);
i--;
continue;
}
if (left && label.x < 0.0f) {
areaLabels.remove(i);
i--;
continue;
}
if (right && label.x + label.boundary.width() > Tile.TILE_SIZE) {
areaLabels.remove(i);
i--;
continue;
}
}
}
示例10: removeSymbolsFromDrawnAreas
void removeSymbolsFromDrawnAreas(List<SymbolContainer> symbols) {
Tile lefttmp = new Tile(this.currentTile.tileX - 1, this.currentTile.tileY, this.currentTile.zoomLevel);
Tile righttmp = new Tile(this.currentTile.tileX + 1, this.currentTile.tileY, this.currentTile.zoomLevel);
Tile uptmp = new Tile(this.currentTile.tileX, this.currentTile.tileY - 1, this.currentTile.zoomLevel);
Tile downtmp = new Tile(this.currentTile.tileX, this.currentTile.tileY + 1, this.currentTile.zoomLevel);
boolean up;
boolean left;
boolean right;
boolean down;
this.tmp = this.dependencyTable.get(lefttmp);
left = this.tmp == null ? false : this.tmp.drawn;
this.tmp = this.dependencyTable.get(righttmp);
right = this.tmp == null ? false : this.tmp.drawn;
this.tmp = this.dependencyTable.get(uptmp);
up = this.tmp == null ? false : this.tmp.drawn;
this.tmp = this.dependencyTable.get(downtmp);
down = this.tmp == null ? false : this.tmp.drawn;
SymbolContainer ref;
for (int i = 0; i < symbols.size(); i++) {
ref = symbols.get(i);
if (up && ref.point.y < 0) {
symbols.remove(i);
i--;
continue;
}
if (down && ref.point.y + ref.symbol.getHeight() > Tile.TILE_SIZE) {
symbols.remove(i);
i--;
continue;
}
if (left && ref.point.x < 0) {
symbols.remove(i);
i--;
continue;
}
if (right && ref.point.x + ref.symbol.getWidth() > Tile.TILE_SIZE) {
symbols.remove(i);
i--;
continue;
}
}
}
示例11: getMapSize
/**
* @param zoomLevel
* the zoom level for which the size of the world map should be returned.
* @return the horizontal and vertical size of the map in pixel at the given zoom level.
* @throws IllegalArgumentException
* if the given zoom level is negative.
*/
public static long getMapSize(byte zoomLevel) {
if (zoomLevel < 0) {
throw new IllegalArgumentException("zoom level must not be negative: " + zoomLevel);
}
return (long) Tile.TILE_SIZE << zoomLevel;
}