本文整理匯總了Java中org.osmdroid.views.MapView.getBoundingBox方法的典型用法代碼示例。如果您正苦於以下問題:Java MapView.getBoundingBox方法的具體用法?Java MapView.getBoundingBox怎麽用?Java MapView.getBoundingBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osmdroid.views.MapView
的用法示例。
在下文中一共展示了MapView.getBoundingBox方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clusterer
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/** Grid-based clustering algorithm */
@Override public ArrayList<StaticCluster> clusterer(MapView mapView){
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
BoundingBoxE6 bb = mapView.getBoundingBox();
double latSpan = bb.getLatitudeSpanE6()*1E-6;
double lonSpan = bb.getLongitudeSpanE6()*1E-6;
//Log.d("ZOOM", "latSpan="+latSpan+" lonSpan="+lonSpan);
//convert grid size from pixels to degrees:
double gridSizeX, gridSizeY;
gridSizeX = lonSpan * (double)mGridSize / (double)(mScreenRect.right - mScreenRect.left);
gridSizeY = latSpan * (double)mGridSize / (double)(mScreenRect.bottom - mScreenRect.top);
int numCellsW = (int)(360.0f/gridSizeX);
//Log.d("ZOOM", "zoomlevel="+mapView.getZoomLevel()+" cells="+numCellsW);
//Log.d("ZOOM", "gridSizeX="+gridSizeX+" gridSizeY="+gridSizeY);
ArrayList<StaticCluster> clusters = new ArrayList<StaticCluster>();
LongSparseArray<StaticCluster> sparseArray = new LongSparseArray<StaticCluster>();
for (Marker item:mItems){
//TODO - add 180° to prevent negative values
long gridX = (long)(item.getPosition().getLongitude() / gridSizeX);
long gridY = (long)(item.getPosition().getLatitude() / gridSizeY);
long coord = numCellsW * gridX + gridY;
StaticCluster cluster = sparseArray.get(coord);
//Log.d("ZOOM", "coord="+coord+" =>cluster:"+(cluster==null?"new":"add"));
if (cluster == null) {
//GeoPoint clusterCorner = new GeoPoint(gridSizeY*(double)gridY, gridSizeX*(double)gridX);
cluster = new StaticCluster(item.getPosition() /*clusterCorner*/);
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
return clusters;
}
示例2: clusterer
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/** Grid-based clustering algorithm */
@Override public ArrayList<StaticCluster> clusterer(MapView mapView){
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
BoundingBox bb = mapView.getBoundingBox();
double latSpan = bb.getLatitudeSpan();
double lonSpan = bb.getLongitudeSpan();
//Log.d("ZOOM", "latSpan="+latSpan+" lonSpan="+lonSpan);
//convert grid size from pixels to degrees:
double gridSizeX, gridSizeY;
gridSizeX = lonSpan * (double)mGridSize / (double)(mScreenRect.right - mScreenRect.left);
gridSizeY = latSpan * (double)mGridSize / (double)(mScreenRect.bottom - mScreenRect.top);
int numCellsW = (int)(360.0f/gridSizeX);
//Log.d("ZOOM", "zoomlevel="+mapView.getZoomLevel()+" cells="+numCellsW);
//Log.d("ZOOM", "gridSizeX="+gridSizeX+" gridSizeY="+gridSizeY);
ArrayList<StaticCluster> clusters = new ArrayList<StaticCluster>();
LongSparseArray<StaticCluster> sparseArray = new LongSparseArray<StaticCluster>();
for (Marker item:mItems){
//TODO - add 180° to prevent negative values
long gridX = (long)(item.getPosition().getLongitude() / gridSizeX);
long gridY = (long)(item.getPosition().getLatitude() / gridSizeY);
long coord = numCellsW * gridX + gridY;
StaticCluster cluster = sparseArray.get(coord);
//Log.d("ZOOM", "coord="+coord+" =>cluster:"+(cluster==null?"new":"add"));
if (cluster == null) {
//GeoPoint clusterCorner = new GeoPoint(gridSizeY*(double)gridY, gridSizeX*(double)gridX);
cluster = new StaticCluster(item.getPosition() /*clusterCorner*/);
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
return clusters;
}
示例3: convertRadiusToMeters
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void convertRadiusToMeters(MapView mapView) {
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
int screenWidth = mScreenRect.right - mScreenRect.left;
int screenHeight = mScreenRect.bottom - mScreenRect.top;
BoundingBoxE6 bb = mapView.getBoundingBox();
double diagonalInMeters = bb.getDiagonalLengthInMeters();
double diagonalInPixels = Math.sqrt(screenWidth * screenWidth + screenHeight * screenHeight);
double metersInPixel = diagonalInMeters / diagonalInPixels;
mRadiusInMeters = mRadiusInPixels * metersInPixel;
}
示例4: convertRadiusToMeters
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void convertRadiusToMeters(MapView mapView) {
Rect mScreenRect = mapView.getIntrinsicScreenRect(null);
int screenWidth = mScreenRect.right - mScreenRect.left;
int screenHeight = mScreenRect.bottom - mScreenRect.top;
BoundingBox bb = mapView.getBoundingBox();
double diagonalInMeters = bb.getDiagonalLengthInMeters();
double diagonalInPixels = Math.sqrt(screenWidth * screenWidth + screenHeight * screenHeight);
double metersInPixel = diagonalInMeters / diagonalInPixels;
mRadiusInMeters = mRadiusInPixels * metersInPixel;
}