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

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

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

Point.longitude介绍

[英]This returns a double value ranging from -180 to 180 representing the x or easting position of this point. ideally, this value would be restricted to 6 decimal places to correctly follow the GeoJson spec.
[中]这将返回一个介于-180到180之间的双精度值,表示该点的x或东距位置。理想情况下,该值应限制为6位小数,以正确遵循GeoJson规范。

代码示例

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

/**
 * Square distance between 2 points.
 *
 * @param p1 first {@link Point}
 * @param p2 second Point
 * @return square of the distance between two input points
 */
private static double getSqDist(Point p1, Point p2) {
 double dx = p1.longitude() - p2.longitude();
 double dy = p1.latitude() - p2.latitude();
 return dx * dx + dy * dy;
}

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

private static String formatCoordinates(List<Point> coordinates) {
  List<String> coordinatesFormatted = new ArrayList<>();
  for (Point point : coordinates) {
   coordinatesFormatted.add(String.format(Locale.US, "%s,%s",
    TextUtils.formatCoordinate(point.longitude()),
    TextUtils.formatCoordinate(point.latitude())));
  }
  return TextUtils.join(";", coordinatesFormatted.toArray());
 }
}

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

private static String formatCoordinates(List<Point> coordinates) {
  List<String> coordinatesFormatted = new ArrayList<>();
  for (Point point : coordinates) {
   coordinatesFormatted.add(String.format(Locale.US, "%s,%s",
    TextUtils.formatCoordinate(point.longitude()),
    TextUtils.formatCoordinate(point.latitude())));
  }
  return TextUtils.join(";", coordinatesFormatted.toArray());
 }
}

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

private static String formatCoordinates(List<Point> coordinates) {
  List<String> coordinatesFormatted = new ArrayList<>();
  for (Point point : coordinates) {
   coordinatesFormatted.add(String.format(Locale.US, "%s,%s",
    TextUtils.formatCoordinate(point.longitude()),
    TextUtils.formatCoordinate(point.latitude())));
  }
  return TextUtils.join(";", coordinatesFormatted.toArray());
 }
}

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

private static String formatCoordinates(List<Point> coordinates) {
  List<String> coordinatesFormatted = new ArrayList<>();
  for (Point point : coordinates) {
   coordinatesFormatted.add(String.format(Locale.US, "%s,%s",
    TextUtils.formatCoordinate(point.longitude()),
    TextUtils.formatCoordinate(point.latitude())));
  }
  return TextUtils.join(";", coordinatesFormatted.toArray());
 }
}

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

private static String formatCoordinates(List<Point> coordinates) {
 String[] coordinatesFormatted = new String[coordinates.size()];
 int index = 0;
 for (Point point : coordinates) {
  coordinatesFormatted[index++] = String.format(Locale.US, "%s,%s",
   TextUtils.formatCoordinate(point.longitude()),
   TextUtils.formatCoordinate(point.latitude()));
 }
 return TextUtils.join(";", coordinatesFormatted);
}

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

private static String formatCoordinates(List<Point> coordinates) {
 String[] coordinatesFormatted = new String[coordinates.size()];
 int index = 0;
 for (Point point : coordinates) {
  coordinatesFormatted[index++] = String.format(Locale.US, "%s,%s",
   TextUtils.formatCoordinate(point.longitude()),
   TextUtils.formatCoordinate(point.latitude()));
 }
 return TextUtils.join(";", coordinatesFormatted);
}

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

private static String formatCoordinates(List<Point> coordinates) {
 String[] coordinatesFormatted = new String[coordinates.size()];
 int index = 0;
 for (Point point : coordinates) {
  coordinatesFormatted[index++] = String.format(Locale.US, "%s,%s",
   TextUtils.formatCoordinate(point.longitude()),
   TextUtils.formatCoordinate(point.latitude()));
 }
 return TextUtils.join(";", coordinatesFormatted);
}

代码示例来源: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 deserialize_sanity() throws Exception {
 String jsonString = "[100.0, 0.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);
}

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

