本文整理汇总了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);
}
示例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();
}
示例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;
}
示例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));
}
}
示例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;
}
示例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);
}
}
}
示例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)
});
}
示例8: setLocationPoint
import com.mapbox.services.commons.geojson.Point; //导入依赖的package包/类
void setLocationPoint(Point locationPoint) {
sourceMap.get(LOCATION_SOURCE).setGeoJson(locationPoint);
}
示例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);
}
示例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());
}