org.locationtech.jts.geom.Geometry.distance()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(579)

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

Geometry.distance介绍

[英]Returns the minimum distance between this Geometry and another Geometry.
[中]返回此Geometry与另一个Geometry之间的最小距离。

代码示例

代码示例来源:origin: geotools/geotools

  1. public static double distance(Geometry arg0, Geometry arg1) {
  2. if (arg0 == null || arg1 == null) return -1d;
  3. Geometry _this = arg0;
  4. return _this.distance(arg1);
  5. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. public boolean visit(Geometry value) {
  3. double d = targetValue.distance(value);
  4. if (d < distance) {
  5. distance = d;
  6. nearest = value;
  7. }
  8. return d == 0;
  9. }

代码示例来源:origin: geotools/geotools

  1. public double distance(Geometry g) {
  2. return geometry.distance(g);
  3. }

代码示例来源:origin: geotools/geotools

  1. @DescribeProcess(
  2. title = "Distance",
  3. description =
  4. "Returns the minimum distance between two geometries. Measurement is given in the input units, so geographic coordinates are not recommended."
  5. )
  6. @DescribeResult(description = "Distance between the two input geometries")
  7. public static double distance(
  8. @DescribeParameter(name = "a", description = "First input geometry") Geometry a,
  9. @DescribeParameter(name = "b", description = "Second input geometry") Geometry b) {
  10. return a.distance(b);
  11. }

代码示例来源:origin: locationtech/geowave

  1. @Override
  2. public Double call(Geometry leftGeom, Geometry rightGeom) throws Exception {
  3. return leftGeom.distance(rightGeom);
  4. }
  5. }

代码示例来源:origin: locationtech/geowave

  1. @Override
  2. public boolean apply(Geometry geom1, Geometry geom2) {
  3. return geom1.distance(geom2) <= radius;
  4. }
  5. }

代码示例来源:origin: locationtech/jts

  1. public static double distance(Geometry a, Geometry b) {
  2. return a.distance(b);
  3. }