@Test
public void fromJson() throws IOException {
 final String json = loadJsonFixture(SAMPLE_MULTIPOLYGON);
 MultiPolygon geo = MultiPolygon.fromJson(json);
 assertEquals(geo.type(), "MultiPolygon");
 assertEquals(geo.coordinates().get(0).get(0).get(0).longitude(), 102.0, DELTA);
 assertEquals(geo.coordinates().get(0).get(0).get(0).latitude(), 2.0, DELTA);
 assertFalse(geo.coordinates().get(0).get(0).get(0).hasAltitude());
}

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

@Test
public void longitude_doesReturnCorrectValue() throws Exception {
 Point point = Point.fromLngLat(1.0, 2.0, 5.0);
 assertEquals(1, point.longitude(), 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 fromJsonHoles() throws IOException {
 final String json = loadJsonFixture(SAMPLE_POLYGON_HOLES);
 Polygon geo = Polygon.fromJson(json);
 assertEquals("Polygon", geo.type());
 assertEquals(100.0, geo.coordinates().get(0).get(0).longitude(), DELTA);
 assertEquals(0.0, geo.coordinates().get(0).get(0).latitude(), DELTA);
 assertEquals(2, geo.coordinates().size());
 assertEquals(100.8, geo.coordinates().get(1).get(0).longitude(), DELTA);
 assertEquals(0.8, geo.coordinates().get(1).get(0).latitude(), DELTA);
 assertFalse(geo.coordinates().get(0).get(0).hasAltitude());
}

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

@Test
public void fromJson() throws IOException {
 final String json = loadJsonFixture(SAMPLE_POLYGON);
 Polygon geo = Polygon.fromJson(json);
 assertEquals("Polygon", geo.type());
 assertEquals(100.0, geo.coordinates().get(0).get(0).longitude(), DELTA);
 assertEquals(0.0, geo.coordinates().get(0).get(0).latitude(), DELTA);
 assertFalse(geo.coordinates().get(0).get(0).hasAltitude());
}

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

@Test
public void turfAlong_returnsZeroWhenRouteIsPoint() throws Exception {
 List<Point> coords = new ArrayList<>();
 coords.add(Point.fromLngLat(1.0, 1.0));
 LineString lineString = LineString.fromLngLats(coords);
 Point point = TurfMeasurement.along(lineString, 0, TurfConstants.UNIT_METERS);
 assertEquals(1.0, point.latitude(), DELTA);
 assertEquals(1.0, point.longitude(), DELTA);
}

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

@Test
public void fromJson() throws IOException {
 final String json = loadJsonFixture(SAMPLE_MULTILINESTRING);
 MultiLineString geo = MultiLineString.fromJson(json);
 assertEquals("MultiLineString", geo.type());
 assertEquals(geo.coordinates().get(0).get(0).longitude(), 100.0, DELTA);
 assertEquals(geo.coordinates().get(0).get(0).latitude(), 0.0, DELTA);
 assertFalse(geo.coordinates().get(0).get(0).hasAltitude());
}

代码示例来源: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 testFromJson() {
  String stepIntersectionJsonString = "{\"out\": 0, \"entry\": [true], \"bearings\": [ 125 ], "
  + "\"location\": [ 13.426579, 52.508068 ] }";
  StepIntersection stepIntersection = StepIntersection.fromJson(stepIntersectionJsonString);

  Point location = stepIntersection.location();
  Assert.assertEquals(13.426579, location.longitude(), 0.0001);
  Assert.assertEquals(52.508068, location.latitude(), 0.0001);

  String jsonStr = stepIntersection.toJson();

  compareJson(stepIntersectionJsonString, jsonStr);
 }
}

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

@Test
public void location_doesGetConvertedToGeoJsonPoint() throws Exception {
 DirectionsWaypoint waypoint = DirectionsWaypoint.builder()
  .rawLocation(new double[] {1.0, 2.0})
  .build();
 assertNotNull(waypoint.location());
 assertEquals(1.0, waypoint.location().longitude(), DELTA);
 assertEquals(2.0, waypoint.location().latitude(), DELTA);
}

相关文章