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

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

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

GeometryFactory.getCoordinateSequenceFactory介绍

暂无

代码示例

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

/**
 * Creates a new instance using a provided GeometryFactory.
 *
 * @param geomFact the factory to use
 */
public GeometryBuilder(GeometryFactory geomFact) {
  this.geomFact = geomFact;
  csFact = geomFact.getCoordinateSequenceFactory();
}

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

public CoordinateSequenceFactory getCoordinateSequenceFactory() {
  return delegate.getCoordinateSequenceFactory();
}

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

@Override
public void newSubPart(final int numPoints) {
  this.subPartNo++;
  this.currPartNumPoints = numPoints;
  this.currPointNo = 0;
  final int dimension = 2;
  this.currCoordSeq =
      JTS.createCS(gf.getCoordinateSequenceFactory(), numPoints, dimension);
}

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

/**
 * Initializes the internal CoordinateSequenceTransformer if not specified explicitly.
 *
 * @param gf the factory to use
 */
private void init(GeometryFactory gf) {
  // don't init if csTransformer already exists
  if (inputCSTransformer != null) return;
  // don't reinit if gf is the same (the usual case)
  if (currGeometryFactory == gf) return;
  currGeometryFactory = gf;
  CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();
  csTransformer = new DefaultCoordinateSequenceTransformer(csf);
}

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

protected final LineString constructLineString(
      final double[] linearCoords, final GeometryFactory geometryFactory)
      throws DataSourceException {
    LineString ls = null;
    CoordinateSequence coords =
        toCoords(linearCoords, geometryFactory.getCoordinateSequenceFactory());
    ls = geometryFactory.createLineString(coords);
    return ls;
  }
}

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

/**
 * Return L as defined by SDO_GTYPE (either 3,4 or 0).
 *
 * <p>L represents support for LRS (Liniar Referencing System?). JTS Geometry objects do not
 * support LRS so this will be 0.
 *
 * <p>Subclasses may override as required.
 *
 * @param geom
 * @return <code>0</code>
 */
public static int L(Geometry geom) {
  CoordinateSequenceFactory f = geom.getFactory().getCoordinateSequenceFactory();
  if (f instanceof CoordinateAccessFactory) {
    return ((CoordinateAccessFactory) f).getDimension();
  } else {
    return 0;
  }
}

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

public Object read(ByteBuffer buffer, ShapeType type, boolean flatGeometry) {
  if (type == ShapeType.NULL) {
    return createNull();
  }
  int dimension = shapeType == ShapeType.POINTZ && !flatGeometry ? 3 : 2;
  CoordinateSequence cs =
      JTS.createCS(geometryFactory.getCoordinateSequenceFactory(), 1, dimension);
  cs.setOrdinate(0, 0, buffer.getDouble());
  cs.setOrdinate(0, 1, buffer.getDouble());
  if (shapeType == ShapeType.POINTM) {
    buffer.getDouble();
  }
  if (dimension > 2) {
    cs.setOrdinate(0, 2, buffer.getDouble());
  }
  return geometryFactory.createPoint(cs);
}

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

public Object read(ByteBuffer buffer, ShapeType type, boolean flatGeometry) {
  if (type == ShapeType.NULL) {
    return createNull();
  }
  // read bounding box (not needed)
  buffer.position(buffer.position() + 4 * 8);
  int numpoints = buffer.getInt();
  int dimensions = shapeType == shapeType.MULTIPOINTZ && !flatGeometry ? 3 : 2;
  CoordinateSequence cs =
      JTS.createCS(geometryFactory.getCoordinateSequenceFactory(), numpoints, dimensions);
  DoubleBuffer dbuffer = buffer.asDoubleBuffer();
  double[] ordinates = new double[numpoints * 2];
  dbuffer.get(ordinates);
  for (int t = 0; t < numpoints; t++) {
    cs.setOrdinate(t, 0, ordinates[t * 2]);
    cs.setOrdinate(t, 1, ordinates[t * 2 + 1]);
  }
  if (dimensions > 2) {
    dbuffer.position(dbuffer.position() + 2);
    dbuffer.get(ordinates, 0, numpoints);
    for (int t = 0; t < numpoints; t++) {
      cs.setOrdinate(t, 2, ordinates[t]); // z
    }
  }
  return geometryFactory.createMultiPoint(cs);
}

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

