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


Java RoadManager类代码示例

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


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

示例1: createPolyline

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
private boolean createPolyline() {
        if (map == null || road.mStatus == Road.STATUS_INVALID || road.mStatus == Road.STATUS_TECHNICAL_ISSUE)
            return false;// some error with the road
        roadOverlay = RoadManager.buildRoadOverlay(road);
        roadOverlay.setColor(context.getResources().getColor(R.color.colorAccent));
        roadOverlay.setWidth(16);
        roadOverlay.setGeodesic(true);

//        Drawable nodeIcon = context.getResources().getDrawable(R.drawable.ic_location);
//        for (int i = 0; i < road.mNodes.size(); i++) {
//            RoadNode node = road.mNodes.get(i);
//            Marker nodeMarker = new Marker(map);
//            nodeMarker.setPosition(node.mLocation);
//            nodeMarker.setIcon(nodeIcon);
//            nodeMarker.setTitle("Step " + i);
//            map.getOverlays().add(nodeMarker);
//            nodeMarker.setSnippet(node.mInstructions);
//            nodeMarker.setSubDescription(Road.getLengthDurationText(context, node.mLength, node.mDuration));
//            Drawable icon = context.getResources().getDrawable(R.drawable.ic_filter_selected);
//            nodeMarker.setImage(icon);
//        }
        map.getOverlays().add(roadOverlay);
        map.invalidate();
        return true;
    }
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:26,代码来源:RouteCreationTask.java

示例2: calcRoute

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
/**
 * Calculates a route from your start location to the next bus stop
 */
private  void calcRoute()
{
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();//Strict mode for ignore NetworkOnMainExceptions (!for anytime, have to put in threading)
    StrictMode.setThreadPolicy(policy);

    ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>(); //Build up list of geopoints
    waypoints.add(currenLocation);
    GeoPoint endPoint = new GeoPoint(destinationLocation);
    waypoints.add(endPoint);
    Road road = roadManager.getRoad(waypoints);
    double d = road.mDuration; // get duration
    double x = road.mLength; // get length
    String st_timeLeft = String.format("%s min", String.valueOf(myRound(d / 60,3)));//format string
    String st_dist = String.valueOf(myRound(x * 1000,2)) + " m";

    timeLeft.setText(st_timeLeft);
    distGoal.setText(st_dist);
    Polyline roadOverlay = RoadManager.buildRoadOverlay(road, Activity2.this);// draw route
    mMapView.getOverlays().add(roadOverlay);
    mMapView.invalidate();


}
 
开发者ID:flbbr,项目名称:Run2Stop,代码行数:27,代码来源:Activity2.java

示例3: calcRoute

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
/**
 * Calulates a route from current destination to the next bus stop
 */
private  void calcRoute()
{


    ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
    waypoints.add(currenLocation);
    GeoPoint endPoint = new GeoPoint(destinationLocation);
    waypoints.add(endPoint);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    Road road = roadManager.getRoad(waypoints);
    double d = road.mDuration;
    double x = road.mLength;
    Polyline roadOverlay = RoadManager.buildRoadOverlay(road, MainActivity.this);
    mMapView.getOverlays().add(roadOverlay);
    mMapView.invalidate();


}
 
开发者ID:flbbr,项目名称:Run2Stop,代码行数:23,代码来源:MainActivity.java

示例4: updateUIWithRoad

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
public void updateUIWithRoad(Road road){
    /*Drawable nodeIcon = getResources().getDrawable(R.drawable.marker_node);
    for (int i=0; i<road.mNodes.size(); i++){
        RoadNode node = road.mNodes.get(i);
        Marker nodeMarker = new Marker(map);
        nodeMarker.setPosition(node.mLocation);
        nodeMarker.setIcon(nodeIcon);
        nodeMarker.setTitle("Step " + i);
        nodeMarker.setSnippet(node.mInstructions);
        nodeMarker.setSubDescription(Road.getLengthDurationText(node.mLength, node.mDuration));

        map.getOverlays().add(nodeMarker);
    }
    map.invalidate();*/
    updateRoadOverlay(RoadManager.buildRoadOverlay(road, getActivity()));
}
 
开发者ID:OpenISDM,项目名称:madapp,代码行数:17,代码来源:MapFragment.java

示例5: doInBackground

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
@Override
protected Road doInBackground(Object[] objects) {
    final RoadManager roadManager = new MapQuestRoadManager(MAP_QUEST_API_KEY);
    //RoadManager roadManager = new OSRMRoadManager();
    roadManager.addRequestOption("routeType=pedestrian");
    final String lang;
    switch(DataManager.getInstance().getCurrentLanguage()){
        case ENGLISH:lang = LANG_ENG; break;
        case FRENCH: lang = LANG_FR;  break;
        case DUTCH:
        default:     lang = LANG_NL;
    }
    roadManager.addRequestOption("locale="+lang ); //display the directions in the selected language
    roadManager.addRequestOption("unit=k"); //display the distance in kilometers
    final Road road = roadManager.getRoad(getGeoPointsFromRoute());
    return road;
}
 
开发者ID:oSoc14,项目名称:Artoria,代码行数:18,代码来源:MapFragment.java

示例6: updateUIWithRoad

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
void updateUIWithRoad(Road road) {
	roadNodeMarkers.removeAllItems();
	List<Overlay> mapOverlays = mv.getOverlays();
	if (roadOverlay != null) {
		mapOverlays.remove(roadOverlay);
	}
	if (road == null)
		return;
	if (road.mStatus == Road.STATUS_DEFAULT)
		Toast.makeText(mv.getContext(),
				"We have a problem to get the route", Toast.LENGTH_SHORT)
				.show();
	roadOverlay = RoadManager.buildRoadOverlay(road, mv.getContext());
	Overlay removedOverlay = mapOverlays.set(1, roadOverlay);
	// we set the road overlay at the "bottom", just above the
	// MapEventsOverlay,
	// to avoid covering the other overlays.
	mapOverlays.add(removedOverlay);
	putRoadNodes(road);
	mv.invalidate();
	// Set route info in the text view:
	// ((TextView) findViewById(R.id.routeInfo)).setText(road
	// .getLengthDurationText(-1));
}
 
开发者ID:nirabpudasaini,项目名称:Mero-Bhada-Meter,代码行数:25,代码来源:MapActivity.java

示例7: getRoadBetweenLocations

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的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

示例8: doInBackground

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的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

示例9: onPostExecute

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
@Override
protected void onPostExecute(Road[] roads) {
    double minLength = 0;
    Road bestRoad = null;
    roadList = roads;
    if (roads == null)
        return;
    if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE) {
        Toast.makeText(activity, "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
    } else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) { //functional issues
        Toast.makeText(activity, "No possible route here", Toast.LENGTH_SHORT).show();
    }
    List<Overlay> mapOverlays = map.getOverlays();
    for (Road road : roads) {
        if(road.mLength < minLength || minLength == 0) {
            minLength = road.mLength;
            bestRoad = road;
        }
    }

    String routeDesc = bestRoad.getLengthDurationText(activity, -1);
    Polyline roadPolyline = RoadManager.buildRoadOverlay(bestRoad);
    roadPolyline.setTitle(getString(R.string.app_name) + " - " + routeDesc);
    roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    mapOverlays.add(0, roadPolyline);
    map.invalidate();
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:28,代码来源:DriverViewRequestActivity.java

示例10: onPostExecute

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
@Override
protected void onPostExecute(Road[] roads) {
    double minLength = 0;
    Road bestRoad = null;
    roadList = roads;
    if (roads == null)
        return;
    if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE) {
        Toast.makeText(activity, "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
    } else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) { //functional issues
        Toast.makeText(activity, "No possible route here", Toast.LENGTH_SHORT).show();
    }
    List<Overlay> mapOverlays = map.getOverlays();
    for (Road road : roads) {
        if(road.mLength < minLength || minLength == 0) {
            minLength = road.mLength;
            bestRoad = road;
        }
    }

    String routeDesc = bestRoad.getLengthDurationText(activity, -1);
    bundle.putDouble("distance", bestRoad.mLength);
    bundle.putDouble("duration", bestRoad.mDuration);

    Polyline roadPolyline = RoadManager.buildRoadOverlay(bestRoad);
    roadPolyline.setTitle(getString(R.string.app_name) + " - " + routeDesc);
    roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    mapOverlays.add(0, roadPolyline);
    map.invalidate();
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:31,代码来源:ViewLocationsActivity.java

示例11: onPostExecute

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
@Override
protected void onPostExecute(Road[] roads) {
    double minLength = 0;
    Road bestRoad = null;
    roadList = roads;
    if (roads == null)
        return;
    if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE) {
        Toast.makeText(activity, "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
    } else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) { //functional issues
        Toast.makeText(activity, "No possible route here", Toast.LENGTH_SHORT).show();
    }
    List<Overlay> mapOverlays = map.getOverlays();
    for (Road road : roads) {
        if (road.mLength < minLength || minLength == 0) {
            minLength = road.mLength;
            bestRoad = road;
        }
    }

    String routeDesc = bestRoad.getLengthDurationText(activity, -1);
    Polyline roadPolyline = RoadManager.buildRoadOverlay(bestRoad);
    roadPolyline.setTitle(getString(R.string.app_name) + " - " + routeDesc);
    roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    mapOverlays.add(0, roadPolyline);
    map.invalidate();
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:28,代码来源:RiderRequestActivity.java

