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

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

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

Geometry.compareTo介绍

[英]Returns whether this Geometry is greater than, equal to, or less than another Geometry.

If their classes are different, they are compared using the following ordering:

  • Point (lowest)
  • MultiPoint
  • LineString
  • LinearRing
  • MultiLineString
  • Polygon
  • MultiPolygon
  • GeometryCollection (highest)
    If the two Geometrys have the same class, their first elements are compared. If those are the same, the second elements are compared, etc.
    [中]返回此Geometry是否大于、等于或小于另一个Geometry
    如果它们的类别不同,则使用以下顺序对它们进行比较:
    *点(最低)
    *多点
    *线绳
    *线性化
    *多重限制
    *多边形
    *多边形
    *几何收集(最高)
    如果两个Geometry具有相同的类,则比较它们的第一个元素。如果这些元素相同,则比较第二个元素,以此类推。

代码示例

代码示例来源:origin: com.h2database/h2

@Override
protected int compareSecure(Value v, CompareMode mode) {
  Geometry g = ((ValueGeometry) v).getGeometryNoCopy();
  return getGeometryNoCopy().compareTo(g);
}

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

public int compareTo(Object o, CoordinateSequenceComparator comp) {
  return geometry.compareTo(o, comp);
}

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

public int compareTo(Object o) {
  return geometry.compareTo(o);
}

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

public int compare(Object obj0, Object obj1) {
 EdgeRing r0 = (EdgeRing) obj0;
 EdgeRing r1 = (EdgeRing) obj1;
 return r0.getRing().getEnvelope().compareTo(r1.getRing().getEnvelope());
}

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

private void checkWKBGeometry(String wkbHex, String expectedWKT) throws ParseException
 {
  WKBReader wkbReader = new WKBReader(geomFactory);
  byte[] wkb = WKBReader.hexToBytes(wkbHex);
  Geometry g2 = wkbReader.read(wkb);

  WKTReader useRdr = rdr;
  if (expectedWKT.contains("ZM"))
   useRdr = rdrM;
  else if (expectedWKT.contains("M(") || expectedWKT.contains("M ("))
   useRdr = rdrM;

  Geometry expected = useRdr.read(expectedWKT);
  
  boolean isEqual = (expected.compareTo(g2, comp2) == 0);
  if (!isEqual) {System.out.println(g2);System.out.println(expected);}
  assertTrue(isEqual);

 }
}

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

void runGeometry(Geometry g, int dimension, int byteOrder, boolean toHex, int srid)
   throws IOException, ParseException
 {
  boolean includeSRID = false;
  if (srid >= 0) {
   includeSRID = true;
   g.setSRID(srid);
  }
  
  WKBWriter wkbWriter = new WKBWriter(dimension, byteOrder, includeSRID);
  byte[] wkb = wkbWriter.write(g);
  String wkbHex = null;
  if (toHex)
   wkbHex = WKBWriter.toHex(wkb);

  if (toHex)
   wkb = WKBReader.hexToBytes(wkbHex);
  Geometry g2 = wkbReader.read(wkb);

  CoordinateSequenceComparator comp = (dimension == 2) ? comp2 : comp3;
  boolean isEqual = (g.compareTo(g2, comp) == 0);
  assertTrue(isEqual);
  
  if (includeSRID) {
   boolean isSRIDEqual = g.getSRID() == g2.getSRID();
   assertTrue(isSRIDEqual);
  }
 }
}

相关文章