當前位置: 首頁>>代碼示例>>Java>>正文


Java MapView.getBoundingBox方法代碼示例

本文整理匯總了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;
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:38,代碼來源:GridMarkerClusterer.java

示例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;
}
 
開發者ID:MKergall,項目名稱:osmbonuspack,代碼行數:38,代碼來源:GridMarkerClusterer.java

示例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;
    }
 
開發者ID:BackPackerDz,項目名稱:Android-Tariki.dz,代碼行數:16,代碼來源:RadiusMarkerClusterer.java

示例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;
    }
 
開發者ID:MKergall,項目名稱:osmbonuspack,代碼行數:16,代碼來源:RadiusMarkerClusterer.java


注:本文中的org.osmdroid.views.MapView.getBoundingBox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。