private CoordinateSequence readCoordinateSequence(int size) throws IOException {
  CoordinateSequence seq =
      JTS.createCS(factory.getCoordinateSequenceFactory(), size, inputDimension);
  int targetDim = seq.getDimension();
  if (targetDim > inputDimension) targetDim = inputDimension;
  for (int i = 0; i < size; i++) {
    readCoordinate();
    for (int j = 0; j < targetDim; j++) {
      seq.setOrdinate(i, j, ordValues[j]);
    }
  }
  return seq;
}

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

/**
 * @param buffer
 * @param numPoints
 */
private CoordinateSequence readCoordinates(
    final ByteBuffer buffer, final int numPoints, final int dimensions) {
  CoordinateSequence cs =
      JTS.createCS(geometryFactory.getCoordinateSequenceFactory(), numPoints, dimensions);
  DoubleBuffer dbuffer = buffer.asDoubleBuffer();
  double[] ordinates = new double[numPoints * 2];
  dbuffer.get(ordinates);
  for (int t = 0; t < numPoints; t++) {
    cs.setOrdinate(t, 0, ordinates[t * 2]);
    cs.setOrdinate(t, 1, ordinates[t * 2 + 1]);
  }
  if (dimensions > 2) {
    // z
    dbuffer.position(dbuffer.position() + 2);
    dbuffer.get(ordinates, 0, numPoints);
    for (int t = 0; t < numPoints; t++) {
      cs.setOrdinate(t, 2, ordinates[t]);
    }
  }
  return cs;
}

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

/**
 * Return D as defined by SDO_GTYPE (either 2,3 or 4).
 *
 * <p>For normal JTS Geometry this will be 2 or 3 depending if geom.getCoordinate.z is
 * Double.NaN.
 *
 * <p>Subclasses may override as required.
 *
 * @param geom
 * @return <code>3</code>
 */
public static int D(Geometry geom) {
  CoordinateSequenceFactory f = geom.getFactory().getCoordinateSequenceFactory();
  if (f instanceof CoordinateAccessFactory) {
    return ((CoordinateAccessFactory) f).getDimension();
  } else if (geom == null || geom.getCoordinate() == null || geom.isEmpty()) {
    return 2;
  } else {
    // return 3;
    return Double.isNaN(geom.getCoordinate().z) ? 2 : 3;
  }
}

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

@Deprecated
  protected Polygon buildPolygon(
      final double[][] parts, final GeometryFactory geometryFactory) {
    Polygon p = null;
    double[] linearCoordArray = parts[0];
    int nHoles = parts.length - 1;
    final CoordinateSequenceFactory coordinateSequenceFactory =
        geometryFactory.getCoordinateSequenceFactory();
    LinearRing shell =
        geometryFactory.createLinearRing(
            toCoords(linearCoordArray, coordinateSequenceFactory));
    LinearRing[] holes = new LinearRing[nHoles];
    if (nHoles > 0) {
      for (int i = 0; i < nHoles; i++) {
        linearCoordArray = parts[i + 1];
        holes[i] =
            geometryFactory.createLinearRing(
                toCoords(linearCoordArray, coordinateSequenceFactory));
      }
    }
    p = geometryFactory.createPolygon(shell, holes);
    return p;
  }
}

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

/**
 * Turns the array of ordinates into a coordinate sequence
 *
 * @param gf
 * @return
 */
public CoordinateSequence toCoordinateSequence(GeometryFactory gf) {
  double[] data = getData();
  CoordinateSequence cs = JTS.createCS(gf.getCoordinateSequenceFactory(), data.length / 2, 2);
  for (int i = 0; i < cs.size(); i++) {
    cs.setOrdinate(i, 0, data[i * 2]);
    cs.setOrdinate(i, 1, data[i * 2 + 1]);
  }
  return cs;
}

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

protected final Polygon buildPolygon(
    final double[] shellCoords,
    final double[][] holes,
    final GeometryFactory geometryFactory) {
  Polygon p = null;
  final CoordinateSequenceFactory sequenceFactory =
      geometryFactory.getCoordinateSequenceFactory();
  final CoordinateSequence coords = toCoords(shellCoords, sequenceFactory);
  final LinearRing shell = geometryFactory.createLinearRing(coords);
  final int nHoles = holes.length;
  LinearRing[] polygonHoles = new LinearRing[nHoles];
  if (nHoles > 0) {
    for (int i = 0; i < nHoles; i++) {
      double hole[] = holes[i];
      polygonHoles[i] =
          geometryFactory.createLinearRing(toCoords(hole, sequenceFactory));
    }
  }
  p = geometryFactory.createPolygon(shell, polygonHoles);
  return p;
}

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

