org.locationtech.jts.geom.Point类的使用及代码示例

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

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

Point介绍

[英]Represents a single point. A Point is topologically valid if and only if:

  • the coordinate which defines it (if any) is a valid coordinate (i.e. does not have an NaN X or Y ordinate)
    [中]表示一个点。当且仅当满足以下条件时,Point在拓扑上有效:
    *定义它的坐标(如果有)是有效坐标(即没有NaNX或Y坐标)

代码示例

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

public Object getProperty(Object object, QName name) throws Exception {
    Point point = (Point) object;

    if (GML.coord.equals(name)) {
      return point.getCoordinate();
    }

    return null;
  }
}

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

public static GHPoint create(Point point) {
  return new GHPoint(point.getY(), point.getX());
}

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

public CoordinateSequence getCoordinateSequence() {
  return point.getCoordinateSequence();
}

代码示例来源:origin: prestodb/presto

private static void writePoint(Point point, SliceOutput output)
{
  output.writeByte(GeometrySerializationType.POINT.code());
  if (!point.isEmpty()) {
    writeCoordinate(point.getCoordinate(), output);
  }
  else {
    output.writeDouble(NaN);
    output.writeDouble(NaN);
  }
}

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

/**
 * @param point
 * @throws TransformException
 */
public Point transformPoint(Point point, GeometryFactory gf) throws TransformException {
  // if required, init csTransformer using geometry's CSFactory
  init(gf);
  CoordinateSequence cs = projectCoordinateSequence(point.getCoordinateSequence());
  Point transformed = gf.createPoint(cs);
  transformed.setUserData(point.getUserData());
  return transformed;
}

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

public static double getX(Geometry arg0) {
  if (!(arg0 instanceof Point)) return 0d;
  Point _this = (Point) arg0;
  return _this.getX();
}

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

if (point.getY() >= 0) {
  fb.add("N");
} else {
  if (wgs84Point.getCoordinate().getOrdinate(fc.northDimension) >= 0) {
    fb.add("N");
  } else {

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

public void write(ByteBuffer buffer, Object geometry) {
    Point point = (Point) geometry;
    Coordinate c = point.getCoordinate();

    buffer.putDouble(c.x);
    buffer.putDouble(c.y);

    if (shapeType == ShapeType.POINTZ) {
      if (Double.isNaN(c.z)) { // nan means not defined
        buffer.putDouble(0.0);
      } else {
        buffer.putDouble(c.z);
      }
    }

    if ((shapeType == ShapeType.POINTZ) || (shapeType == ShapeType.POINTM)) {
      double m = point.getCoordinateSequence().getM(0);
      buffer.putDouble(!Double.isNaN(m) ? m : 0.0); // M
    }
  }
}

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

public static double getY(Geometry arg0) {
  if (!(arg0 instanceof Point)) return 0d;
  Point _this = (Point) arg0;
  return _this.getY();
}

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

public void testPos() throws Exception {
  GML3MockData.point(document, document);
  Point p = (Point) parse();
  assertNotNull(p);
  assertEquals(new Coordinate(1d, 2d), p.getCoordinate());
  assertTrue(p.getUserData() instanceof CoordinateReferenceSystem);
}

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

public boolean equalsExact(Geometry other, double tolerance) {
 if (!isEquivalentClass(other)) {
  return false;
 }
 if (isEmpty() && other.isEmpty()) {
  return true;
 }
 if (isEmpty() != other.isEmpty()) {
  return false;
 }
 return equal(((Point) other).getCoordinate(), this.getCoordinate(), tolerance);
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Return a testsuite-suite point (filter, ...)
 *
 * @return a testsuite-suite point
 */
public Point getTestPoint() {
  WKTReader reader = new WKTReader();
  try {
    Point point = (Point) reader.read( TEST_POINT_WKT );
    point.setSRID( getTestSrid() );
    return point;
  }
  catch (ParseException e) {
    throw new RuntimeException( e );
  }
}

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

@Test
public void testDecimate3DPoint() throws Exception {
  Point p = gf.createPoint(csf.create(new double[] {0, 1, 2}, 3));
  Decimator d = new Decimator(identity, new Rectangle(0, 0, 5, 5), 0.8);
  d.decimateTransformGeneralize(p, identity);
  assertEquals(1, p.getNumPoints());
  assertEquals(2, p.getCoordinateSequence().getDimension());
}

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

/**
   * Generates the point.
   *
   * @param geometryFactory Geometry factory to be used to create the point.
   * @return Created Point.
   */
  public Geometry create(GeometryFactory geometryFactory) {
    Point point = geometryFactory.createPoint(coordinate);
    point.setUserData(getSRS());
    point.setSRID(getSRID());
    return point;
  }
}

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

/** A simple constructor without normalization / validation. */
public JtsPoint(org.locationtech.jts.geom.Point pointGeom, JtsSpatialContext ctx) {
 super(ctx);
 this.pointGeom = pointGeom;
 this.empty = pointGeom.isEmpty();
}

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

public Object parse(Handler arg, GeometryFactory gf) throws SAXException {
    // one child, either a coord
    // or a coordinate sequence
    
    if(arg.children.size()!=1)
      throw new SAXException("Cannot create a point without exactly one coordinate");
    int srid = getSrid(arg.attrs,gf.getSRID());
    Object c = arg.children.get(0);
    Point p = null;
    if(c instanceof Coordinate){
      p = gf.createPoint((Coordinate)c);
    }else{
      p = gf.createPoint((CoordinateSequence)c);
    }
    if(p.getSRID()!=srid)
      p.setSRID(srid);
    
    return p;
  }
});

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

public void apply(CoordinateSequenceFilter filter) 
{
   if (isEmpty())
   return;
   filter.filter(coordinates, 0);
  if (filter.isGeometryChanged())
   geometryChanged();
  }

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

public Coordinate[] getCoordinates() {
 return isEmpty() ? new Coordinate[]{} : new Coordinate[]{
   getCoordinate()
   };
}

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

public double getX() {
  return point.getX();
}

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

public double getY() {
  return point.getY();
}

相关文章