com.mapbox.geojson.Point.altitude()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中com.mapbox.geojson.Point.altitude()方法的一些代码示例,展示了Point.altitude()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.altitude()方法的具体详情如下:
包路径:com.mapbox.geojson.Point
类名称:Point
方法名:altitude

Point.altitude介绍

[英]Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the coordinate array. #hasAltitude() can be used to determine if this value was set during initialization of this Point instance. This double value should only be used to represent either the elevation or altitude value at this particular point.
[中]或者,GeoJson中的坐标规范允许将高度值放置在坐标数组中#hasAltitude()可用于确定此值是否在该点实例的初始化过程中设置。此双精度值仅用于表示此特定点的高程或高度值。

代码示例

代码示例来源:origin: com.mapbox.mapboxsdk/mapbox-sdk-geojson

/**
 * Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the
 * coordinate array. If an altitude value was provided while initializing this instance, this will
 * return true.
 *
 * @return true if this instance of point contains an altitude value
 * @since 3.0.0
 */
public boolean hasAltitude() {
 return !Double.isNaN(altitude());
}

代码示例来源:origin: mapbox/mapbox-java

/**
 * Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the
 * coordinate array. If an altitude value was provided while initializing this instance, this will
 * return true.
 *
 * @return true if this instance of point contains an altitude value
 * @since 3.0.0
 */
public boolean hasAltitude() {
 return !Double.isNaN(altitude());
}

代码示例来源:origin: mapbox/mapbox-java

@Override
public List<Double> unshiftPoint(Point shiftedPoint) {
 return Arrays.asList(shiftedPoint.longitude() - 3,
     shiftedPoint.latitude() - 5,
     shiftedPoint.altitude() - 8);
}

代码示例来源:origin: mapbox/mapbox-java

@Test
 public void point_deserializeArrayOfArraysOfArrays() throws Exception {
  String jsonString = "[[[50.0, 50.0, 100.0], [100.0, 100.0, 200.0]]]";
  GsonBuilder gsonBuilder = new GsonBuilder()
   .registerTypeAdapter(Point.class, new PointDeserializer());

  Type type =
   new TypeToken<List<List<Point>>>() {}.getType();
  List<List<Point>> points = gsonBuilder.create().fromJson(jsonString,
   type);

  assertEquals(50, points.get(0).get(0).longitude(), DELTA);
  assertEquals(50, points.get(0).get(0).latitude(), DELTA);
  assertEquals(100, points.get(0).get(0).altitude(), DELTA);

  assertEquals(100, points.get(0).get(1).longitude(), DELTA);
  assertEquals(100, points.get(0).get(1).latitude(), DELTA);
  assertEquals(200, points.get(0).get(1).altitude(), DELTA);
 }
}

代码示例来源:origin: mapbox/mapbox-java

@Test
public void point_deserializeArrayOfArrays() throws Exception {
 String jsonString = "[[50.0, 50.0, 100.0], [100.0, 100.0, 200.0]]";
 GsonBuilder gsonBuilder = new GsonBuilder()
  .registerTypeAdapter(Point.class, new PointDeserializer());
 List<Point> points = gsonBuilder.create().fromJson(jsonString,
  new TypeToken<List<Point>>() {}.getType());
 assertEquals(50, points.get(0).longitude(), DELTA);
 assertEquals(50, points.get(0).latitude(), DELTA);
 assertEquals(100, points.get(0).altitude(), DELTA);
 assertEquals(100, points.get(1).longitude(), DELTA);
 assertEquals(100, points.get(1).latitude(), DELTA);
 assertEquals(200, points.get(1).altitude(), DELTA);
}

代码示例来源:origin: mapbox/mapbox-java

@Test
public void point_deserializeArray() throws Exception {
 String jsonString = "[100.0, 0.0, 200.0]";
 GsonBuilder gsonBuilder = new GsonBuilder()
  .registerTypeAdapter(Point.class, new PointDeserializer());
 Point point = gsonBuilder.create().fromJson(jsonString, Point.class);
 assertEquals(100, point.longitude(), DELTA);
 assertEquals(0, point.latitude(), DELTA);
 assertEquals(200, point.altitude(), DELTA);
}

代码示例来源:origin: mapbox/mapbox-java

@Test
public void altitude_doesReturnCorrectValueFromDoubleArray() throws Exception {
 double[] coords = new double[] {1.0, 2.0, 5.0};
 Point point = Point.fromLngLat(coords);
 assertEquals(5, point.altitude(), DELTA);
}

代码示例来源:origin: mapbox/mapbox-java

@Test
public void point_hasAltitudeValueNoBoundingBoxAltCheck() throws Exception {
 Point point = Point.fromLngLat(100, 0, 200);
 assertEquals(200, point.altitude(), 0);
}

代码示例来源:origin: mapbox/mapbox-java

@Test
public void fromJson() throws IOException {
 final String json = loadJsonFixture(SAMPLE_MULTIPOINT);
 MultiPoint geo = MultiPoint.fromJson(json);
 assertEquals(geo.type(), "MultiPoint");
 assertEquals(geo.coordinates().get(0).longitude(), 100.0, DELTA);
 assertEquals(geo.coordinates().get(0).latitude(), 0.0, DELTA);
 assertEquals(geo.coordinates().get(1).longitude(), 101.0, DELTA);
 assertEquals(geo.coordinates().get(1).latitude(), 1.0, DELTA);
 assertFalse(geo.coordinates().get(0).hasAltitude());
 assertEquals(Double.NaN, geo.coordinates().get(0).altitude(), DELTA);
}

代码示例来源:origin: mapbox/mapbox-java

@Test
public void fromJson() throws IOException {
 final String json = loadJsonFixture(SAMPLE_POINT);
 Point geo = Point.fromJson(json);
 assertEquals(geo.type(), "Point");
 assertEquals(geo.longitude(), 100.0, DELTA);
 assertEquals(geo.latitude(), 0.0, DELTA);
 assertEquals(geo.altitude(), Double.NaN, DELTA);
 assertEquals(geo.coordinates().get(0), 100.0, DELTA);
 assertEquals(geo.coordinates().get(1), 0.0, DELTA);
 assertEquals(geo.coordinates().size(), 2);
 assertFalse(geo.hasAltitude());
}

相关文章