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


Java RoadManager.getRoad方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: getLocations

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

示例7: write

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

示例8: onCreate

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

示例9: onCreate

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

示例10: onCreateView

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

示例11: doInBackground

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

示例12: buildRoute

import org.osmdroid.bonuspack.routing.RoadManager; //导入方法依赖的package包/类
/**
 * Builds a route between points
 * @param roadManager The RoadManager chosen to calculate the itinerary
 * @param arrayList The list of GeoPoints to calculate the itinireray between
 * @return The Road between all points
 */
public Road buildRoute(RoadManager roadManager, ArrayList<GeoPoint> arrayList) {
    Road route = roadManager.getRoad(arrayList);
    return route;
}
 
开发者ID:WikiJourney,项目名称:wikijourney_app,代码行数:11,代码来源:Routing.java


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