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


Java BoundingBox类代码示例

本文整理汇总了Java中org.osmdroid.util.BoundingBox的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox类的具体用法?Java BoundingBox怎么用?Java BoundingBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getBoundingBox

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * This function finds a BoundingBox that fits both the start and end location points.
 *
 * @param start GeoPoint for start location
 * @param end GeoPoint for end location
 * @return BoundingBox that holds both location points
 */
private BoundingBox getBoundingBox(GeoPoint start, GeoPoint end) {
    double north;
    double south;
    double east;
    double west;
    if(start.getLatitude() > end.getLatitude()) {
        north = start.getLatitude();
        south = end.getLatitude();
    } else {
        north = end.getLatitude();
        south = start.getLatitude();
    }
    if(start.getLongitude() > end.getLongitude()) {
        east = start.getLongitude();
        west = end.getLongitude();
    } else {
        east = end.getLongitude();
        west = start.getLongitude();
    }
    return new BoundingBox(north, east, south, west);
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:29,代码来源:DriverViewRequestActivity.java

示例2: zoomToBounds

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * This function allows the MapView to zoom to show the whole path between
 * the start and end points.
 *
 * @param box BoundingBox for start and end points
 */
// see code attribution
private void zoomToBounds(final BoundingBox box) {
    if (map.getHeight() > 0) {
        map.zoomToBoundingBox(box, false);
        map.zoomToBoundingBox(box, false);
    } else {
        ViewTreeObserver vto = map.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                map.zoomToBoundingBox(box, false);
                map.zoomToBoundingBox(box, false);
                ViewTreeObserver vto2 = map.getViewTreeObserver();
                vto2.removeOnGlobalLayoutListener(this);
            }
        });
    }
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:25,代码来源:DriverViewRequestActivity.java

示例3: getBoundingBox

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * This function finds a BoundingBox that fits both the start and end location points.
 *
 * @param start GeoPoint for start location
 * @param end GeoPoint for end location
 * @return BoundingBox that holds both location points
 */
public BoundingBox getBoundingBox(GeoPoint start, GeoPoint end) {
    double north;
    double south;
    double east;
    double west;
    if(start.getLatitude() > end.getLatitude()) {
        north = start.getLatitude();
        south = end.getLatitude();
    } else {
        north = end.getLatitude();
        south = start.getLatitude();
    }
    if(start.getLongitude() > end.getLongitude()) {
        east = start.getLongitude();
        west = end.getLongitude();
    } else {
        east = end.getLongitude();
        west = start.getLongitude();
    }
    return new BoundingBox(north, east, south, west);
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:29,代码来源:ViewLocationsActivity.java

示例4: zoomToBounds

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * This function allows the MapView to zoom to show the whole path between
 * the start and end points.
 *
 * @param box BoundingBox for start and end points
 */
// see code attribution
public void zoomToBounds(final BoundingBox box) {
    if (map.getHeight() > 0) {
        map.zoomToBoundingBox(box, false);
        map.zoomToBoundingBox(box, false);
    } else {
        ViewTreeObserver vto = map.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                map.zoomToBoundingBox(box, false);
                map.zoomToBoundingBox(box, false);
                ViewTreeObserver vto2 = map.getViewTreeObserver();
                vto2.removeOnGlobalLayoutListener(this);
            }
        });
    }
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:25,代码来源:ViewLocationsActivity.java

示例5: setBoundingBox

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
private void setBoundingBox() {
    double minLat = Integer.MAX_VALUE;
    double maxLat = Integer.MIN_VALUE;
    double minLong = Integer.MAX_VALUE;
    double maxLong = Integer.MIN_VALUE;

    for (OverlayItem item : placeMarkers) {
        GeoPoint point = new GeoPoint(item.getPoint().getLatitude(), item.getPoint().getLongitude());
        if (point.getLatitude() < minLat)
            minLat = point.getLatitude();
        if (point.getLatitude() > maxLat)
            maxLat = point.getLatitude();
        if (point.getLongitude() < minLong)
            minLong = point.getLongitude();
        if (point.getLongitude() > maxLong)
            maxLong = point.getLongitude();
    }

    BoundingBox boundingBox = new BoundingBox(maxLat, maxLong, minLat, minLong);
    map.zoomToBoundingBox(boundingBox, true);
}
 
开发者ID:hamzux,项目名称:cosi,代码行数:22,代码来源:PlacesFragment.java

