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

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

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

Point.type介绍

[英]This describes the TYPE of GeoJson geometry this object is, thus this will always return Point.
[中]这描述了该对象的GeoJson几何体类型,因此它将始终返回点。

代码示例

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

  1. @Test
  2. public void fromJson() throws IOException {
  3. final String json = loadJsonFixture(SAMPLE_POINT);
  4. Point geo = Point.fromJson(json);
  5. assertEquals(geo.type(), "Point");
  6. assertEquals(geo.longitude(), 100.0, DELTA);
  7. assertEquals(geo.latitude(), 0.0, DELTA);
  8. assertEquals(geo.altitude(), Double.NaN, DELTA);
  9. assertEquals(geo.coordinates().get(0), 100.0, DELTA);
  10. assertEquals(geo.coordinates().get(1), 0.0, DELTA);
  11. assertEquals(geo.coordinates().size(), 2);
  12. assertFalse(geo.hasAltitude());
  13. }

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

  1. @Test
  2. public void testLineDistanceWithGeometries() throws IOException, TurfException {
  3. Point pt = (Point) Feature.fromJson(loadJsonFixture(PT)).geometry();
  4. FeatureCollection pts = FeatureCollection.fromJson(loadJsonFixture(PTS));
  5. List<Point> pointList = new ArrayList<>();
  6. for (Feature feature : pts.features()) {
  7. pointList.add((Point) (feature.geometry()));
  8. }
  9. Point closestPt = TurfClassification.nearestPoint(pt, pointList);
  10. Assert.assertNotNull(closestPt);
  11. Assert.assertEquals(closestPt.type(), "Point");
  12. Assert.assertEquals(closestPt.longitude(), -75.33, DELTA);
  13. Assert.assertEquals(closestPt.latitude(), 39.44, DELTA);
  14. }
  15. }

相关文章