當前位置: 首頁>>代碼示例>>Java>>正文


Java Point類代碼示例

本文整理匯總了Java中com.mapbox.services.commons.geojson.Point的典型用法代碼示例。如果您正苦於以下問題:Java Point類的具體用法?Java Point怎麽用?Java Point使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Point類屬於com.mapbox.services.commons.geojson包,在下文中一共展示了Point類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setLocation

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
/**
 * Updates the user location icon.
 *
 * @param location the latest user location
 * @since 0.1.0
 */
private void setLocation(final Location location) {
  lastLocation = location;

  // Convert the new location to a Point object.
  Point newPoint = Point.fromCoordinates(new double[] {location.getLongitude(),
    location.getLatitude()});

  // If the source doesn't have geometry, a Point gets added.
  if (previousPoint == null) {
    locationLayer.setLocationPoint(newPoint);
    previousPoint = newPoint;
    return;
  }

  // Do nothing if the location source's current Point is identical to the new location Point.
  if (previousPoint.getCoordinates().equals(newPoint.getCoordinates())) {
    return;
  }
  locationChangeAnimate(previousPoint, newPoint);
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:27,代碼來源:LocationLayerPlugin.java

示例2: locationChangeAnimate

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
/**
 * Handles the animation from currentSourcePoint to the new user location point.
 */
private void locationChangeAnimate(@NonNull Point currentSourcePoint, @NonNull Point newPoint) {
  if (locationChangeAnimator != null) {
    locationChangeAnimator.end();
  }

  locationChangeAnimator = ValueAnimator.ofObject(new Utils.PointEvaluator(), currentSourcePoint,
    newPoint);
  locationChangeAnimator.setDuration(linearAnimation || (location.getSpeed() > 0)
    ? getLocationUpdateDuration() : LocationLayerConstants.LOCATION_UPDATE_DELAY_MS);
  if (linearAnimation || location.getSpeed() > 0) {
    locationChangeAnimator.setInterpolator(new LinearInterpolator());
  } else {
    locationChangeAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
  }
  locationChangeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      previousPoint = (Point) animation.getAnimatedValue();
      locationLayer.setLocationPoint(previousPoint);
    }
  });
  locationChangeAnimator.start();
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:27,代碼來源:LocationLayerPlugin.java

示例3: getPointFromLineString

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
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;
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:13,代碼來源:NavigationMapRoute.java

