Search in sources :

Example 6 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class MapBusIconsBuilder method setIconsAndViews.

public void setIconsAndViews(LayoutInflater inflater, HashMap<String, Bitmap> imagesMap, HashMap<String, View> viewMap) {
    for (Feature feature : featureCollection.getFeatures()) {
        String id = feature.getStringProperty(Marker.PROPERTY_ID);
        BusMarker marker = (BusMarker) feature;
        ServerSentBus bus = marker.getBus();
        setBusIcons(id, bus, inflater, imagesMap, viewMap, false);
    }
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature) ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)

Example 7 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopClickHandler method handleMarkerClick.

public Feature handleMarkerClick(Feature feature, FeatureCollection busStopFeatures) {
    Feature newSelectedFeature = null;
    String id = feature.getStringProperty(PROPERTY_ID);
    List<Feature> featureList = busStopFeatures.getFeatures();
    for (int i = 0; i < featureList.size(); i++) {
        if (featureList.get(i).getStringProperty(PROPERTY_ID).equals(id)) {
            Feature selectedFeature = featureList.get(i);
            if (selectedFeature.getBooleanProperty(PROPERTY_SELECTED)) {
                selectedFeature.addBooleanProperty(BusStopMarker.PROPERTY_MAXIMIZED, !selectedFeature.getBooleanProperty(PROPERTY_MAXIMIZED));
            } else {
                selectedFeature.getProperties().addProperty(PROPERTY_SELECTED, true);
                selectedFeature.getProperties().addProperty(PROPERTY_MAXIMIZED, true);
                selectedFeature.getProperties().addProperty(PROPERTY_LOADING, true);
                newSelectedFeature = selectedFeature;
            }
        } else {
            Feature nonSelectedFeature = featureList.get(i);
            nonSelectedFeature.getProperties().addProperty(PROPERTY_SELECTED, false);
        }
    }
    return newSelectedFeature;
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature)

Example 8 with Feature

use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.

the class NavigationMapRoute method buildTrafficFeaturesFromRoute.

private void buildTrafficFeaturesFromRoute(DirectionsRoute route, int index, List<Feature> features, LineString lineString) {
    for (RouteLeg leg : route.legs()) {
        if (leg.annotation() != null && leg.annotation().congestion() != null) {
            for (int i = 0; i < leg.annotation().congestion().size(); i++) {
                // See https://github.com/mapbox/mapbox-navigation-android/issues/353
                if (leg.annotation().congestion().size() + 1 <= lineString.getCoordinates().size()) {
                    double[] startCoord = lineString.getCoordinates().get(i).getCoordinates();
                    double[] endCoord = lineString.getCoordinates().get(i + 1).getCoordinates();
                    LineString congestionLineString = LineString.fromCoordinates(new double[][] { startCoord, endCoord });
                    Feature feature = Feature.fromGeometry(congestionLineString);
                    feature.addStringProperty(CONGESTION_KEY, leg.annotation().congestion().get(i));
                    feature.addStringProperty(SOURCE_KEY, String.format(Locale.US, ID_FORMAT, GENERIC_ROUTE_SOURCE_ID, index));
                    feature.addNumberProperty(INDEX_KEY, index);
                    features.add(feature);
                }
            }
        } else {
            Feature feature = Feature.fromGeometry(lineString);
            features.add(feature);
        }
    }
}
Also used : LineString(com.mapbox.services.commons.geojson.LineString) RouteLeg(com.mapbox.api.directions.v5.models.RouteLeg) Feature(com.mapbox.services.commons.geojson.Feature) Point(com.mapbox.services.commons.geojson.Point)

Example 9 with Feature

use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.

the class MapUtils method updateMapSourceFromFeatureCollection.

/**
 * Takes a {@link FeatureCollection} and creates a map GeoJson source using the sourceId also
 * provided.
 *
 * @param mapboxMap  that the current mapView is using
 * @param collection the feature collection to be added to the map style
 * @param sourceId   the source's id for identifying it when adding layers
 * @since 0.8.0
 */
public static void updateMapSourceFromFeatureCollection(@NonNull MapboxMap mapboxMap, @Nullable FeatureCollection collection, @NonNull String sourceId) {
    if (collection == null) {
        collection = FeatureCollection.fromFeatures(new Feature[] {});
    }
    GeoJsonSource source = mapboxMap.getSourceAs(sourceId);
    if (source == null) {
        GeoJsonOptions routeGeoJsonOptions = new GeoJsonOptions().withMaxZoom(16);
        GeoJsonSource routeSource = new GeoJsonSource(sourceId, collection, routeGeoJsonOptions);
        mapboxMap.addSource(routeSource);
    } else {
        source.setGeoJson(collection);
    }
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) GeoJsonOptions(com.mapbox.mapboxsdk.style.sources.GeoJsonOptions) Feature(com.mapbox.services.commons.geojson.Feature)

Example 10 with Feature

use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.

the class BusStopPlugin method moveCenterInAndOpen.

public void moveCenterInAndOpen(String id) {
    if (selectedBusStop != null) {
        if (selectedBusStop.getStringProperty(Marker.PROPERTY_ID).equals(id)) {
            MapboxUtil.animateCameraToSelection(selectedBusStop, animatorSet, mapboxMap);
            return;
        } else {
            deselectSelectedBusStop();
        }
    }
    Feature busStopFeature = getFeature(id, busStopFeatures, BusStopMarker.PROPERTY_ID);
    BusStopClickHandler handler = new BusStopClickHandler(getContext().getResources(), periodicRequestHandler, BusStopPlugin.this);
    if (busStopFeature == null) {
        BusStopHelper helper = new BusStopHelper(getContext());
        ArrayList<BusStop> busStops = new ArrayList<>();
        busStops.add(helper.getBusStopById(id));
        updateBusStopSource(busStops);
        busStopFeature = busStopFeatures.getFeatures().get(0);
    }
    busStopFeatureClick(busStopFeature, handler);
}
Also used : BusStopHelper(cl.smartcities.isci.transportinspector.database.BusStopHelper) ArrayList(java.util.ArrayList) BusStopClickHandler(cl.smartcities.isci.transportinspector.map.model.busStop.BusStopClickHandler) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop) 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