本文整理汇总了Java中org.osmdroid.util.BoundingBox类的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox类的具体用法?Java BoundingBox怎么用?Java BoundingBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundingBox类属于org.osmdroid.util包,在下文中一共展示了BoundingBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getTileSource
import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
public GeopackageRasterTileSource getTileSource(String database, String table) {
Iterator<GeoPackage> iterator = geopackage.tileSources.iterator();
while (iterator.hasNext()){
GeoPackage next = iterator.next();
if (next.getName().equalsIgnoreCase(database)) {
//found the database
if (next.getTileTables().contains(table)) {
//find the tile table
TileDao tileDao = next.getTileDao(table);
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());
return new GeopackageRasterTileSource(database,table, (int)tileDao.getMinZoom(),(int)tileDao.getMaxZoom(), bounds);
}
}
}
return null;
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:21,代码来源:GeoPackageProvider.java
示例17: successGetPositions
import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
@Override
public void successGetPositions(List<Position> positions) {
Timber.d("Interval positions: " + positions);
ArrayList<GeoPoint> points = new ArrayList<>();
for (Position position: positions) {
points.add(new GeoPoint(position.getLatitude(), position.getLongitude()));
}
pathOverlay.setPoints(points);
mMapView.zoomToBoundingBox(BoundingBox.fromGeoPoints(points), true);
mMapView.postInvalidate();
mList.setAdapter(new PositionsExpandableListAdapter(getContext(), 0, positions));
}
开发者ID:erlymon,项目名称:erlymon-monitor-android,代码行数:15,代码来源:ReportFragment.java
示例18: newInstance
import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
* Initialize a MapFragment based on an specifc location
* @param chosenPlace Place containing name and coordinates
* @param mapBoundaries Coordinates of the box to limit the map
* @return MapFragment Instance
*/
public static MapFragment newInstance(final Place chosenPlace, final BoundingBox mapBoundaries) {
MapFragment fragment = new MapFragment();
defaultPlace = chosenPlace;
mapRegion = mapBoundaries;
return fragment;
}
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:13,代码来源:MapFragment.java
示例19: setupMapFragment
import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
/**
* Configuration method for the MapFragment.
* It will pass up to the fragment the location where the map should be positioned.
*/
private void setupMapFragment(){
mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MapFragment.FRAGMENT_TAG);
if(mapFragment == null){
try {
// Get location configs from file
final String[] defaultPlaceCoord = ConfigHelper.getConfigValue(this, Constants.DEFAULT_PLACE_COORDINATES).split(",");
final String[] mapRegionBounds = ConfigHelper.getConfigValue(this, Constants.MAP_REGION_BOUNDS).split(",");
final String defaultPlaceName = ConfigHelper.getConfigValue(this, Constants.DEFAULT_PLACE_NAME);
// Parse information about place
double lat = Double.valueOf(defaultPlaceCoord[0]);
double longtd = Double.valueOf(defaultPlaceCoord[1]);
// Parse information about map bounds
double north = Double.valueOf(mapRegionBounds[0]);
double east = Double.valueOf(mapRegionBounds[1]);
double south = Double.valueOf(mapRegionBounds[2]);
double west = Double.valueOf(mapRegionBounds[3]);
// Define variables to pass to the MapFragment
final BoundingBox mapBounds = new BoundingBox(north,east,south,west);
final Place chosenLocation = new Place(lat,longtd,defaultPlaceName);
mapFragment = MapFragment.newInstance(chosenLocation,mapBounds);
// Loads the fragment
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.frame_map_container,mapFragment,MapFragment.FRAGMENT_TAG);
ft.commit();
}catch (NullPointerException e){
e.printStackTrace();
}
}
}
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:40,代码来源:MainActivity.java
示例20: boundBoxBuses
import org.osmdroid.util.BoundingBox; //导入依赖的package包/类
private void boundBoxBuses(ArrayList<MapBus> buses){
ArrayList<GeoPoint> geoPoints = new ArrayList<>();
Collections.sort(buses, new Comparator<MapBus>() {
@Override
public int compare(MapBus bus1, MapBus bus2) {
return bus1.getDistance() < bus2.getDistance() ? -1 :
(bus1.getDistance() == bus2.getDistance() ? 0 : 1);
}
});
MapBus nearBus = null;
for (MapBus bus : buses){
if (bus.getLatitude() != Double.POSITIVE_INFINITY &&
bus.getLongitude() != Double.POSITIVE_INFINITY &&
!currentVisibilityState.contains(bus.getService().getName())) {
nearBus = bus;
break;
}
}
if (nearBus == null || nearBus.getDistance() < MINIMUM_ZOOMING_DISTANCE_IN_METERS){
return;
}
GeoPoint busPoint = new GeoPoint(nearBus.getLatitude(), nearBus.getLongitude());
geoPoints.add(busPoint);
geoPoints.add(rotatePoint(busPoint, new GeoPoint(selectedBusStopMarker.getPosition())));
getMapView().zoomToBoundingBox(BoundingBox.fromGeoPoints(geoPoints), false);
}
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:29,代码来源:BusStopStrategy.java
注:本文中的org.osmdroid.util.BoundingBox类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论