Search in sources :

Example 51 with Geometry

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

the class OverlayValidatedGeometryOperation method invokeValidatedOverlayOp.

/**
 * Invokes an overlay op, optionally using snapping,
 * and optionally validating the result.
 *
 * @param opCode
 * @param g0
 * @param args
 * @return the result
 * @throws Exception
 */
public Result invokeValidatedOverlayOp(final int opCode, final Geometry g0, final Object[] args) throws Exception {
    Geometry result = null;
    final Geometry g1 = (Geometry) args[0];
    result = invokeGeometryOverlayMethod(opCode, g0, g1);
    // validate
    validate(opCode, g0, g1, result);
    areaValidate(g0, g1);
    /**
     * Return an empty GeometryCollection as the result.
     * This allows the test case to avoid specifying an exact result
     */
    if (this.returnEmptyGC) {
        result = result.getGeometryFactory().geometryCollection();
    }
    return new GeometryResult(result);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryResult(com.revolsys.geometry.test.testrunner.GeometryResult)

Example 52 with Geometry

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

the class GeometryFactoryParseErrorTest method readBad.

private void readBad(final String wkt) throws IOException {
    boolean threwParseEx = false;
    try {
        final Geometry g = this.geometryFactory.geometry(wkt);
    } catch (final Throwable ex) {
        // System.out.println(ex.getMessage());
        threwParseEx = true;
    }
    assertTrue(threwParseEx);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry)

Example 53 with Geometry

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

the class WKBTest method runWKBTestCoordinateArray.

private void runWKBTestCoordinateArray(final String wkt) throws IOException, ParseException {
    final GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
    final Geometry g = geometryFactory.geometry(wkt);
    // CoordinateArrays support dimension 3, so test both dimensions
    runWKBTest(g, 2, true);
    runWKBTest(g, 2, false);
    runWKBTest(g, 3, true);
    runWKBTest(g, 3, false);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Example 54 with Geometry

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

the class WKBTest method runGeometry.

void runGeometry(final Geometry g, final int dimension, final int byteOrder, final boolean toHex, final int srid) throws IOException, ParseException {
    boolean includeSRID = false;
    if (srid >= 0) {
        includeSRID = true;
    // g.setSRID(srid);
    }
    final WKBWriter wkbWriter = new WKBWriter(dimension, byteOrder, includeSRID);
    byte[] wkb = wkbWriter.write(g);
    String wkbHex = null;
    if (toHex) {
        wkbHex = WKBWriter.toHex(wkb);
    }
    if (toHex) {
        wkb = WKBReader.hexToBytes(wkbHex);
    }
    final Geometry g2 = this.wkbReader.read(wkb);
    final boolean isEqual = g.equals(2, g2);
    assertTrue(isEqual);
    if (includeSRID) {
        final boolean isSRIDEqual = g.getCoordinateSystemId() == g2.getCoordinateSystemId();
        assertTrue(isSRIDEqual);
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) WKBWriter(com.revolsys.geometry.wkb.WKBWriter)

Example 55 with Geometry

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

the class WKBTest method runWKBTestPackedCoordinate.

private void runWKBTestPackedCoordinate(final String wkt) throws IOException, ParseException {
    final GeometryFactory geometryFactory = GeometryFactory.floating2d(0);
    final Geometry g = geometryFactory.geometry(wkt);
    // Since we are using a PCS of dim=2, only check 2-dimensional storage
    runWKBTest(g, 2, true);
    runWKBTest(g, 2, false);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Aggregations

Geometry (com.revolsys.geometry.model.Geometry)488 Point (com.revolsys.geometry.model.Point)140 LineString (com.revolsys.geometry.model.LineString)87 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)75 ArrayList (java.util.ArrayList)70 BoundingBox (com.revolsys.geometry.model.BoundingBox)39 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)39 Polygon (com.revolsys.geometry.model.Polygon)34 List (java.util.List)33 Record (com.revolsys.record.Record)32 Iterator (java.util.Iterator)20 RecordDefinition (com.revolsys.record.schema.RecordDefinition)18 LinearRing (com.revolsys.geometry.model.LinearRing)16 Vertex (com.revolsys.geometry.model.vertex.Vertex)16 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)14 LineSegment (com.revolsys.geometry.model.segment.LineSegment)13 GeometricShapeFactory (com.revolsys.geometry.util.GeometricShapeFactory)13 FieldDefinition (com.revolsys.record.schema.FieldDefinition)12 DataType (com.revolsys.datatype.DataType)10 IOException (java.io.IOException)10