示例6: innerSetRoute

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
private void innerSetRoute(Route route){
    adapter.changeItems(route.steps);

    final ArrayList<GeoPoint> activePoints = new ArrayList<>();
    Log.d(TAG,route.northEastPoint.toString());
    Log.d(TAG,route.southWestPoint.toString());
    activePoints.add(route.northEastPoint);
    activePoints.add(route.southWestPoint);

    List<Route> routeList = new ArrayList<>();
    routeList.add(route);
    routerOptionAdapter.changeItems(routeList);

    convertView = routerOptionAdapter.getView(0, convertView, viewGroup);

    title.setText(route.title);
    currentStrategy = new RouterStrategy(mapView, this,
            new RedirectionListener(getActivity()), route);
    mapView.zoomToBoundingBox(BoundingBox.fromGeoPoints(activePoints), false);
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:21,代码来源:RouterMapFragment.java

示例7: onPostExecute

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
@Override protected void onPostExecute(Boolean ok) {
	if (mPD != null)
		mPD.dismiss();
	if (!ok)
		Toast.makeText(getApplicationContext(), "Sorry, unable to read "+mUri, Toast.LENGTH_SHORT).show();
	updateUIWithKml();
	if (ok){
		BoundingBox bb = mKmlDocument.mKmlRoot.getBoundingBox();
		if (bb != null){
			if (!mOnCreate)
				setViewOn(bb);
			else  //KO in onCreate (osmdroid bug) - Workaround:
				setInitialViewOn(bb);
		}
	}
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:17,代码来源:MapActivity.java

示例8: shouldBeDrawn

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * @param mapBB bounding box of the map view
 * @param mapOrientation orientation of the map view
 * @return true if the overlay should be drawn.
 */
public boolean shouldBeDrawn(BoundingBox mapBB, float mapOrientation){
    if (!mBoundingBoxSet)
        return true;
    if (mBoundingBox == null)
        //null bounding box means overlay is empty, so nothing to draw:
        return false;
    if (mapOrientation != 0.0f)
        //TODO - handle map rotation...
        return true;
    if (mBoundingBox.getLatSouth() > mapBB.getLatNorth()
        || mBoundingBox.getLatNorth() < mapBB.getLatSouth()
        || mBoundingBox.getLonWest() > mapBB.getLonEast()
        || mBoundingBox.getLonEast() < mapBB.getLonWest())
        //completely outside the map view:
        return false;
    return true;
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:23,代码来源:FolderZOverlay.java

示例9: urlForTagSearchKml

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * Build the URL to search for elements having a specific OSM Tag (key=value), within a bounding box. 
 * Similar to {@link #urlForPOISearch}, but here the request is built to retrieve the full geometry. 
 * @param tag
 * @param bb bounding box
 * @param limit max number of results. 
 * @param timeout in seconds
 * @return the url for this request. 
 */
public String urlForTagSearchKml(String tag, BoundingBox bb, int limit, int timeout){
	StringBuilder s = new StringBuilder();
	s.append(mService+"?data=");
	String sBB = "("+bb.getLatSouth()+","+bb.getLonWest()+","+bb.getLatNorth()+","+bb.getLonEast()+")";
	String data = 
		"[out:json][timeout:"+timeout+"];"
		+ "(node["+tag+"]"+sBB+";"
		+ "way["+tag+"]"+sBB+";);"
		+ "out qt geom tags "+ limit + ";"
		+ "relation["+tag+"]"+sBB+";out qt geom body "+ limit+";"; //relation isolated to get geometry with body option
	//TODO: see issue https://github.com/drolbr/Overpass-API/issues/134#issuecomment-58847362
	//When solved, simplify. 
	Log.d(BonusPackHelper.LOG_TAG, "data="+data);
	s.append(URLEncoder.encode(data));
	return s.toString();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:26,代码来源:OverpassAPIProvider.java

示例10: getUrlInside

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
private String getUrlInside(BoundingBox boundingBox, int maxResults, String query){
	StringBuilder url = new StringBuilder("http://picasaweb.google.com/data/feed/api/all?");
	url.append("bbox="+boundingBox.getLonWest());
	url.append(","+boundingBox.getLatSouth());
	url.append(","+boundingBox.getLonEast());
	url.append(","+boundingBox.getLatNorth());
	url.append("&max-results="+maxResults);
	url.append("&thumbsize=64c"); //thumbnail size: 64, cropped. 
	url.append("&fields=openSearch:totalResults,entry(summary,media:group/media:thumbnail,media:group/media:title,gphoto:*,georss:where,link)");
	if (query != null)
		url.append("&q="+URLEncoder.encode(query));
	if (mAccessToken != null){
		//TODO: warning: not tested... 
		url.append("&access_token="+mAccessToken);
	}
	return url.toString();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:18,代码来源:PicasaPOIProvider.java

示例11: getUrlInside

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
private String getUrlInside(BoundingBox boundingBox, int maxResults){
	StringBuilder url = new StringBuilder("https://api.flickr.com/services/rest/?method=flickr.photos.search");
	url.append("&api_key="+mApiKey);
	url.append("&bbox="+boundingBox.getLonWest());
	url.append(","+boundingBox.getLatSouth());
	url.append(","+boundingBox.getLonEast());
	url.append(","+boundingBox.getLatNorth());
	url.append("&has_geo=1");
	url.append("&format=json&nojsoncallback=1");
	url.append("&per_page="+maxResults);
	
	//From Flickr doc: "Geo queries require some sort of limiting agent in order to prevent the database from crying."
	//And min_date_upload is considered as a limiting agent. So:
	url.append("&min_upload_date=2005/01/01");
	
	//Ask to provide some additional attributes we will need:
	url.append("&extras=geo,url_sq");
	url.append("&sort=interestingness-desc");
	return url.toString();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:21,代码来源:FlickrPOIProvider.java

示例12: SimpleFastPointOverlay

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
public SimpleFastPointOverlay(PointAdapter pointList, SimpleFastPointOverlayOptions style) {
    mStyle = style;
    mPointList = pointList;

    Double east = null, west = null, north = null, south = null;
    for(IGeoPoint p : mPointList) {
        if(p == null) continue;
        if(east == null || p.getLongitude() > east) east = p.getLongitude();
        if(west == null || p.getLongitude() < west) west = p.getLongitude();
        if(north == null || p.getLatitude() > north) north = p.getLatitude();
        if(south == null || p.getLatitude() < south) south = p.getLatitude();
    }

    if(east != null)
        mBoundingBox = new BoundingBox(north, east, south, west);
    else
        mBoundingBox = null;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:19,代码来源:SimpleFastPointOverlay.java

示例13: zoomToBoundingBox

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * @since 6.0.0
 */
public void zoomToBoundingBox(final BoundingBox boundingBox, final boolean animated, final int borderSizeInPixels) {
	double nextZoom = TileSystem.getBoundingBoxZoom(boundingBox, getWidth() - 2 * borderSizeInPixels, getHeight() - 2 * borderSizeInPixels);
	if (nextZoom == Double.MIN_VALUE) {
		return;
	}
	nextZoom = Math.min(getMaxZoomLevel(), Math.max(nextZoom, getMinZoomLevel()));
	final IGeoPoint center = boundingBox.getCenterWithDateLine();
	if(animated) { // it's best to set the center first, because the animation is not immediate
		// in a perfect world there would be an animation for both center and zoom level
		getController().setCenter(center);
		getController().zoomTo(nextZoom);
	} else { // it's best to set the zoom first, so that the center is accurate
		getController().setZoom(nextZoom);
		getController().setCenter(center);
	}
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:20,代码来源:MapView.java

示例14: createPolygon

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * converts the bounding box into a color filled polygon
 *
 * @param key
 * @param value
 * @param redthreshold
 * @param orangethreshold
 * @return
 */
private Overlay createPolygon(BoundingBox key, Integer value, int redthreshold, int orangethreshold) {
    Polygon polygon = new Polygon(mMapView);
    if (value < orangethreshold)
        polygon.setFillColor(Color.parseColor(alpha + yellow));
    else if (value < redthreshold)
        polygon.setFillColor(Color.parseColor(alpha + orange));
    else if (value >= redthreshold)
        polygon.setFillColor(Color.parseColor(alpha + red));
    else {
        //no polygon
    }
    polygon.setStrokeColor(polygon.getFillColor());

    //if you set this to something like 20f and have a low alpha setting,
    // you'll end with a gaussian blur like effect
    polygon.setStrokeWidth(0f);
    List<GeoPoint> pts = new ArrayList<GeoPoint>();
    pts.add(new GeoPoint(key.getLatNorth(), key.getLonWest()));
    pts.add(new GeoPoint(key.getLatNorth(), key.getLonEast()));
    pts.add(new GeoPoint(key.getLatSouth(), key.getLonEast()));
    pts.add(new GeoPoint(key.getLatSouth(), key.getLonWest()));
    polygon.setPoints(pts);
    return polygon;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:34,代码来源:HeatMap.java

示例15: getTileSources

import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
 * returns ALL available raster tile sources for all "imported" geopackage databases
 *
 * @return
 */
public List<GeopackageRasterTileSource> getTileSources() {
    List<GeopackageRasterTileSource> srcs = new ArrayList<>();

    List<String> databases = manager.databases();
    for (int i = 0; i < databases.size(); i++) {

        GeoPackage open = manager.open(databases.get(i));
        List<String> tileTables = open.getTileTables();
        for (int k = 0; k < tileTables.size(); k++) {
            TileDao tileDao = open.getTileDao(tileTables.get(k));
            mil.nga.geopackage.BoundingBox boundingBox = tileDao.getBoundingBox();
            ProjectionTransform transformation = tileDao.getProjection().getTransformation(tileDao.getProjection());
            boundingBox = transformation.transform(boundingBox);
            BoundingBox bounds = new BoundingBox(boundingBox.getMaxLatitude(), boundingBox.getMaxLongitude(), boundingBox.getMinLatitude(), boundingBox.getMinLongitude());
            srcs.add(new GeopackageRasterTileSource(databases.get(i), tileTables.get(k), (int)tileDao.getMinZoom(), (int)tileDao.getMaxZoom(), bounds));

        }
        open.close();
    }

    return srcs;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:28,代码来源:GeoPackageMapTileModuleProvider.java


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