代码示例来源:origin: geotools/geotools

  1. assertTrue(offset.isValid());
  2. assertTrue(offset.getLength() > 0);
  3. assertEquals(abs(offsetDistance), offset.distance(geom), EPS * abs(offsetDistance));
  4. offset.apply(
  5. new GeometryComponentFilter() {

代码示例来源:origin: locationtech/jts

  1. void testAll(Geometry[] geom)
  2. {
  3. for (int i = 0; i < geom.length; i++ ) {
  4. for (int j = 0; j < geom.length; j++ ) {
  5. double dist = geom[i].distance(geom[j]);
  6. // double dist = SortedBoundsFacetDistance.distance(g1, g2);
  7. // double dist = BranchAndBoundFacetDistance.distance(geom[i], geom[j]);
  8. // double dist = CachedBABDistance.getDistance(geom[i], geom[j]);
  9. }
  10. }
  11. }

代码示例来源:origin: locationtech/jts

  1. void computePairDistance(List geoms, int i, int j)
  2. {
  3. for (int n = 0; n < MAX_ITER; n++ ) {
  4. Geometry g1 = (Geometry) geoms.get(i);
  5. Geometry g2 = (Geometry) geoms.get(j);
  6. double dist = g1.distance(g2);
  7. // double dist = SortedBoundsFacetDistance.distance(g1, g2);
  8. // double dist = BranchAndBoundFacetDistance.distance(g1, g2);
  9. }
  10. }

代码示例来源:origin: org.opengeo/geodb

  1. /**
  2. * Returns the distance between two geometries.
  3. */
  4. public static double ST_Distance( byte[] wkb1, byte[] wkb2 ) {
  5. if ( wkb1 == null || wkb2 == null ) {
  6. return -1;
  7. }
  8. Geometry g1 = gFromWKB(wkb1);
  9. Geometry g2 = gFromWKB(wkb2);
  10. return g1.distance(g2);
  11. }

代码示例来源:origin: jdeolive/geodb

  1. /**
  2. * Returns the distance between two geometries.
  3. */
  4. public static double ST_Distance( byte[] wkb1, byte[] wkb2 ) {
  5. if ( wkb1 == null || wkb2 == null ) {
  6. return -1;
  7. }
  8. Geometry g1 = gFromWKB(wkb1);
  9. Geometry g2 = gFromWKB(wkb2);
  10. return g1.distance(g2);
  11. }

代码示例来源:origin: org.opengeo/geodb

  1. /**
  2. * Returns true if the geometries are within the specified distance of one another
  3. */
  4. public static boolean ST_DWithin( byte[] wkb1, byte[] wkb2, double distance ) {
  5. if ( wkb1 == null || wkb2 == null ) {
  6. return false;
  7. }
  8. Geometry g1 = gFromWKB(wkb1);
  9. Geometry g2 = gFromWKB(wkb2);
  10. return g1.distance(g2) <= distance;
  11. }

代码示例来源:origin: com.orientechnologies/orientdb-lucene

  1. @Override
  2. public double distance(Shape s1, Shape s2) {
  3. Geometry geometry = factory.toGeometry(s1);
  4. Geometry geometry1 = factory.toGeometry(s2);
  5. return geometry.distance(geometry1);
  6. }

代码示例来源:origin: locationtech/jts

  1. public void testDisjointCollinearSegments() throws Exception {
  2. Geometry g1 = reader.read("LINESTRING (0.0 0.0, 9.9 1.4)");
  3. Geometry g2 = reader.read("LINESTRING (11.88 1.68, 21.78 3.08)");
  4. assertEquals(2.23606, g1.distance(g2), 0.0001);
  5. }

代码示例来源:origin: locationtech/jts

  1. public void testDisjointCollinearSegments() throws Exception {
  2. Geometry g1 = reader.read("LINESTRING (0.0 0.0, 9.9 1.4)");
  3. Geometry g2 = reader.read("LINESTRING (11.88 1.68, 21.78 3.08)");
  4. assertEquals(2.23606, g1.distance(g2), 0.0001);
  5. }

代码示例来源:origin: locationtech/jts

  1. public void testEmpty() throws Exception {
  2. Geometry g1 = reader.read("POINT (0 0)");
  3. Geometry g2 = reader.read("POLYGON EMPTY");
  4. assertEquals(0.0, g1.distance(g2), 0.0);
  5. }

代码示例来源:origin: locationtech/jts

  1. public void testEmpty() throws Exception {
  2. Geometry g1 = reader.read("POINT (0 0)");
  3. Geometry g2 = reader.read("POLYGON EMPTY");
  4. assertEquals(0.0, g1.distance(g2), 0.0);
  5. }

代码示例来源:origin: locationtech/jts

  1. public void testEverything() throws Exception {
  2. Geometry g1 = reader.read("POLYGON ((40 320, 200 380, 320 80, 40 40, 40 320), (180 280, 80 280, 100 100, 220 140, 180 280))");
  3. Geometry g2 = reader.read("POLYGON ((160 240, 120 240, 120 160, 160 140, 160 240))");
  4. assertEquals(18.97366596, g1.distance(g2), 1E-5);
  5. g2 = reader.read("POLYGON ((160 240, 120 240, 120 160, 180 100, 160 240))");
  6. assertEquals(0.0, g1.distance(g2), 1E-5);
  7. LineString l1 = (LineString) reader.read("LINESTRING(10 10, 20 20, 30 40)");
  8. LineString l2 = (LineString) reader.read("LINESTRING(10 10, 20 20, 30 40)");
  9. assertEquals(0.0, l1.distance(l2), 1E-5);
  10. }

代码示例来源:origin: locationtech/jts

  1. public void testEverything() throws Exception {
  2. Geometry g1 = reader.read("POLYGON ((40 320, 200 380, 320 80, 40 40, 40 320), (180 280, 80 280, 100 100, 220 140, 180 280))");
  3. Geometry g2 = reader.read("POLYGON ((160 240, 120 240, 120 160, 160 140, 160 240))");
  4. assertEquals(18.97366596, g1.distance(g2), 1E-5);
  5. g2 = reader.read("POLYGON ((160 240, 120 240, 120 160, 180 100, 160 240))");
  6. assertEquals(0.0, g1.distance(g2), 1E-5);
  7. LineString l1 = (LineString) reader.read("LINESTRING(10 10, 20 20, 30 40)");
  8. LineString l2 = (LineString) reader.read("LINESTRING(10 10, 20 20, 30 40)");
  9. assertEquals(0.0, l1.distance(l2), 1E-5);
  10. }

相关文章