private void readCoordinateSequences() {
  Figure[] figures = binary.getFigures();
  CoordinateSequence[] sequences = new CoordinateSequence[figures.length];
  for (int i = 0; i < figures.length; i++) {
    int figurePointOffset = figures[i].getPointOffset();
    int nextPointOffset =
        figures.length >= i + 2
            ? figures[i + 1].getPointOffset()
            : binary.getCoordinates().length;
    Coordinate[] coordinates =
        Arrays.copyOfRange(binary.getCoordinates(), figurePointOffset, nextPointOffset);
    int attribute = figures[i].getAttribute();
    if ((attribute == 0 || attribute == 2)
        && !coordinates[0].equals(coordinates[coordinates.length - 1])) {
      coordinates = Arrays.copyOf(coordinates, coordinates.length + 1);
      coordinates[coordinates.length - 1] = coordinates[0];
    }
    sequences[i] = gf.getCoordinateSequenceFactory().create(coordinates);
  }
  binary.setSequences(sequences);
}

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

List<Polygon> getFaces(GeometryFactory gf, double extrude) {
    // sort the segments from bottom to top
    Collections.sort(segments);
    // extrude each segment
    List<Polygon> result = new ArrayList<Polygon>();
    for (Segment segment : segments) {
      CoordinateSequence cs = JTS.createCS(gf.getCoordinateSequenceFactory(), 5, 2);
      cs.setOrdinate(0, 0, segment.x0);
      cs.setOrdinate(0, 1, segment.y0);
      cs.setOrdinate(3, 0, segment.x0);
      cs.setOrdinate(3, 1, segment.y0 + extrude);
      cs.setOrdinate(2, 0, segment.x1);
      cs.setOrdinate(2, 1, segment.y1 + extrude);
      cs.setOrdinate(1, 0, segment.x1);
      cs.setOrdinate(1, 1, segment.y1);
      cs.setOrdinate(4, 0, segment.x0);
      cs.setOrdinate(4, 1, segment.y0);
      result.add(gf.createPolygon(gf.createLinearRing(cs), null));
    }
    return result;
  }
}

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

if (GeometryFactory.class.isAssignableFrom(category)) {
  final GeometryFactory factory = (GeometryFactory) provider;
  final CoordinateSequenceFactory sequence = factory.getCoordinateSequenceFactory();
  final PrecisionModel precision = factory.getPrecisionModel();
  if (!isAcceptable(sequence, hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY))

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

/**
 * Add ordinates for polygon - with hole support.
 *
 * <p>Ensure ordinates are added in the correct orientation as External or Internal polygons.
 *
 * @param list List to add coordiantes to
 * @param polygon Polygon to be encoded
 */
private static void addCoordinatesInterpretation1(List list, Polygon polygon) {
  int holes = polygon.getNumInteriorRing();
  if (!polygon.isEmpty()) {
    addCoordinates(
        list,
        counterClockWise(
            polygon.getFactory().getCoordinateSequenceFactory(),
            polygon.getExteriorRing().getCoordinateSequence()));
    for (int i = 0; i < holes; i++) {
      addCoordinates(
          list,
          clockWise(
              polygon.getFactory().getCoordinateSequenceFactory(),
              polygon.getInteriorRingN(i).getCoordinateSequence()));
    }
  }
}

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

/**
 * Does what it says, reverses the order of the Coordinates in the ring.
 *
 * <p>This is different then lr.reverses() in that a copy is produced using a new coordinate
 * sequence.
 *
 * @param lr The ring to reverse.
 * @return A new ring with the reversed Coordinates.
 */
public static final LinearRing reverseRing(LinearRing lr) {
  GeometryFactory gf = lr.getFactory();
  CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();
  CoordinateSequence csOrig = lr.getCoordinateSequence();
  int numPoints = csOrig.size();
  int dimensions = csOrig.getDimension();
  CoordinateSequence csNew = JTS.createCS(csf, numPoints, dimensions, csOrig.getMeasures());
  for (int i = 0; i < numPoints; i++) {
    for (int j = 0; j < dimensions; j++) {
      csNew.setOrdinate(numPoints - 1 - i, j, csOrig.getOrdinate(i, j));
    }
  }
  return gf.createLinearRing(csNew);
}

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

public Object getSimplifiedShape() {
  CoordinateSequenceFactory csf = geometryFactory.getCoordinateSequenceFactory();
  if (type.isPointType()) {
    CoordinateSequence cs = JTS.createCS(csf, 1, 2);

相关文章