Search in sources :

Example 6 with PointList

use of com.revolsys.geometry.model.PointList in project com.revolsys.open by revolsys.

the class JTSFunctions method newS.

private static Geometry newS(final Geometry g) {
    final GeometryFactory gf = FunctionsUtil.getFactoryOrDefault(g);
    final double centreX = WIDTH - S_RADIUS;
    final Point[] top = new Point[] { new PointDoubleXY(WIDTH, HEIGHT), new PointDoubleXY(centreX, HEIGHT) };
    final Point[] bottom = new Point[] { new PointDoubleXY(centreX, 0), new PointDoubleXY(WIDTH - 2 * S_RADIUS, 0) };
    final GeometricShapeFactory gsf = new GeometricShapeFactory(gf);
    gsf.setCentre(new PointDoubleXY(centreX, HEIGHT - S_RADIUS));
    gsf.setSize(2 * S_RADIUS);
    gsf.setNumPoints(10);
    final LineString arcTop = gsf.newArc(0.5 * Math.PI, Math.PI);
    final GeometricShapeFactory gsf2 = new GeometricShapeFactory(gf);
    gsf2.setCentre(new PointDoubleXY(centreX, S_RADIUS));
    gsf2.setSize(2 * S_RADIUS);
    gsf2.setNumPoints(10);
    final LineString arcBottom = gsf2.newArc(1.5 * Math.PI, Math.PI).reverse();
    final PointList coordList = new PointList();
    coordList.add(top, false);
    coordList.add(CoordinatesListUtil.getPointArray(arcTop), false, 1, arcTop.getVertexCount() - 1);
    coordList.add(new PointDoubleXY(centreX, HEIGHT / 2));
    coordList.add(CoordinatesListUtil.getPointArray(arcBottom), false, 1, arcBottom.getVertexCount() - 1);
    coordList.add(bottom, false);
    return gf.lineString(coordList.toPointArray());
}
Also used : PointList(com.revolsys.geometry.model.PointList) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) GeometricShapeFactory(com.revolsys.geometry.util.GeometricShapeFactory) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 7 with PointList

use of com.revolsys.geometry.model.PointList in project com.revolsys.open by revolsys.

the class SegmentDensifier method densify.

public Geometry densify(final double segLength) {
    this.newCoords = new PointList();
    final LineString seq = this.inputLine;
    this.newCoords.add(seq.getPoint(0));
    for (int i = 0; i < seq.getVertexCount() - 1; i++) {
        final Point p0 = seq.getPoint(i);
        final Point p1 = seq.getPoint(i + 1);
        densify(p0, p1, segLength);
    }
    final Point[] newPts = this.newCoords.toPointArray();
    return this.inputLine.getGeometryFactory().lineString(newPts);
}
Also used : PointList(com.revolsys.geometry.model.PointList) LineString(com.revolsys.geometry.model.LineString) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 8 with PointList

use of com.revolsys.geometry.model.PointList in project com.revolsys.open by revolsys.

the class LinearGeometryBuilder method add.

/**
 * Adds a point to the current line.
 *
 * @param pt the Point to add
 */
public void add(final Point pt, final boolean allowRepeatedPoints) {
    if (this.coordList == null) {
        this.coordList = new PointList();
    }
    this.coordList.add(pt, allowRepeatedPoints);
    this.lastPt = pt;
}
Also used : PointList(com.revolsys.geometry.model.PointList)

Example 9 with PointList

use of com.revolsys.geometry.model.PointList in project com.revolsys.open by revolsys.

the class DouglasPeuckerLineSimplifier method simplify.

public Point[] simplify() {
    this.usePt = new boolean[this.pts.getVertexCount()];
    for (int i = 0; i < this.pts.getVertexCount(); i++) {
        this.usePt[i] = true;
    }
    simplifySection(0, this.pts.getVertexCount() - 1);
    final PointList coordList = new PointList();
    for (int i = 0; i < this.pts.getVertexCount(); i++) {
        if (this.usePt[i]) {
            coordList.add(this.pts.getPoint(i));
        }
    }
    return coordList.toPointArray();
}
Also used : PointList(com.revolsys.geometry.model.PointList) Point(com.revolsys.geometry.model.Point)

Example 10 with PointList

use of com.revolsys.geometry.model.PointList in project com.revolsys.open by revolsys.

the class ConvexHull method computeOctPts.

private static PointList computeOctPts(final Collection<Point> points) {
    final Iterator<Point> iterator = points.iterator();
    final Point firstPoint = iterator.next();
    Point octetPoint1 = firstPoint;
    Point octetPoint2 = firstPoint;
    Point octetPoint3 = firstPoint;
    Point octetPoint4 = firstPoint;
    Point octetPoint5 = firstPoint;
    Point octetPoint6 = firstPoint;
    Point octetPoint7 = firstPoint;
    Point octetPoint8 = firstPoint;
    while (iterator.hasNext()) {
        final Point currentPoint = iterator.next();
        final double currentX = currentPoint.getX();
        final double currentY = currentPoint.getY();
        if (currentX < octetPoint1.getX()) {
            octetPoint1 = currentPoint;
        }
        if (currentX - currentY < octetPoint2.getX() - octetPoint2.getY()) {
            octetPoint2 = currentPoint;
        }
        if (currentY > octetPoint3.getY()) {
            octetPoint3 = currentPoint;
        }
        if (currentX + currentY > octetPoint4.getX() + octetPoint4.getY()) {
            octetPoint4 = currentPoint;
        }
        if (currentX > octetPoint5.getX()) {
            octetPoint5 = currentPoint;
        }
        if (currentX - currentY > octetPoint6.getX() - octetPoint6.getY()) {
            octetPoint6 = currentPoint;
        }
        if (currentY < octetPoint7.getY()) {
            octetPoint7 = currentPoint;
        }
        if (currentX + currentY < octetPoint8.getX() + octetPoint8.getY()) {
            octetPoint8 = currentPoint;
        }
    }
    final PointList pointList = new PointList();
    pointList.add(octetPoint1, false);
    pointList.add(octetPoint2, false);
    pointList.add(octetPoint3, false);
    pointList.add(octetPoint4, false);
    pointList.add(octetPoint5, false);
    pointList.add(octetPoint6, false);
    pointList.add(octetPoint7, false);
    pointList.add(octetPoint8, false);
    return pointList;
}
Also used : PointList(com.revolsys.geometry.model.PointList) Point(com.revolsys.geometry.model.Point)

Aggregations

PointList (com.revolsys.geometry.model.PointList)11 Point (com.revolsys.geometry.model.Point)6 LineString (com.revolsys.geometry.model.LineString)3 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)2 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)2 HalfEdge (com.revolsys.geometry.edgegraph.HalfEdge)1 MarkHalfEdge (com.revolsys.geometry.edgegraph.MarkHalfEdge)1 DirectedEdge (com.revolsys.geometry.planargraph.DirectedEdge)1