• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Position类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mapbox.services.commons.models.Position的典型用法代码示例。如果您正苦于以下问题:Java Position类的具体用法?Java Position怎么用?Java Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Position类属于com.mapbox.services.commons.models包,在下文中一共展示了Position类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLocationMap

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
public static String getLocationMap(Position position, boolean isSmall) {
    StaticMarkerAnnotation marker = new StaticMarkerAnnotation.Builder()
            .setName(com.mapbox.services.Constants.PIN_LARGE)
            .setPosition(position)
            .setColor(COLOR_RED)
            .build();
    MapboxStaticImage client = new MapboxStaticImage.Builder()
            .setAccessToken(Constants.MAPBOX_ACCESS_TOKEN)
            .setWidth(isSmall ? smallWidth : largeWidth)
            .setHeight(isSmall ? smallHeight : largeHeight)
            .setStyleId(com.mapbox.services.Constants.MAPBOX_STYLE_STREETS)
            .setPosition(position)
            .setStaticMarkerAnnotations(marker)
            .setZoom(15)
            .build();
    return client.getUrl().toString();
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:18,代码来源:ImageComponent.java


示例2: getCoordinatesFromAddress

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
public static Position getCoordinatesFromAddress(String address, Position proximity) {
    try {
        log.info(String.format("Looking for '%s'.", address));
        MapboxGeocoding.Builder builder = new MapboxGeocoding.Builder()
                .setAccessToken(Constants.MAPBOX_ACCESS_TOKEN)
                .setMode(GeocodingCriteria.MODE_PLACES)
                .setCountry("US")
                .setLimit(1)
                .setLocation(address);

        if (proximity != null) {
            // Add support for bias
            builder.setProximity(proximity);
        }

        Response<GeocodingResponse> response = builder.build().executeCall();
        double[] coordinates = response.body().getFeatures().get(0).getCenter();
        log.info(String.format("Found at '%f,%f'.", coordinates[0], coordinates[1]));
        return Position.fromCoordinates(coordinates);
    } catch (Exception e) {
        log.error("Geocoding failed.", e);
    }

    return null;
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:26,代码来源:AddressUtils.java


示例3: addNoiseToRoute

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
/**
 * Emulate a noisy route using this method. Note that some points might not be noisy if the random value produced
 * equals 0.
 *
 * @since 2.2.0
 */
private void addNoiseToRoute(double distance) {

  // End point will always match the given route (no noise will be added)
  for (int i = 0; i < positions.size() - 1; i++) {

    double bearing = TurfMeasurement.bearing(positions.get(i), positions.get(i + 1));
    Random random = new Random();
    bearing = random.nextInt(15 - -15) + bearing;

    Position position = TurfMeasurement.destination(
      positions.get(i), distance, bearing, TurfConstants.UNIT_KILOMETERS
    );
    positions.set(i, position);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:22,代码来源:MockLocationEngine.java


示例4: mockLocation

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
/**
 * Here we build the new mock {@link Location} object and fill in as much information we can calculate.
 *
 * @param position taken from the positions list, converts this to a {@link Location}.
 * @return a {@link Location} object with as much information filled in as possible.
 * @since 2.2.0
 */
private Location mockLocation(Position position) {
  lastLocation = new Location(MockLocationEngine.class.getName());
  lastLocation.setLatitude(position.getLatitude());
  lastLocation.setLongitude(position.getLongitude());

  // Need to convert speed to meters/second as specified in Android's Location object documentation.
  float speedInMeterPerSec = (float) (((speed * 1.609344) * 1000) / (60 * 60));
  lastLocation.setSpeed(speedInMeterPerSec);

  if (positions.size() >= 2) {
    double bearing = TurfMeasurement.bearing(position, positions.get(1));
    lastLocation.setBearing((float) bearing);
  }

  lastLocation.setAccuracy(3f);
  lastLocation.setTime(SystemClock.elapsedRealtime());

  return lastLocation;
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:27,代码来源:MockLocationEngine.java


示例5: drawRoute

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private void drawRoute(DirectionsRoute route) {
  // Convert LineString coordinates into LatLng[]
  LineString lineString = LineString.fromPolyline(route.getGeometry(), PRECISION_6);
  List<Position> coordinates = lineString.getCoordinates();
  LatLng[] points = new LatLng[coordinates.size()];
  for (int i = 0; i < coordinates.size(); i++) {
    points[i] = new LatLng(
      coordinates.get(i).getLatitude(),
      coordinates.get(i).getLongitude());
  }

  // Draw Points on MapView
  map.addPolyline(new PolylineOptions()
    .add(points)
    .color(Color.parseColor("#009688"))
    .width(5));
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:18,代码来源:DirectionsActivity.java


示例6: drawSimplify

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private void drawSimplify(List<Position> points) {

    Position[] before = new Position[points.size()];
    for (int i = 0; i < points.size(); i++) {
      before[i] = points.get(i);
    }

    Position[] after = PolylineUtils.simplify(before, 0.001);

    LatLng[] result = new LatLng[after.length];
    for (int i = 0; i < after.length; i++) {
      result[i] = new LatLng(after[i].getLatitude(), after[i].getLongitude());
    }

    map.addPolyline(new PolylineOptions()
      .add(result)
      .color(Color.parseColor("#3bb2d0"))
      .width(4));
  }
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:20,代码来源:SimplifyPolylineActivity.java


示例7: doInBackground

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
@Override
protected List<Position> doInBackground(Void... voids) {

  List<Position> points = new ArrayList<>();

  try {
    // Load GeoJSON file
    InputStream inputStream = getAssets().open("trace.geojson");
    BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
    StringBuilder sb = new StringBuilder();
    int cp;
    while ((cp = rd.read()) != -1) {
      sb.append((char) cp);
    }

    inputStream.close();
    FeatureCollection featureCollection = FeatureCollection.fromJson(sb.toString());
    LineString lineString = (LineString) featureCollection.getFeatures().get(0).getGeometry();
    points = lineString.getCoordinates();
  } catch (Exception exception) {
    Log.e(TAG, "Exception Loading GeoJSON: " + exception.toString());
  }

  return points;
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:26,代码来源:MapMatchingActivity.java


示例8: calculateLinePoints

import com.mapbox.services.commons.models.Position; //导入依赖的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


示例9: getPositionFromKey

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private Position getPositionFromKey(String key) {
    try {
        S3Object object = s3.getObject(new GetObjectRequest(BUCKET_NAME, key));
        BufferedReader reader = new BufferedReader(new InputStreamReader(object.getObjectContent()));
        StringBuilder sb = new StringBuilder();
        while (true) {
            String line = reader.readLine();
            if (line == null) break;
            sb.append(line);
        }
        return new Gson().fromJson(sb.toString(), Position.class);
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:16,代码来源:StorageManager.java


示例10: getRouteMap

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
public static String getRouteMap(Position origin, Position destination, String geometry, boolean isSmall) {
    StaticMarkerAnnotation markerOrigin = new StaticMarkerAnnotation.Builder()
            .setName(com.mapbox.services.Constants.PIN_LARGE)
            .setPosition(origin)
            .setColor(COLOR_GREEN)
            .build();
    StaticMarkerAnnotation markerDestination = new StaticMarkerAnnotation.Builder()
            .setName(com.mapbox.services.Constants.PIN_LARGE)
            .setPosition(destination)
            .setColor(COLOR_RED)
            .build();
    StaticPolylineAnnotation route = new StaticPolylineAnnotation.Builder()
            .setPolyline(geometry)
            .setStrokeColor(COLOR_BLUE)
            .setStrokeOpacity(1)
            .setStrokeWidth(5)
            .build();
    MapboxStaticImage client = new MapboxStaticImage.Builder()
            .setAccessToken(Constants.MAPBOX_ACCESS_TOKEN)
            .setWidth(isSmall ? smallWidth : largeWidth)
            .setHeight(isSmall ? smallHeight : largeHeight)
            .setStyleId(com.mapbox.services.Constants.MAPBOX_STYLE_TRAFFIC_DAY)
            .setAuto(true)
            .setStaticMarkerAnnotations(markerOrigin, markerDestination)
            .setStaticPolylineAnnotations(route)
            .setZoom(15)
            .build();
    return client.getUrl().toString();
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:30,代码来源:ImageComponent.java


示例11: getHomeAddressResponse

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
public SpeechletResponse getHomeAddressResponse(Slot postalAddress, Slot city) {
    String speechText;
    String cardText;
    Image image = null;

    String address = AddressUtils.getAddressFromSlot(postalAddress, city, null);

    try {
        Position position = AddressUtils.getCoordinatesFromAddress(address, null);
        storageManager.setHomeAddress(position);
        speechText = "Thank you, home address set.";
        cardText = String.format(Locale.US, "Thank you, home address set: %s", address);
        image = new Image();
        image.setSmallImageUrl(ImageComponent.getLocationMap(position, true));
        image.setLargeImageUrl(ImageComponent.getLocationMap(position, false));
    } catch (Exception e) {
        speechText = "Sorry, I couldn't find that address.";
        cardText = String.format(Locale.US, "Sorry, I couldn't find that address: %s", address);
    }

    // Create a standard card content
    StandardCard card = new StandardCard();
    card.setTitle(CARD_TITLE);
    card.setText(cardText);

    // Card image
    if (image != null) {
        card.setImage(image);
    }

    // Create the plain text output
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);

    return SpeechletResponse.newTellResponse(speech, card);
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:37,代码来源:IntentManager.java


示例12: getOfficeAddressResponse

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
public SpeechletResponse getOfficeAddressResponse(Slot postalAddress, Slot city) {
    String speechText;
    String cardText;
    Image image = null;

    String address = AddressUtils.getAddressFromSlot(postalAddress, city, null);

    try {
        Position proximity = storageManager.getHomeAddress();
        Position position = AddressUtils.getCoordinatesFromAddress(address, proximity);
        storageManager.setOfficeAddress(position);
        cardText = String.format(Locale.US, "Thank you, office address set: %s", address);
        speechText = "Thank you, office address set.";
        image = new Image();
        image.setSmallImageUrl(ImageComponent.getLocationMap(position, true));
        image.setLargeImageUrl(ImageComponent.getLocationMap(position, false));
    } catch (Exception e) {
        cardText = String.format(Locale.US, "Sorry, I couldn't find that address: %s", address);
        speechText = "Sorry, I couldn't find that address.";
    }

    // Create a standard card content
    StandardCard card = new StandardCard();
    card.setTitle(CARD_TITLE);
    card.setText(cardText);

    // Card image
    if (image != null) {
        card.setImage(image);
    }

    // Create the plain text output
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);

    return SpeechletResponse.newTellResponse(speech, card);
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:38,代码来源:IntentManager.java


示例13: getRouteMapIsNotEmpty

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
@Test
public void getRouteMapIsNotEmpty() {
    // From https://www.mapbox.com/api-playground/#/directions
    String geometry = "}[email protected]?xC}[email protected][email protected]@FItAaAhCaAH?ZqD`[email protected]@[email protected]@[email protected]";

    Position whiteHouse = Position.fromCoordinates(-77.0365, 38.8977);
    Position dupontCircle = Position.fromCoordinates(-77.04341, 38.90962);
    assertTrue(ImageComponent.getRouteMap(whiteHouse, dupontCircle, geometry, true).startsWith(BASE_URL));
    assertTrue(ImageComponent.getRouteMap(whiteHouse, dupontCircle, geometry, false).startsWith(BASE_URL));
}
 
开发者ID:mapbox,项目名称:mapbox-assistant-example,代码行数:11,代码来源:ImageComponentTest.java


示例14: onConnected

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
@SuppressWarnings({"MissingPermission"})
@Override
public void onConnected() {
  locationEngine.requestLocationUpdates();

  if (locationEngine.getLastLocation() != null) {
    Location lastLocation = locationEngine.getLastLocation();
    currentUserPosition = Position.fromLngLat(lastLocation.getLongitude(), lastLocation.getLatitude());
    checkIntentExtras();
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-hud-demo,代码行数:12,代码来源:DisplayActivity.java


示例15: checkIntentExtras

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private void checkIntentExtras() {
  if (getIntent().hasExtra(PLACE_LOCATION_EXTRA)) {
    Location placeLocation = getIntent().getParcelableExtra(PLACE_LOCATION_EXTRA);
    Position destination = Position.fromLngLat(placeLocation.getLongitude(), placeLocation.getLatitude());

    if (currentUserPosition != null) {
      navigation.getRoute(currentUserPosition, destination, this);
    } else {
      Toast.makeText(this, "Current Location is null", Toast.LENGTH_LONG).show();
    }
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-hud-demo,代码行数:13,代码来源:DisplayActivity.java


示例16: sliceRoute

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
/**
 * Interpolates the route into even positions along the route and adds these to the positions list.
 *
 * @param lineString our route geometry.
 * @param distance   the distance you want to interpolate the line by, by default we calculate the distance using the
 *                   speed variable.
 * @since 2.2.0
 */
private void sliceRoute(LineString lineString, double distance) {
  double distanceKm = TurfMeasurement.lineDistance(lineString, TurfConstants.UNIT_KILOMETERS);
  if (distanceKm <= 0) {
    return;
  }

  // Chop the line in small pieces
  for (double i = 0; i < distanceKm; i += distance) {
    Position position = TurfMeasurement.along(lineString, i, TurfConstants.UNIT_KILOMETERS).getCoordinates();
    positions.add(position);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:21,代码来源:MockLocationEngine.java


示例17: updateMap

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private void updateMap(double latitude, double longitude, boolean isOrigin) {
    if (routePolyLine != null) {
        map.removePolyline(routePolyLine);
    }
    if (!isOrigin) {
        if (markerDestination != null) {
            map.removeMarker(markerDestination);
        }
        markerDestination = map.addMarker(new MarkerOptions()
                .position(new LatLng(latitude, longitude)).title(getString(R.string.destination)));
        destination = Position.fromCoordinates(longitude, latitude);
        map.updateMarker(markerDestination);
    } else {
        if (markerOrigin != null) {
            map.removeMarker(markerOrigin);
        }
        markerOrigin = map.addMarker(new MarkerOptions()
                .position(new LatLng(latitude, longitude)).title(getString(R.string.origin)));
        origin = Position.fromCoordinates(longitude, latitude);
        map.updateMarker(markerOrigin);
    }

    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(new LatLng(latitude, longitude))
            .zoom(15)
            .build();
    map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, null);
}
 
开发者ID:opticod,项目名称:Moto-Navigator,代码行数:29,代码来源:MapFragment.java


示例18: drawRoute

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private void drawRoute(DirectionsRoute route, String profile) {
    // Convert LineString coordinates into LatLng[]
    LineString lineString = LineString.fromPolyline(route.getGeometry(), Constants.OSRM_PRECISION_V5);
    List<Position> coordinates = lineString.getCoordinates();
    LatLng[] points = new LatLng[coordinates.size()];
    for (int i = 0; i < coordinates.size(); i++) {
        points[i] = new LatLng(
                coordinates.get(i).getLatitude(),
                coordinates.get(i).getLongitude());
    }

    // Draw Points on MapView
    int color;
    if (profile.equals(DirectionsCriteria.PROFILE_CYCLING)) {
        color = ContextCompat.getColor(mActivity, R.color.polyBike);
    } else if (profile.equals(DirectionsCriteria.PROFILE_DRIVING)) {
        color = ContextCompat.getColor(mActivity, R.color.polyCar);
    } else {
        color = ContextCompat.getColor(mActivity, R.color.polyWalk);
    }

    if (routePolyLine != null) {
        map.removePolyline(routePolyLine);
    }

    routePolyLine = map.addPolyline(new PolylineOptions()
            .add(points)
            .color(color)
            .width(5));
}
 
开发者ID:opticod,项目名称:Moto-Navigator,代码行数:31,代码来源:MapFragment.java


示例19: onPostExecute

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
@Override
protected void onPostExecute(List<Position> points) {
  super.onPostExecute(points);

  drawBeforeSimplify(points);
  drawSimplify(points);

}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:9,代码来源:SimplifyPolylineActivity.java


示例20: drawBeforeSimplify

import com.mapbox.services.commons.models.Position; //导入依赖的package包/类
private void drawBeforeSimplify(List<Position> points) {

    LatLng[] pointsArray = new LatLng[points.size()];
    for (int i = 0; i < points.size(); i++) {
      pointsArray[i] = new LatLng(points.get(i).getLatitude(), points.get(i).getLongitude());
    }

    map.addPolyline(new PolylineOptions()
      .add(pointsArray)
      .color(Color.parseColor("#8a8acb"))
      .width(4));
  }
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:13,代码来源:SimplifyPolylineActivity.java



注:本文中的com.mapbox.services.commons.models.Position类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SelectionToolEntry类代码示例发布时间:2022-05-22
下一篇:
Java ResponseSpecBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap