当前位置: 首页>>代码示例>>Java>>正文


Java Tile.getPixelY方法代码示例

本文整理汇总了Java中org.mapsforge.core.model.Tile.getPixelY方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.getPixelY方法的具体用法?Java Tile.getPixelY怎么用?Java Tile.getPixelY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mapsforge.core.model.Tile的用法示例。


在下文中一共展示了Tile.getPixelY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPriority

import org.mapsforge.core.model.Tile; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:45,代码来源:TileScheduler.java

示例2: drawBitmap

import org.mapsforge.core.model.Tile; //导入方法依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:56,代码来源:FrameBuffer.java


注:本文中的org.mapsforge.core.model.Tile.getPixelY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。