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

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

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

Point.coordinates介绍

暂无

代码示例

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

@Override
public List<Double> unshiftPoint(Point point) {
 return point.coordinates();
}

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

@Override
public List<Double> unshiftPoint(Point point) {
 return point.coordinates();
}

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

/**
 * 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.
 *
 * @return a double value ranging from -90 to 90 representing the y or northing position of this
 *   point
 * @since 3.0.0
 */
public double latitude() {
 return coordinates().get(1);
}

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

/**
 * 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.
 *
 * @return a double value ranging from -180 to 180 representing the x or easting position of this
 *   point
 * @since 3.0.0
 */
public double longitude() {
 return coordinates().get(0);
}

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

/**
 * 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.
 *
 * @return a double value ranging from -180 to 180 representing the x or easting position of this
 *   point
 * @since 3.0.0
 */
public double longitude() {
 return coordinates().get(0);
}

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

/**
 * 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.
 *
 * @return a double value ranging from -90 to 90 representing the y or northing position of this
 *   point
 * @since 3.0.0
 */
public double latitude() {
 return coordinates().get(1);
}

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

/**
 * Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the
 * coordinate array. {@link #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.
 *
 * @return a double value ranging from negative to positive infinity
 * @since 3.0.0
 */
public double altitude() {
 if (coordinates().size() < 3) {
  return Double.NaN;
 }
 return coordinates().get(2);
}

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

/**
 * Optionally, the coordinate spec in GeoJson allows for altitude values to be placed inside the
 * coordinate array. {@link #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.
 *
 * @return a double value ranging from negative to positive infinity
 * @since 3.0.0
 */
public double altitude() {
 if (coordinates().size() < 3) {
  return Double.NaN;
 }
 return coordinates().get(2);
}

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

@Test
public void testLineAlongStopLongerThanLength() throws IOException, TurfException {
 Feature line1 = Feature.fromJson(loadJsonFixture(LINE_SLICE_ALONG_LINE_ONE));
 LineString lineStringLine1 = (LineString) line1.geometry();
 double start = 500;
 double stop = 800000;
 Point start_point = TurfMeasurement.along(lineStringLine1, start, TurfConstants.UNIT_MILES);
 List<Point> lineCoordinates = lineStringLine1.coordinates();
 LineString sliced = TurfMisc.lineSliceAlong(line1, start, stop, TurfConstants.UNIT_MILES);
 assertEquals(sliced.coordinates().get(0).coordinates(),
  start_point.coordinates());
 assertEquals(sliced.coordinates().get(sliced.coordinates().size() - 1).coordinates(),
  lineCoordinates.get(lineCoordinates.size() - 1).coordinates());
}

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

@Test
public void testLineSliceAlongRoute2() throws IOException, TurfException {
 Feature route2 = Feature.fromJson(loadJsonFixture(LINE_SLICE_ALONG_ROUTE_TWO));
 LineString lineStringRoute2 = (LineString)route2.geometry();
 double start = 25;
 double stop = 50;
 Point start_point = TurfMeasurement.along(lineStringRoute2, start, TurfConstants.UNIT_MILES);
 Point end_point = TurfMeasurement.along(lineStringRoute2, stop, TurfConstants.UNIT_MILES);
 LineString sliced = TurfMisc.lineSliceAlong(route2, start, stop, TurfConstants.UNIT_MILES);
 assertEquals(sliced.coordinates().get(0).coordinates(),
  start_point.coordinates());
 assertEquals(sliced.coordinates().get(sliced.coordinates().size() - 1).coordinates(),
  end_point.coordinates());
}

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