示例12: doInBackground

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
@Override
protected Polyline doInBackground(GeoPoint... places) {
    // Starts a RoadManager using the key acquired with a Graphhopper account
    RoadManager roadManager = new GraphHopperRoadManager(BuildConfig.GRAPHHOPPER_KEY,true);
    roadManager.addRequestOption("vehicle=foot");
    ArrayList<GeoPoint> wayPoints = new ArrayList<>();
    Collections.addAll(wayPoints, places);
    // Calculates the route
    Road road = roadManager.getRoad(wayPoints);
    if( road.mStatus == 0) // succeed
        return RoadManager.buildRoadOverlay(road);

    taskStatus = ServerResponse.CONNECTION_FAILED;
    return null;
}
 
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:16,代码来源:SearchRouteTask.java

示例13: doInBackground

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
@Override
protected Polyline doInBackground(LatLng... params) {
    RoadManager roadManager = new GoogleRoadManager();
    ArrayList<GeoPoint> waypoints = new ArrayList<>();
    for (LatLng p : params){
        waypoints.add(new GeoPoint(p.latitude,p.longitude));
    }
    Road road = roadManager.getRoad(waypoints);
    Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
    callback.onFinished(roadOverlay);
    return roadOverlay;
}
 
开发者ID:RSDT,项目名称:Japp16,代码行数:13,代码来源:Navigator.java

示例14: getRoutingRoad

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
public static Road getRoutingRoad(Context context, RouteCalculator routeCalculator,
                                      int whichRouteProvider, ArrayList<GeoPoint> waypoints)
    {
        RoadManager roadManager = null;
        Locale locale = new Locale("fa", "IR");
        switch (whichRouteProvider) {
            case OSRM:
//                    roadManager = new OSRMRoadManager();
                break;
            case GRAPHHOPPER_FASTEST:
                roadManager = new GraphHopperRoadManager(context);
                ((GraphHopperRoadManager)roadManager).mRouteCalculator = routeCalculator;
                roadManager.addRequestOption("locale=" + locale.getLanguage());

                break;
            case GRAPHHOPPER_BICYCLE:
                roadManager = new GraphHopperRoadManager(context);
                ((GraphHopperRoadManager)roadManager).mRouteCalculator = routeCalculator;
                roadManager.addRequestOption("locale=" + locale.getLanguage());
                roadManager.addRequestOption("vehicle=bike");
                //((GraphHopperRoadManager)roadManager).setElevation(true);
                break;
            case GRAPHHOPPER_PEDESTRIAN:
                roadManager = new GraphHopperRoadManager(context);
                ((GraphHopperRoadManager)roadManager).mRouteCalculator = routeCalculator;
                roadManager.addRequestOption("locale=" + locale.getLanguage());
                roadManager.addRequestOption("vehicle=foot");
                //((GraphHopperRoadManager)roadManager).setElevation(true);
                break;
            case GOOGLE_FASTEST:
//                    roadManager = new GoogleRoadManager();
                break;
            default:
                return null;
        }
        return roadManager.getRoad(waypoints);
    }
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:38,代码来源:Helper.java

示例15: updateUIWithRoads

import org.osmdroid.bonuspack.routing.RoadManager; //导入依赖的package包/类
void updateUIWithRoads(Road[] roads){
mRoadNodeMarkers.getItems().clear();
TextView textView = (TextView)findViewById(R.id.routeInfo);
textView.setText("");
List<Overlay> mapOverlays = map.getOverlays();
if (mRoadOverlays != null){
	for (int i=0; i<mRoadOverlays.length; i++)
		mapOverlays.remove(mRoadOverlays[i]);
	mRoadOverlays = null;
}
if (roads == null)
	return;
if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE)
	Toast.makeText(map.getContext(), "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
else if (roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE) //functional issues
	Toast.makeText(map.getContext(), "No possible route here", Toast.LENGTH_SHORT).show();
mRoadOverlays = new Polyline[roads.length];
for (int i=0; i<roads.length; i++) {
	Polyline roadPolyline = RoadManager.buildRoadOverlay(roads[i]);
	mRoadOverlays[i] = roadPolyline;
	if (mWhichRouteProvider == GRAPHHOPPER_BICYCLE || mWhichRouteProvider == GRAPHHOPPER_PEDESTRIAN) {
		Paint p = roadPolyline.getPaint();
		p.setPathEffect(new DashPathEffect(new float[]{10, 5}, 0));
	}
	String routeDesc = roads[i].getLengthDurationText(this, -1);
	roadPolyline.setTitle(getString(R.string.route) + " - " + routeDesc);
	roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
	roadPolyline.setRelatedObject(i);
	roadPolyline.setOnClickListener(new RoadOnClickListener());
	mapOverlays.add(1, roadPolyline);
	//we insert the road overlays at the "bottom", just above the MapEventsOverlay,
	//to avoid covering the other overlays. 
}
selectRoad(0);
  }
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:36,代码来源:MapActivity.java


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