本文整理汇总了Java中org.osmdroid.bonuspack.routing.OSRMRoadManager类的典型用法代码示例。如果您正苦于以下问题:Java OSRMRoadManager类的具体用法?Java OSRMRoadManager怎么用?Java OSRMRoadManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OSRMRoadManager类属于org.osmdroid.bonuspack.routing包,在下文中一共展示了OSRMRoadManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getRoadBetweenLocations
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
private void getRoadBetweenLocations() {
RoadManager roadManager = new OSRMRoadManager(context);
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(new GeoPoint(fromLatitude, fromLongitude));
GeoPoint endPoint = new GeoPoint(toLatitude, toLongitude);
waypoints.add(endPoint);
road = roadManager.getRoad(waypoints);
}
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:9,代码来源:RouteCreationTask.java
示例2: doInBackground
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
@Override
protected Road[] doInBackground(Object... params) {
@SuppressWarnings("unchecked")
ArrayList<GeoPoint> waypoints = (ArrayList<GeoPoint>) params[0];
RoadManager roadManager = new OSRMRoadManager(activity);
return roadManager.getRoads(waypoints);
}
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:8,代码来源:DriverViewRequestActivity.java
示例3: getLocations
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
/**
* Gets locations from ChooseLocationActivity, prints them, and puts them on the map
*/
public void getLocations() {
Intent intent = getIntent();
Gson gson = new Gson();
// clean the map in case user changes location
map.getOverlays().clear();
if (intent.getStringExtra("start") != null) {
startLocation = new Location("");
startLocation = gson.fromJson(intent.getStringExtra("start"), startLocation.getClass());
}
if (startLocation == null) {
startLocationText.setText("");
}
if (startLocation != null) {
startLocationText.setText(startLocation.getAddress());
Marker sMarker = new Marker(map);
sMarker.setPosition(startLocation.getGeoLocation());
sMarker.setTitle(startLocation.getAddress());
sMarker.setIcon(getResources().getDrawable(R.drawable.person));
sMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(sMarker);
}
if (intent.getStringExtra("end") != null) {
endLocation = new Location("");
endLocation = gson.fromJson(intent.getStringExtra("end"), endLocation.getClass());
}
if (endLocation == null) {
endLocationText.setText("");
}
if (endLocation != null) {
endLocationText.setText(endLocation.getAddress());
Marker eMarker = new Marker(map);
eMarker.setPosition(endLocation.getGeoLocation());
eMarker.setTitle(endLocation.getAddress());
eMarker.setIcon(getResources().getDrawable(R.drawable.marker_default));
eMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(eMarker);
}
// If both locations specified, draw the route
if((startLocation != null) & (endLocation != null)) {
RoadManager roadManager = new OSRMRoadManager(this);
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(startLocation.getGeoLocation());
waypoints.add(endLocation.getGeoLocation());
Road road = roadManager.getRoad(waypoints);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
recommendedFare.setText(startLocation.calculateFare(endLocation));
map.getOverlays().add(roadOverlay);
}
map.invalidate();
}
开发者ID:CMPUT301F16T19,项目名称:SeekARide,代码行数:58,代码来源:AddRequestActivity.java
示例4: write
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
/**
* fills in the blank text views with the relavent information from the request.
*/
public void write() {
description = (TextView) findViewById(R.id.view_Description_Text);
startLocationText = (TextView) findViewById(R.id.view_Slocation_Text);
destinationText = (TextView) findViewById(R.id.view_Elocation_Text);
fare = (TextView) findViewById(R.id.view_Fare_Text);
riderInfo = (TextView) findViewById(R.id.view_Info_Text);
description.setText("Description: " + request.getDescription());
startLocationText.setText("From: " + request.getStart().getAddress());
destinationText.setText("To: " + request.getDestination().getAddress());
fare.setText("Fare: $" + ((Double) request.getPrice()).toString());
riderInfo.setText("Rider: " + request.getRiderProfile().getUsername());
riderInfo.setPaintFlags(riderInfo.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
// Initialize map
MapView map = (MapView) findViewById(R.id.view_Offer_Map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
IMapController mapController = map.getController();
mapController.setZoom(10);
// Draw start location marker
Location start = request.getStart();
Marker startMarker = new Marker(map);
startMarker.setPosition(start.getGeoLocation());
startMarker.setTitle(start.getAddress());
startMarker.setIcon(getResources().getDrawable(R.drawable.person));
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(startMarker);
mapController.setCenter(start.getGeoLocation());
// Draw destination marker
Location end = request.getDestination();
Marker endMarker = new Marker(map);
endMarker.setPosition(end.getGeoLocation());
endMarker.setTitle(end.getAddress());
endMarker.setIcon(getResources().getDrawable(R.drawable.marker_default));
endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(endMarker);
// Draw the route in between start and destination
RoadManager roadManager = new OSRMRoadManager(this);
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(start.getGeoLocation());
waypoints.add(end.getGeoLocation());
Road road = roadManager.getRoad(waypoints);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
map.getOverlays().add(roadOverlay);
}
开发者ID:CMPUT301F16T19,项目名称:SeekARide,代码行数:54,代码来源:ViewOfferActivity.java
示例5: onCreate
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rcomplete);
isRider = getIntent().getBooleanExtra("isRider", false);
//requestIndex = getIntent().getIntExtra("requestIndex", -1);
if (isRider) {
//request = Rider.getInstance().getOpenRequests().get(requestIndex);
request = Rider.getInstance().getRequestInProgress();
}
else {
//request = Driver.getInstance().getAcceptedRequests().get(requestIndex);
request = Driver.getInstance().getRequestInProgress();
}
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// Initialize map
final MapView map = (MapView) findViewById(R.id.rCompleteMap);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
IMapController mapController = map.getController();
mapController.setZoom(11);
// Draw start marker
Location start = request.getStart();
Marker startMarker = new Marker(map);
startMarker.setPosition(start.getGeoLocation());
startMarker.setTitle(start.getAddress());
startMarker.setIcon(getResources().getDrawable(R.drawable.person));
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(startMarker);
mapController.setCenter(start.getGeoLocation());
// Draw destination marker
Location end = request.getDestination();
Marker endMarker = new Marker(map);
endMarker.setPosition(end.getGeoLocation());
endMarker.setTitle(end.getAddress());
endMarker.setIcon(getResources().getDrawable(R.drawable.marker_default));
endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(endMarker);
// Draw the route between start and destination
RoadManager roadManager = new OSRMRoadManager(this);
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(start.getGeoLocation());
waypoints.add(end.getGeoLocation());
Road road = roadManager.getRoad(waypoints);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
map.getOverlays().add(roadOverlay);
move();
}
开发者ID:CMPUT301F16T19,项目名称:SeekARide,代码行数:57,代码来源:RequestCompleteActivity.java
示例6: onCreate
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent in = getIntent();
// getting attached intent data
Bundle extras = in.getExtras();
double lat = Double.parseDouble(extras.getString("lat"));
double lon = Double.parseDouble(extras.getString("lon"));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_routing);
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
Criteria criteria = new Criteria();
Location locationNet = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
Location locationGPS = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
//GeoPoint gp = new GeoPoint(48.416312, -4.466546);
GeoPoint gp = null;
if(locationGPS != null) {
gp = new GeoPoint(locationGPS.getLatitude(), locationGPS.getLongitude());
}
else if(locationNet != null){
gp = new GeoPoint(locationNet.getLatitude(), locationNet.getLongitude());
} else {
return;
}
MapView mMap = (MapView) findViewById(R.id.mapRoute);
IMapController mapController = mMap.getController();
RoadManager roadManager = new OSRMRoadManager();
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(gp);
GeoPoint endPoint = new GeoPoint(lat, lon);
waypoints.add(endPoint);
Road road = roadManager.getRoad(waypoints);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, this);
mMap.getOverlays().add(roadOverlay);
//mMap.invalidate();
/*NominatimPOIProvider poiProvider = new NominatimPOIProvider();
ArrayList<POI> pois = poiProvider.getPOICloseTo(gp, "garage", 50, 0.1);
FolderOverlay poiMarkers = new FolderOverlay(this);
mMap.getOverlays().add(poiMarkers);*/
mapController.setCenter(endPoint);
mapController.setZoom(13);
mMap.setMultiTouchControls(true);
}
开发者ID:Darkitty,项目名称:BTB,代码行数:51,代码来源:Routing.java
示例7: onCreateView
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_trace_line, container, false);
mMap = (MapView) rootView.findViewById(R.id.mapLine);
Intent in = getActivity().getIntent();
product = in.getStringExtra("LineNumber");
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
try {
JSONArray tmp = Utils.getJSON("https://applications002.brest-metropole.fr/WIPOD01/Transport.svc/getDestinations?format=json&route_id=" + product);
if(product.equals("A"))
terminus = tmp.getJSONObject(1).getString("Trip_headsign");
else
terminus = tmp.getJSONObject(0).getString("Trip_headsign");
JSONArray jr2 = Utils.getJSON("https://applications002.brest-metropole.fr/WIPOD01/Transport.svc/getStops_route?format=json&route_id="+product+"&trip_headsign="+terminus.replace(" ", "%20"));
for(int i = 1; i < jr2.length(); i++) {
JSONObject object2 = (JSONObject) jr2.getJSONObject(i);
waypoints.add(new GeoPoint(Double.valueOf(object2.getString("Stop_lat")), Double.valueOf(object2.getDouble("Stop_lon"))));
}
// Instantiate a JSON object from the request response
JSONArray jr3 = Utils.getJSON("https://applications002.brest-metropole.fr/WIPOD01/Transport.svc/getGeolocatedVehiclesPosition?format=json&route_id=" + product + "&trip_headsign=" + terminus.replace(" ", "%20"));
Resources res = getResources();
for(int i = 0; i < jr3.length(); i++) {
JSONObject object = (JSONObject) jr3.getJSONObject(i);
OverlayItem overlayItem = new OverlayItem("0, 0", "0, 0", new GeoPoint(Double.valueOf(object.getString("Lat")), Double.valueOf(object.getDouble("Lon"))));
overlayItem.setMarker(res.getDrawable(R.drawable.icone_bus));
overlayItemArray.add(overlayItem);
}
IMapController mapController = mMap.getController();
RoadManager roadManager = new OSRMRoadManager();
Road road = roadManager.getRoad(waypoints);
roadOverlay = RoadManager.buildRoadOverlay(road, rootView.getContext());
mMap.getOverlays().add(roadOverlay);
ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(getActivity(), overlayItemArray, null);
mMap.getOverlays().add(anotherItemizedIconOverlay);
mapController.setCenter(waypoints.get(1));
mapController.setZoom(13);
mMap.setMultiTouchControls(true);
} catch (Exception ex) {
ex.getMessage();
}
this.mHandler = new Handler();
this.mHandler.postDelayed(m_Runnable,5000);
return rootView;
}
开发者ID:Darkitty,项目名称:BTB,代码行数:60,代码来源:Fragment_traceLine.java
示例8: doInBackground
import org.osmdroid.bonuspack.routing.OSRMRoadManager; //导入依赖的package包/类
/**
* Calculating the directions from the current to the location of the
* topComment. Builds a road overlay and adds it to the openMapView
* objects overlays.
*/
@Override
protected Void doInBackground(Void... params) {
RoadManager roadManager = new OSRMRoadManager();
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
GeoLocation currentLocation = new GeoLocation(
locationListenerService);
waypoints.add(new GeoPoint(currentLocation.getLatitude(),
currentLocation.getLongitude()));
waypoints.add(originalPostMarker.getPosition());
Road road = roadManager.getRoad(waypoints);
roadOverlay = RoadManager.buildRoadOverlay(road, getActivity());
Drawable nodeIcon = getResources().getDrawable(
R.drawable.marker_node);
Drawable nodeImage = getResources().getDrawable(
R.drawable.ic_continue);
for (int i = 0; i < road.mNodes.size(); i++) {
RoadNode node = road.mNodes.get(i);
GeoLocation geoLocation = new GeoLocation(node.mLocation);
CustomMarker nodeMarker = new CustomMarker(geoLocation,
mapData.getMap(), nodeIcon);
MarkerInfoWindow infoWindow = new MarkerInfoWindow(
R.layout.bonuspack_bubble, mapData.getMap());
nodeMarker.setInfoWindow(infoWindow);
nodeMarker.setTitle("Step " + i);
nodeMarker.setSnippet(node.mInstructions);
nodeMarker.setSubDescription(Road.getLengthDurationText(
node.mLength, node.mDuration));
nodeMarker.setImage(nodeImage);
setMarkerListeners(nodeMarker);
directionsClusterMarkers.add(nodeMarker);
markers.add(nodeMarker);
}
return null;
}
开发者ID:CMPUT301W14T08,项目名称:GeoChan,代码行数:50,代码来源:MapViewFragment.java
注:本文中的org.osmdroid.bonuspack.routing.OSRMRoadManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论