use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.
the class PolylineEngine method addRoutePolyline.
public List<Polyline> addRoutePolyline(MapboxMap mapboxMap, Route route) {
if (busRouteEndFeature == null) {
setupPolylineVars(mapboxMap);
}
List<Location> firstList = route.route.get(0).getPoints();
Feature startPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(firstList.get(0).getLongitude(), firstList.get(0).getLatitude())));
List<Location> lastList = route.route.get(route.route.size() - 1).getPoints();
Feature endPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(lastList.get(lastList.size() - 1).getLongitude(), lastList.get(lastList.size() - 1).getLatitude())));
busRouteStartFeature = FeatureCollection.fromFeatures(new Feature[] { startPoint });
busRouteEndFeature = FeatureCollection.fromFeatures(new Feature[] { endPoint });
refreshSourceWithFeatures(busRouteStartSource, busRouteStartFeature);
refreshSourceWithFeatures(busRouteEndSource, busRouteEndFeature);
List<Polyline> polylineArrayList = new ArrayList<>(route.route.size());
for (InnerPolyline polyline : route.route) {
polylineArrayList.add(mapboxMap.addPolyline(new PolylineOptions().addAll(toLatLng(polyline.getPoints())).color(getColor(polyline)).width(4)));
}
return polylineArrayList;
}
use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.
the class SearchBusStopEngine method updateBusStopSource.
public void updateBusStopSource(List<BusStop> busStops) {
List<Feature> markerCoordinates = new ArrayList<>();
for (BusStop busStop : busStops) {
markerCoordinates.add(new BusStopMarker(busStop));
}
busStopFeatures = FeatureCollection.fromFeatures(markerCoordinates);
refreshSourceWithFeatures(busStopSource, busStopFeatures);
}
use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method buildRouteFeatureFromGeometry.
private void buildRouteFeatureFromGeometry(int index, List<Feature> features, LineString originalGeometry) {
Feature feat = Feature.fromGeometry(originalGeometry);
feat.addStringProperty(SOURCE_KEY, String.format(Locale.US, ID_FORMAT, GENERIC_ROUTE_SOURCE_ID, index));
feat.addNumberProperty(INDEX_KEY, index);
features.add(feat);
}
use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method waypointFeatureCollection.
/**
* The routes also display an icon for each waypoint in the route, we use symbol layers for this.
*/
private static FeatureCollection waypointFeatureCollection(DirectionsRoute route) {
final List<Feature> waypointFeatures = new ArrayList<>();
for (RouteLeg leg : route.legs()) {
waypointFeatures.add(getPointFromLineString(leg, 0));
waypointFeatures.add(getPointFromLineString(leg, leg.steps().size() - 1));
}
return FeatureCollection.fromFeatures(waypointFeatures);
}
use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method getPointFromLineString.
private static Feature getPointFromLineString(RouteLeg leg, int stepIndex) {
Feature feature = Feature.fromGeometry(Point.fromCoordinates(new double[] { leg.steps().get(stepIndex).maneuver().location().longitude(), leg.steps().get(stepIndex).maneuver().location().latitude() }));
feature.addStringProperty(SOURCE_KEY, WAYPOINT_SOURCE_ID);
feature.addStringProperty("waypoint", stepIndex == 0 ? "origin" : "destination");
return feature;
}
Aggregations