/** * @return length and duration of the whole road, or of a leg of the road, * as a String, in a readable format. * @param leg leg index, starting from 0. -1 for the whole road */ public String getLengthDurationText(Context context, int leg) { double length = (leg == -1 ? mLength : mLegs.get(leg).mLength); double duration = (leg == -1 ? mDuration : mLegs.get(leg).mDuration); return getLengthDurationText(context, length, duration); }
protected Road[] defaultRoad(ArrayList<GeoPoint> waypoints) { Road[] roads = new Road[1]; roads[0] = new Road(waypoints); return roads; }
public Road() { init(); }
for (int j=firstNodeIndex; j<n; j++){ GeoPoint roadPoint = mNodes.get(j).mLocation; double dSquared = distanceLLSquared(roadPoint, waypoint); if (nodeIndexMin == -1 || dSquared < distanceMin){ distanceMin = dSquared;
} else if (isOverviewPolyline){ mCurrentRoad.setRouteLow(PolylineEncoder.decode(mStringBuilder.toString(), 10, false));
JSONObject jPath = jPaths.getJSONObject(r); String route_geometry = jPath.getString("points"); Road road = new Road(); roads[r] = road; road.mRouteHigh = PolylineEncoder.decode(route_geometry, 10, mWithElevation); jBBox.getDouble(1), jBBox.getDouble(0)); road.mStatus = Road.STATUS_OK; road.buildLegs(waypoints); Log.d(BonusPackHelper.LOG_TAG, "GraphHopper.getRoads - finished");
@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; }
protected Road[] defaultRoad(ArrayList<GeoPoint> waypoints){ Road[] roads = new Road[1]; roads[0] = new Road(waypoints); return roads; }
/** default constructor when normal loading failed: * the road shape only contains the waypoints; All distances and times are at 0; * there is no node; mStatus set to TECHNICAL_ISSUE. */ public Road(ArrayList<GeoPoint> waypoints){ init(); int n = waypoints.size(); for (int i=0; i<n; i++){ GeoPoint p = waypoints.get(i); mRouteHigh.add(p); } for (int i=0; i<n-1; i++){ RoadLeg leg = new RoadLeg(/*i, i+1, mLinks*/); mLegs.add(leg); } mBoundingBox = BoundingBox.fromGeoPoints(mRouteHigh); mStatus = STATUS_TECHNICAL_ISSUE; }
void selectRoad(int roadIndex){ mSelectedRoad = roadIndex; putRoadNodes(mRoads[roadIndex]); //Set route info in the text view: TextView textView = (TextView)findViewById(R.id.routeInfo); textView.setText(mRoads[roadIndex].getLengthDurationText(this, -1)); for (int i=0; i<mRoadOverlays.length; i++){ Paint p = mRoadOverlays[i].getPaint(); if (i == roadIndex) p.setColor(0x800000FF); //blue else p.setColor(0x90666666); //grey } map.invalidate(); }
@Override public Road createFromParcel(Parcel source) { return new Road(source); } @Override public Road[] newArray(int size) {
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));
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if (localName.equals("route")) { mCurrentRoad = new Road(); mRoads.add(mCurrentRoad); } else if (localName.equals("polyline")) { isPolyline = true; } else if (localName.equals("overview_polyline")) { isOverviewPolyline = true; } else if (localName.equals("leg")) { mLeg = new RoadLeg(); isLeg = true; } else if (localName.equals("step")) { mNode = new RoadNode(); isStep = true; } else if (localName.equals("duration")) { isDuration = true; } else if (localName.equals("distance")) { isDistance = true; } else if (localName.equals("bounds")) { isBB = true; } mStringBuilder.setLength(0); }
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); } nodeMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER); mRoadNodeMarkers.add(nodeMarker); } iconIds.recycle(); }
Road[] roads = new Road[jRoutes.length()]; for (int i=0; i<jRoutes.length(); i++){ Road road = new Road(); roads[i] = road; road.mStatus = Road.STATUS_OK;
nodeMarker.setSubDescription(Road.getLengthDurationText(this, node.mLength, node.mDuration)); Drawable iconContinue = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_continue, null); nodeMarker.setImage(iconContinue);
roads[0] = new Road(waypoints); } else { for (int i=0; i<roads.length; i++){