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


Java Road类代码示例

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


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

示例1: createPolyline

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

import org.osmdroid.bonuspack.routing.Road; //导入依赖的package包/类
private void putRoadNodes(Road road){
	mRoadNodeMarkers.getItems().clear();
	Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_node, null);
	int n = road.mNodes.size();
	MarkerInfoWindow infoWindow = new MarkerInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map);
	TypedArray iconIds = getResources().obtainTypedArray(R.array.direction_icons);
   	for (int i=0; i<n; i++){
   		RoadNode node = road.mNodes.get(i);
   		String instructions = (node.mInstructions==null ? "" : node.mInstructions);
   		Marker nodeMarker = new Marker(map);
   		nodeMarker.setTitle(getString(R.string.step)+ " " + (i+1));
   		nodeMarker.setSnippet(instructions);
		nodeMarker.setSubDescription(Road.getLengthDurationText(this, node.mLength, node.mDuration));
		nodeMarker.setPosition(node.mLocation);
   		nodeMarker.setIcon(icon);
		nodeMarker.setInfoWindow(infoWindow); //use a shared infowindow.
		int iconId = iconIds.getResourceId(node.mManeuverType, R.drawable.ic_empty);
   		if (iconId != R.drawable.ic_empty){
			Drawable image = ResourcesCompat.getDrawable(getResources(), iconId, null);
			nodeMarker.setImage(image);
   		}
   		mRoadNodeMarkers.add(nodeMarker);
   	}
   	iconIds.recycle();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:26,代码来源:MapActivity.java

示例6: onCreate

import org.osmdroid.bonuspack.routing.Road; //导入依赖的package包/类
@Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.items_list);

    ListView list = (ListView) findViewById(R.id.items);

    Intent myIntent = getIntent();
    final int selectedRoad = myIntent.getIntExtra("SELECTED_ROAD", 0);
    Road road = MapActivity.mRoads[selectedRoad]; //too big to pass safely in Extras
    final int currentNodeId = myIntent.getIntExtra("NODE_ID", -1);
    RoadNodesAdapter adapter = new RoadNodesAdapter(this, road);

    list.setOnItemClickListener(new OnItemClickListener() {
        @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
Intent intent = new Intent();
 		intent.putExtra("NODE_ID", position);
setResult(RESULT_OK, intent);
finish();
        }
    });

    list.setAdapter(adapter);
    list.setSelection(currentNodeId);
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:25,代码来源:RouteActivity.java

示例7: getView

import org.osmdroid.bonuspack.routing.Road; //导入依赖的package包/类
@Override public View getView(int position, View convertView, ViewGroup viewGroup) {
      RoadNode entry = (RoadNode)getItem(position);
      if (convertView == null) {
          LayoutInflater inflater = (LayoutInflater) mContext
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = inflater.inflate(R.layout.item_layout, null);
      }
      TextView tvTitle = (TextView)convertView.findViewById(R.id.title);
      String instructions = (entry.mInstructions==null ? "" : entry.mInstructions);
      tvTitle.setText("" + (position+1) + ". " + instructions);
      TextView tvDetails = (TextView)convertView.findViewById(R.id.details);
      tvDetails.setText(Road.getLengthDurationText(mContext, entry.mLength, entry.mDuration));
      int iconId = iconIds.getResourceId(entry.mManeuverType, R.drawable.ic_empty);
 		Drawable icon = mContext.getResources().getDrawable(iconId);
ImageView ivManeuver = (ImageView)convertView.findViewById(R.id.thumbnail);
 		ivManeuver.setImageDrawable(icon);
      return convertView;
  }
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:19,代码来源:RouteActivity.java

示例8: doInBackground

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

示例9: initRouteInstructions

import org.osmdroid.bonuspack.routing.Road; //导入依赖的package包/类
private void initRouteInstructions(Road road){
    if(road != null && road.mNodes != null) {
        final ListView lstRouteDesc = (ListView)getView().findViewById(R.id.lstRouteDesc);
        final List<DescriptionRow> descriptions = new ArrayList<DescriptionRow>();
        int waypoint = 0;
        for(int i = 0; i < road.mNodes.size(); i++){
            final RoadNode node = road.mNodes.get(i);
            String instructions = node.mInstructions;
            if(node.mInstructions.toUpperCase().contains(getResources().getString(R.string.destination).toUpperCase())){
                instructions = RouteManager.getInstance().getWaypoints().get(waypoint).getName();
                waypoint++;
            }
            descriptions.add(new DescriptionRow(getIconForManeuver(node.mManeuverType),instructions));
        }
        lstRouteDesc.setAdapter(new RouteDescAdapter(getActivity(),android.R.layout.simple_list_item_1,descriptions));
    }
}
 
开发者ID:oSoc14,项目名称:Artoria,代码行数:18,代码来源:MapFragment.java

示例10: calculateFare

import org.osmdroid.bonuspack.routing.Road; //导入依赖的package包/类
private void calculateFare(Road road) {

		if (road == null)
			return;

		if (road.mStatus == Road.STATUS_DEFAULT) {

			// Show error if route could not be fetched
			Toast.makeText(this, "Error getting the distance",
					Toast.LENGTH_SHORT).show();
			return;

		}

		road_distance = road.mLength;
		vehicle_type = preferences.getString("vehicle_list_preference", "01");
		Fare fare = new Fare(this, road_distance, "01");
		fare.calculate();
		fare.show();

	}
 
开发者ID:nirabpudasaini,项目名称:Mero-Bhada-Meter,代码行数:22,代码来源:MapActivity.java

示例11: putRoadNodes

import org.osmdroid.bonuspack.routing.Road; //导入依赖的package包/类
private void putRoadNodes(Road road) {
	roadNodeMarkers.removeAllItems();
	Drawable marker = getResources().getDrawable(R.drawable.marker_node);
	int n = road.mNodes.size();
	TypedArray iconIds = getResources().obtainTypedArray(
			R.array.direction_icons);
	for (int i = 0; i < n; i++) {
		RoadNode node = road.mNodes.get(i);
		String instructions = (node.mInstructions == null ? ""
				: node.mInstructions);
		ExtendedOverlayItem nodeMarker = new ExtendedOverlayItem("Step "
				+ (i + 1), instructions, node.mLocation, this);
		nodeMarker.setSubDescription(road.getLengthDurationText(
				node.mLength, node.mDuration));
		nodeMarker.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
		nodeMarker.setMarker(marker);
		int iconId = iconIds.getResourceId(node.mManeuverType,
				R.drawable.ic_empty);
		if (iconId != R.drawable.ic_empty) {
			Drawable icon = getResources().getDrawable(iconId);
			nodeMarker.setImage(icon);
		}
		roadNodeMarkers.addItem(nodeMarker);
	}
}
 
开发者ID:nirabpudasaini,项目名称:Mero-Bhada-Meter,代码行数:26,代码来源:MapActivity.java

示例12: updateUIWithRoad

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

示例13: doInBackground

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

示例14: onPostExecute

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

示例15: onPostExecute

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


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