Search in sources :

Example 21 with Feature

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;
}
Also used : InnerPolyline(cl.smartcities.isci.transportinspector.router.InnerPolyline) Polyline(com.mapbox.mapboxsdk.annotations.Polyline) InnerPolyline(cl.smartcities.isci.transportinspector.router.InnerPolyline) ArrayList(java.util.ArrayList) Feature(com.mapbox.services.commons.geojson.Feature) Location(android.location.Location) PolylineOptions(com.mapbox.mapboxsdk.annotations.PolylineOptions)

Example 22 with Feature

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);
}
Also used : ArrayList(java.util.ArrayList) BusStopMarker(cl.smartcities.isci.transportinspector.map.model.busStop.BusStopMarker) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop) Feature(com.mapbox.services.commons.geojson.Feature)

Example 23 with Feature

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);
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature)

Example 24 with Feature

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);
}
Also used : ArrayList(java.util.ArrayList) RouteLeg(com.mapbox.api.directions.v5.models.RouteLeg) Feature(com.mapbox.services.commons.geojson.Feature)

Example 25 with Feature

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;
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature)

Aggregations

Feature (com.mapbox.services.commons.geojson.Feature)26 ArrayList (java.util.ArrayList)13 BusStop (cl.smartcities.isci.transportinspector.backend.BusStop)8 BusStopMarker (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopMarker)7 Bitmap (android.graphics.Bitmap)4 NonNull (android.support.annotation.NonNull)4 View (android.view.View)4 BusMarker (cl.smartcities.isci.transportinspector.map.model.bus.BusMarker)4 ServerSentBus (cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)4 BusStopIconsBuilder (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopIconsBuilder)3 IconBuilder (cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder)3 GenerateViewIconTask (cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask)3 PolylineOptions (com.mapbox.mapboxsdk.annotations.PolylineOptions)3 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)3 PointF (android.graphics.PointF)2 FavoriteHelper (cl.smartcities.isci.transportinspector.database.FavoriteHelper)2 BusClickHandler (cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler)2 BusStopClickHandler (cl.smartcities.isci.transportinspector.map.model.busStop.BusStopClickHandler)2 MultiLayerOnMapClickListener (cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener)2 PeriodicRequestHandler (cl.smartcities.isci.transportinspector.periodicRequest.PeriodicRequestHandler)2