示例4: onMapClick

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
@Override
public void onMapClick(@NonNull LatLng point) {
  if (directionsRoutes == null || directionsRoutes.isEmpty() || !alternativesVisible) {
    return;
  }
  // determine which feature collections are alternative routes
  for (FeatureCollection featureCollection : featureCollections) {
    if (!(featureCollection.getFeatures().get(0).getGeometry() instanceof Point)) {
      List<com.mapbox.geojson.Point> linePoints = calculateLinePoints(featureCollection);

      com.mapbox.geojson.Feature feature = TurfMisc.pointOnLine(
        com.mapbox.geojson.Point.fromLngLat(point.getLongitude(), point.getLatitude()),
        linePoints);
      com.mapbox.geojson.Point pointAlong = (com.mapbox.geojson.Point) feature.geometry();
      // No linestring to get point on line, thus we just return.
      if (pointAlong == null) {
        return;
      }
      double dis = TurfMeasurement.distance(com.mapbox.geojson
        .Point.fromLngLat(point.getLongitude(),
        point.getLatitude()), pointAlong, TurfConstants.UNIT_METERS);
      if (dis <= ROUTE_CLICK_PADDING) {
        primaryRouteIndex = featureCollection.getFeatures()
          .get(0).getNumberProperty(INDEX_KEY).intValue();
      }
    }
  }
  updateRoute();
  if (onRouteSelectionChangeListener != null) {
    onRouteSelectionChangeListener.onNewPrimaryRouteSelected(
      directionsRoutes.get(primaryRouteIndex));
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:34,代碼來源:NavigationMapRoute.java

示例5: calculateLinePoints

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private static List<com.mapbox.geojson.Point> calculateLinePoints(
  FeatureCollection featureCollection) {
  List<com.mapbox.geojson.Point> linePoints = new ArrayList<>();
  for (Feature feature : featureCollection.getFeatures()) {
    List<Position> positions = (List<Position>) feature.getGeometry().getCoordinates();
    for (Position pos : positions) {
      linePoints.add(com.mapbox.geojson
        .Point.fromLngLat(pos.getLongitude(), pos.getLatitude()));
    }
  }
  return linePoints;
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:14,代碼來源:NavigationMapRoute.java

示例6: updateRoute

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
private void updateRoute() {
  // Update all route geometries to reflect their appropriate colors depending on if they are
  // alternative or primary.
  for (FeatureCollection featureCollection : featureCollections) {
    if (!(featureCollection.getFeatures().get(0).getGeometry() instanceof Point)) {
      int index = featureCollection.getFeatures().get(0).getNumberProperty(INDEX_KEY).intValue();
      updatePrimaryShieldRoute(String.format(Locale.US, ID_FORMAT, GENERIC_ROUTE_SHIELD_LAYER_ID,
        index), index);
      updatePrimaryRoute(String.format(Locale.US, ID_FORMAT, GENERIC_ROUTE_LAYER_ID, index),
        index);
    }
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:14,代碼來源:NavigationMapRoute.java

示例7: evaluate

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
@Override
public Point evaluate(float fraction, Point startValue, Point endValue) {
  return Point.fromCoordinates(new double[] {
    startValue.getCoordinates().getLongitude() + (
      (endValue.getCoordinates().getLongitude() - startValue.getCoordinates().getLongitude()) * fraction),
    startValue.getCoordinates().getLatitude() + (
      (endValue.getCoordinates().getLatitude() - startValue.getCoordinates().getLatitude()) * fraction)
  });
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:10,代碼來源:Utils.java

示例8: setLocationPoint

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
void setLocationPoint(Point locationPoint) {
  sourceMap.get(LOCATION_SOURCE).setGeoJson(locationPoint);
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:4,代碼來源:LocationLayer.java

示例9: onMapReady

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
@Override
public void onMapReady(MapboxMap mapboxMap) {

  this.mapboxMap = mapboxMap;

  List<Feature> markerCoordinates = new ArrayList<>();
  markerCoordinates.add(Feature.fromGeometry(
    Point.fromCoordinates(Position.fromCoordinates(-71.065634, 42.354950))) // Boston Common Park
  );
  markerCoordinates.add(Feature.fromGeometry(
    Point.fromCoordinates(Position.fromCoordinates(-71.097293, 42.346645))) // Fenway Park
  );
  markerCoordinates.add(Feature.fromGeometry(
    Point.fromCoordinates(Position.fromCoordinates(-71.053694, 42.363725))) // The Paul Revere House
  );
  FeatureCollection featureCollection = FeatureCollection.fromFeatures(markerCoordinates);

  Source geoJsonSource = new GeoJsonSource("marker-source", featureCollection);
  mapboxMap.addSource(geoJsonSource);

  Bitmap icon = BitmapFactory.decodeResource(
    BasicSymbolLayerActivity.this.getResources(), R.drawable.blue_marker_view);

  // Add the marker image to map
  mapboxMap.addImage("my-marker-image", icon);

  SymbolLayer markers = new SymbolLayer("marker-layer", "marker-source")
    .withProperties(PropertyFactory.iconImage("my-marker-image"));
  mapboxMap.addLayer(markers);

  // Add the selected marker source and layer
  FeatureCollection emptySource = FeatureCollection.fromFeatures(new Feature[]{});
  Source selectedMarkerSource = new GeoJsonSource("selected-marker", emptySource);
  mapboxMap.addSource(selectedMarkerSource);

  SymbolLayer selectedMarker = new SymbolLayer("selected-marker-layer", "selected-marker")
    .withProperties(PropertyFactory.iconImage("my-marker-image"));
  mapboxMap.addLayer(selectedMarker);

  mapboxMap.addOnMapClickListener(this);
}
 
開發者ID:mapbox,項目名稱:mapbox-android-demo,代碼行數:42,代碼來源:BasicSymbolLayerActivity.java

示例10: convertToLatLng

import com.mapbox.services.commons.geojson.Point; //導入依賴的package包/類
private LatLng convertToLatLng(Feature feature) {
  Point symbolPoint = (Point) feature.getGeometry();
  Position position = symbolPoint.getCoordinates();
  return new LatLng(position.getLatitude(), position.getLongitude());
}
 
開發者ID:mapbox,項目名稱:mapbox-android-demo,代碼行數:6,代碼來源:SymbolLayerMapillaryActivity.java


注:本文中的com.mapbox.services.commons.geojson.Point類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。