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

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

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

Point.getCoordinateSequence介绍

暂无

代码示例

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

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

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

public Object getProperty(Object object, QName name) throws Exception {
    if (KML.coordinates.getLocalPart().equals(name.getLocalPart())) {
      Point p = (Point) object;
      return p.getCoordinateSequence();
    }

    return null;
  }
}

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

/**
 * Used with ELEM_INFO <code>( 1, 1, 1)</code>
 *
 * @param list List to add coordiantes to
 * @param point Point to be encoded
 */
private static void addCoordinates(List list, Point point) {
  addCoordinates(list, point.getCoordinateSequence());
}

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

Map<String, Object> createPoint(Point point) {
  LinkedHashMap obj = new LinkedHashMap();
  obj.put("type", "Point");
  obj.put("coordinates", new CoordinateSequenceEncoder(point.getCoordinateSequence(), scale));
  return obj;
}

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

public Object getProperty(Object object, QName name) {
    // hack for xlink stuff
    Geometry geometry = (Geometry) object;
    if (geometry.isEmpty()) {
      return null;
    }

    if ("pos".equals(name.getLocalPart())) {
      Point point = (Point) object;
      return point.getCoordinateSequence();
    }

    return null;
  }
}

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

private void writePoint(Point pt, OutStream os) throws IOException {
  if (pt.getCoordinateSequence().size() == 0)
    throw new IllegalArgumentException("Empty Points cannot be represented in WKB");
  writeByteOrder(os);
  writeGeometryType(DB2WKBConstants.wkbPoint2D, os);
  writeCoordinateSequence(pt.getCoordinateSequence(), false, os);
}

代码示例来源: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

private static final Geometry cloneGeometry(Point geom, int dimension) {
  return geomFac.createPoint(
      new LiteCoordinateSequence(geom.getCoordinateSequence(), dimension));
}

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

@Override
  public void encode(Point geometry, AttributesImpl atts, GMLWriter handler) throws Exception {
    handler.startElement(point, atts);
    handler.coordinates(geometry.getCoordinateSequence());
    handler.endElement(point);
  }
}

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

@Override
public void reset(double x, double y) {
 assert ! isEmpty();
 CoordinateSequence cSeq = pointGeom.getCoordinateSequence();
 cSeq.setOrdinate(0, CoordinateSequence.X, x);
 cSeq.setOrdinate(0, CoordinateSequence.Y, y);
}

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

List toList(GeometryCollection mgeom) {
  ArrayList list = new ArrayList(mgeom.getNumGeometries());
  for (int i = 0; i < mgeom.getNumGeometries(); i++) {
    Geometry g = mgeom.getGeometryN(i);
    if (g instanceof Polygon) {
      list.add(toList((Polygon) g));
    } else if (g instanceof LineString) {
      list.add(
          new CoordinateSequenceEncoder(
              ((LineString) g).getCoordinateSequence(), scale));
    } else if (g instanceof Point) {
      list.add(new CoordinateSequenceEncoder(((Point) g).getCoordinateSequence(), scale));
    }
  }
  return list;
}

代码示例来源: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

@Override
  public void encode(Point geometry, AttributesImpl atts, GMLWriter handler, String gmlId)
      throws Exception {
    atts = cloneWithGmlId(atts, gmlId);
    handler.startElement(point, atts);
    handler.startElement(pos, null);
    handler.position(geometry.getCoordinateSequence());
    handler.endElement(pos);
    handler.endElement(point);
  }
}

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

public void testEncode2D() throws Exception {
  Point point = GML3MockData.pointLite2D();
  CoordinateSequence seq = point.getCoordinateSequence();
  Document doc = encode(seq, GML.pos);
  checkPosOrdinates(doc, 2);
}

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

public void testEncode3D() throws Exception {
  Point point = GML3MockData.pointLite3D();
  CoordinateSequence seq = point.getCoordinateSequence();
  Document doc = encode(seq, GML.pos);
  checkPosOrdinates(doc, 3);
}

代码示例来源: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

/** Tests encoding for X, Y, M ordinates number */
@Test
public void testEncodeXYM() throws Exception {
  GeometryFactory gf = new GeometryFactory();
  Point pointM = gf.createPoint(new CoordinateXYM(1, 1, 4));
  CoordinateSequence seq = pointM.getCoordinateSequence();
  Document doc = encode(seq, GML.pos);
  checkPosOrdinates(doc, 4);
}

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

/** Tests encoding for X, Y, Z, M ordinates number */
  @Test
  public void testEncodeZM() throws Exception {
    GeometryFactory gf = new GeometryFactory();
    Point pointM = gf.createPoint(new CoordinateXYZM(1, 1, 2, 4));
    CoordinateSequence seq = pointM.getCoordinateSequence();
    Document doc = encode(seq, GML.pos);
    checkPosOrdinates(doc, 4);
  }
}

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

@Test
public void multiPointZ() throws Exception {
  double[] ords = {1, 2, 3, 4, 5, 6};
  MultiPoint mp = builder.multiPointZ(ords[0], ords[1], ords[2], ords[3], ords[4], ords[5]);
  assertEquals(2, mp.getNumGeometries());
  Point p = (Point) mp.getGeometryN(0);
  assertEquals(3, p.getCoordinateSequence().getDimension());
}

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

@Test
public void multiPoint() throws Exception {
  double[] ords = {1, 2, 3, 4};
  MultiPoint mp = builder.multiPoint(ords[0], ords[1], ords[2], ords[3]);
  assertEquals(2, mp.getNumGeometries());
  Point p = (Point) mp.getGeometryN(0);
  assertEquals(2, p.getCoordinateSequence().getDimension());
}

相关文章