Search in sources :

Example 41 with Point

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

the class PolygonEditor method insertVertex.

@Override
public GeometryEditor<?> insertVertex(final int[] vertexId, final Point point) {
    if (vertexId == null || vertexId.length < 1) {
    } else {
        final int ringIndex = vertexId[0];
        final LinearRingEditor editor = getEditor(ringIndex);
        if (editor != null) {
            final int[] childVertexId = Arrays.copyOfRange(vertexId, 1, vertexId.length);
            editor.insertVertex(childVertexId, point);
        }
    }
    return this;
}
Also used : Point(com.revolsys.geometry.model.Point)

Example 42 with Point

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

the class PolygonEditor method appendVertex.

public PolygonalEditor appendVertex(final int ringIndex, final Point point) {
    LinearRingEditor editor = getEditor(ringIndex);
    if (editor == null) {
        if (ringIndex == 0) {
            editor = new LinearRingEditor(this);
            this.editors.add(editor);
        } else {
            return this;
        }
    }
    final int vertexCount = editor.getVertexCount();
    if (vertexCount < 2) {
        editor.appendVertex(point);
    } else if (vertexCount == 2) {
        editor.appendVertex(point);
        final Point firstPoint = editor.getPoint(0);
        editor.appendVertex(firstPoint);
    } else {
        editor.insertVertex(vertexCount - 1, point);
    }
    return this;
}
Also used : Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 43 with Point

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

the class TriangleDouble method newTriangle.

public static Triangle newTriangle(final Point... points) {
    if (points.length != 3) {
        throw new IllegalArgumentException("A traingle must have exeactly 3 points not " + points.length);
    }
    final double[] coordinates = new double[9];
    for (int i = 0; i < 3; i++) {
        final Point point = points[i];
        coordinates[i * 3] = point.getX();
        coordinates[i * 3 + 1] = point.getY();
        coordinates[i * 3 + 2] = point.getZ();
    }
    return new TriangleDouble(coordinates);
}
Also used : Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Example 44 with Point

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

the class AffineTransformationFactory method newFromBaseLines.

/**
 * Creates an AffineTransformation defined by a maping between two baselines.
 * The computed transformation consists of:
 * <ul>
 * <li>a translation
 * from the start point of the source baseline to the start point of the destination baseline,
 * <li>a rotation through the angle between the baselines about the destination start point,
 * <li>and a scaling equal to the ratio of the baseline lengths.
 * </ul>
 * If the source baseline has zero length, an identity transformation is returned.
 *
 * @param src0 the start point of the source baseline
 * @param src1 the end point of the source baseline
 * @param dest0 the start point of the destination baseline
 * @param dest1 the end point of the destination baseline
 * @return the computed transformation
 */
public static AffineTransformation newFromBaseLines(final Point src0, final Point src1, final Point dest0, final Point dest1) {
    final Point rotPt = new PointDoubleXY(src0.getX() + dest1.getX() - dest0.getX(), src0.getY() + dest1.getY() - dest0.getY());
    final double ang = Angle.angleBetweenOriented(src1, src0, rotPt);
    final double srcDist = src1.distancePoint(src0);
    final double destDist = dest1.distancePoint(dest0);
    // return identity if transformation would be degenerate
    if (srcDist == 0.0) {
        return new AffineTransformation();
    }
    final double scale = destDist / srcDist;
    final AffineTransformation trans = AffineTransformation.translationInstance(-src0.getX(), -src0.getY());
    trans.rotate(ang);
    trans.scale(scale, scale);
    trans.translate(dest0.getX(), dest0.getY());
    return trans;
}
Also used : Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 45 with Point

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

the class FastNodingValidator method checkValid.

/**
 * Checks for an intersection and throws
 * a TopologyException if one is found.
 *
 * @throws TopologyException if an intersection is found
 */
public void checkValid() {
    execute();
    if (!this.isValid) {
        final String errorMessage = getErrorMessage();
        final Point interiorIntersection = this.segInt.getInteriorIntersection();
        throw new TopologyException(errorMessage, interiorIntersection);
    }
}
Also used : Point(com.revolsys.geometry.model.Point) TopologyException(com.revolsys.geometry.model.TopologyException)

Aggregations

Point (com.revolsys.geometry.model.Point)669 LineString (com.revolsys.geometry.model.LineString)130 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)103 Geometry (com.revolsys.geometry.model.Geometry)95 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)90 ArrayList (java.util.ArrayList)79 BoundingBox (com.revolsys.geometry.model.BoundingBox)51 Polygon (com.revolsys.geometry.model.Polygon)42 LineSegment (com.revolsys.geometry.model.segment.LineSegment)34 List (java.util.List)28 LinearRing (com.revolsys.geometry.model.LinearRing)26 PointDouble (com.revolsys.geometry.model.impl.PointDouble)22 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)19 Edge (com.revolsys.geometry.graph.Edge)18 Test (org.junit.Test)17 Punctual (com.revolsys.geometry.model.Punctual)16 Segment (com.revolsys.geometry.model.segment.Segment)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)15 Record (com.revolsys.record.Record)15 Lineal (com.revolsys.geometry.model.Lineal)14