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

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

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

Point.latitude介绍

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

代码示例

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

/**
 * Convenience method for getting the bounding box most westerly point (longitude) as a double
 * coordinate.
 *
 * @return the most westerly coordinate inside this bounding box
 * @since 3.0.0
 */
public final double north() {
 return northeast().latitude();
}

代码示例来源: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: 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) {
 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 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 testDecodePath() {
 List<Point> latLngs = decode(TEST_LINE, Constants.PRECISION_5);
 int expectedLength = 21;
 assertEquals("Wrong length.", expectedLength, latLngs.size());
 Point lastPoint = latLngs.get(expectedLength - 1);
 expectNearNumber(37.76953, lastPoint.latitude(), 1e-6);
 expectNearNumber(-122.41488, lastPoint.longitude(), 1e-6);
}

代码示例来源: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 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_LINESTRING_FIXTURE);
 LineString geo = LineString.fromJson(json);
 assertEquals(geo.type(), "LineString");
 assertEquals(geo.coordinates().get(0).longitude(), 100.0, 0.0);
 assertEquals(geo.coordinates().get(0).latitude(), 0.0, 0.0);
 assertFalse(geo.coordinates().get(0).hasAltitude());
}

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

@Test
public void test_point_feature_fromJson() throws IOException {
 final String json =  "{ \"type\": \"Feature\"," +
  "\"geometry\": { \"type\": \"Point\", \"coordinates\": [ 125.6, 10.1] }," +
  "\"properties\": {\"name\": \"Dinagat Islands\" }}";
 Feature geo = Feature.fromJson(json);
 assertEquals(geo.type(), "Feature");
 assertEquals(geo.geometry().type(), "Point");
 assertEquals(((Point)geo.geometry()).longitude(), 125.6, DELTA);
 assertEquals(((Point)geo.geometry()).latitude(), 10.1, DELTA);
 assertEquals(geo.properties().get("name").getAsString(), "Dinagat Islands");
}

代码示例来源: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);
}

相关文章