@Test
public void testLineSliceAlongLine1() throws IOException, TurfException {
 Feature line1 = Feature.fromJson(loadJsonFixture(LINE_SLICE_ALONG_LINE_ONE));
 LineString lineStringLine1 = (LineString) line1.geometry();
 double start = 500;
 double stop = 750;
 Point start_point = TurfMeasurement.along(lineStringLine1, start, TurfConstants.UNIT_MILES);
 Point end_point = TurfMeasurement.along(lineStringLine1, stop, TurfConstants.UNIT_MILES);
 LineString sliced = TurfMisc.lineSliceAlong(line1, start, stop, TurfConstants.UNIT_MILES);
 assertEquals(sliced.coordinates().get(0).coordinates(),
  start_point.coordinates());
 assertEquals(sliced.coordinates().get(sliced.coordinates().size() - 1).coordinates(),
  end_point.coordinates());
}

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

@Test
 public void testLineSliceAlongOvershootLine1() throws IOException, TurfException {
 Feature line1 = Feature.fromJson(loadJsonFixture(LINE_SLICE_ALONG_LINE_ONE));
 LineString lineStringLine1 = (LineString) line1.geometry();
 double start = 500;
 double stop = 1500;
 Point start_point = TurfMeasurement.along(lineStringLine1, start, TurfConstants.UNIT_MILES);
 Point end_point = TurfMeasurement.along(lineStringLine1, stop, TurfConstants.UNIT_MILES);
 LineString sliced = TurfMisc.lineSliceAlong(line1, start, stop, TurfConstants.UNIT_MILES);
 assertEquals(sliced.coordinates().get(0).coordinates(),
  start_point.coordinates());
 assertEquals(sliced.coordinates().get(sliced.coordinates().size() - 1).coordinates(),
  end_point.coordinates());
}

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

@Test
public void testLineSliceAlongRoute1() throws IOException, TurfException {
 Feature route1 = Feature.fromJson(loadJsonFixture(LINE_SLICE_ALONG_ROUTE_ONE));
 LineString lineStringRoute1 = (LineString)route1.geometry();
 double start = 500;
 double stop = 750;
 Point start_point = TurfMeasurement.along(lineStringRoute1, start, TurfConstants.UNIT_MILES);
 Point end_point = TurfMeasurement.along(lineStringRoute1, stop, TurfConstants.UNIT_MILES);
 LineString sliced = TurfMisc.lineSliceAlong(route1, start, stop, TurfConstants.UNIT_MILES);
 assertEquals(sliced.coordinates().get(0).coordinates(),
  start_point.coordinates());
 assertEquals(sliced.coordinates().get(sliced.coordinates().size() - 1).coordinates(),
  end_point.coordinates());
}

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

@Test
 public void testShortLine() throws IOException, TurfException {

  // Distance between points is about 186 miles
  LineString lineStringLine1 = LineString.fromLngLats(Arrays.asList(
   Point.fromLngLat(113.99414062499999, 22.350075806124867),
   Point.fromLngLat(116.76269531249999, 23.241346102386135)));

  double start = 50;
  double stop =  100;

  Point start_point = TurfMeasurement.along(lineStringLine1, start, TurfConstants.UNIT_MILES);
  Point end_point = TurfMeasurement.along(lineStringLine1, stop, TurfConstants.UNIT_MILES);
  LineString sliced = TurfMisc.lineSliceAlong(lineStringLine1, start, stop, TurfConstants.UNIT_MILES);

  assertEquals(sliced.coordinates().get(0).coordinates(),
   start_point.coordinates());
  assertEquals(sliced.coordinates().get(sliced.coordinates().size() - 1).coordinates(),
   end_point.coordinates());
 }
}

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

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

@Test
public void passingInSingleFeature_doesHandleCorrectly() throws Exception {
 Point geometry = Point.fromLngLat(1.0, 2.0);
 Feature feature = Feature.fromGeometry(geometry);
 FeatureCollection geo = FeatureCollection.fromFeature(feature);
 assertNotNull(geo.features());
 assertEquals(1, geo.features().size());
 assertEquals(2.0, ((Point) geo.features().get(0).geometry()).coordinates().get(1), DELTA);
}

相关文章