Search in sources :

Example 46 with GeometryFactory

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

the class BoundingBoxTest method testMultiPoint.

@Test
public void testMultiPoint() {
    for (final GeometryFactory geometryFactory : GEOMETRY_FACTORIES) {
        final Punctual empty = geometryFactory.punctual();
        final BoundingBox boundingBoxEmpty = empty.getBoundingBox();
        assertBoundingBox(empty, boundingBoxEmpty, geometryFactory, true, 2, NULL_BOUNDS);
        final Punctual geometry1 = geometryFactory.punctual(2, 3.0, 4.0, 1.0, 2.0);
        final BoundingBox boundingBox1 = geometry1.getBoundingBox();
        assertBoundingBox(geometry1, boundingBox1, geometryFactory, false, 2, 1.0, 2.0, 3.0, 4.0);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Punctual(com.revolsys.geometry.model.Punctual) BoundingBox(com.revolsys.geometry.model.BoundingBox) Test(org.junit.Test)

Example 47 with GeometryFactory

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

the class BoundingBoxTest method testConstructorCoordinatesArray.

@Test
public void testConstructorCoordinatesArray() {
    final BoundingBox emptyList = BoundingBoxDoubleXY.newBoundingBox(new Point[0]);
    assertBoundingBox(null, emptyList, GeometryFactory.DEFAULT_3D, true, 2, NULL_BOUNDS);
    // Different number of axis and values
    for (int axisCount = 2; axisCount < 6; axisCount++) {
        for (int valueCount = 1; valueCount < 10; valueCount++) {
            Point[] points = new Point[valueCount];
            final double[] bounds = RectangleUtil.newBounds(axisCount);
            for (int i = 0; i < valueCount; i++) {
                final double[] values = new double[axisCount];
                for (int axisIndex = 0; axisIndex < axisCount; axisIndex++) {
                    final double value = Math.random() * 360 - 180;
                    values[axisIndex] = value;
                    final double min = bounds[axisIndex];
                    if (Double.isNaN(min) || value < min) {
                        bounds[axisIndex] = value;
                    }
                    final double max = bounds[axisCount + axisIndex];
                    if (Double.isNaN(max) || value > max) {
                        bounds[axisCount + axisIndex] = value;
                    }
                }
                points[i] = new PointDouble(values);
            }
            final GeometryFactory noGf = GeometryFactory.DEFAULT_3D.convertAxisCount(axisCount);
            final BoundingBox noGeometryFactory = noGf.newBoundingBox(axisCount, points);
            assertBoundingBox(null, noGeometryFactory, noGf, false, axisCount, bounds);
            final GeometryFactory gfFloating = GeometryFactory.floating(4326, axisCount);
            assertBoundingBox(null, gfFloating.newBoundingBox(axisCount, points), gfFloating, false, axisCount, bounds);
            final double[] scales = GeometryFactory.newScalesFixed(axisCount, 10.0);
            final GeometryFactory gfFixed = GeometryFactory.fixed(4326, axisCount, scales);
            points = gfFixed.getPrecise(points);
            final double[] boundsPrecise = gfFixed.copyPrecise(bounds);
            assertBoundingBox(null, gfFixed.newBoundingBox(axisCount, points), gfFixed, false, axisCount, boundsPrecise);
        }
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Example 48 with GeometryFactory

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

the class BoundingBoxTest method testConstructorIterable.

@Test
public void testConstructorIterable() {
    final BoundingBox emptyNull = BoundingBoxDoubleXY.newBoundingBox((Iterable<Point>) null);
    assertBoundingBox(null, emptyNull, GeometryFactory.DEFAULT_3D, true, 2, NULL_BOUNDS);
    final BoundingBox emptyList = BoundingBoxDoubleXY.newBoundingBox(new ArrayList<Point>());
    assertBoundingBox(null, emptyList, GeometryFactory.DEFAULT_3D, true, 2, NULL_BOUNDS);
    final BoundingBox emptyListWithNulls = BoundingBoxDoubleXY.newBoundingBox(Collections.<Point>singleton(null));
    assertBoundingBox(null, emptyListWithNulls, GeometryFactory.DEFAULT_3D, true, 2, NULL_BOUNDS);
    final BoundingBox emptyNullCoordinatesList = BoundingBoxDoubleXY.newBoundingBox((Iterable<Point>) null);
    assertBoundingBox(null, emptyNullCoordinatesList, GeometryFactory.DEFAULT_3D, true, 2, NULL_BOUNDS);
    final BoundingBox emptyCoordinatesList = BoundingBoxDoubleXY.newBoundingBox(new ArrayList<Point>());
    assertBoundingBox(null, emptyCoordinatesList, GeometryFactory.DEFAULT_3D, true, 2, NULL_BOUNDS);
    // Different number of axis and values
    for (int axisCount = 2; axisCount < 6; axisCount++) {
        for (int valueCount = 1; valueCount < 10; valueCount++) {
            final List<Point> points = new ArrayList<>();
            final double[] bounds = RectangleUtil.newBounds(axisCount);
            for (int i = 0; i < valueCount; i++) {
                final double[] values = new double[axisCount];
                for (int axisIndex = 0; axisIndex < axisCount; axisIndex++) {
                    final double value = Math.random() * 360 - 180;
                    values[axisIndex] = value;
                    final double min = bounds[axisIndex];
                    if (Double.isNaN(min) || value < min) {
                        bounds[axisIndex] = value;
                    }
                    final double max = bounds[axisCount + axisIndex];
                    if (Double.isNaN(max) || value > max) {
                        bounds[axisCount + axisIndex] = value;
                    }
                }
                points.add(new PointDouble(values));
            }
            final GeometryFactory noGf = GeometryFactory.DEFAULT_3D.convertAxisCount(axisCount);
            final BoundingBox noGeometryFactory = noGf.newBoundingBox(axisCount, points);
            assertBoundingBox(null, noGeometryFactory, noGf, false, axisCount, bounds);
            final GeometryFactory gfFloating = GeometryFactory.floating(4326, axisCount);
            assertBoundingBox(null, gfFloating.newBoundingBox(axisCount, points), gfFloating, false, axisCount, bounds);
            final double[] scales = GeometryFactory.newScalesFixed(axisCount, 10.0);
            final GeometryFactory gfFixed = GeometryFactory.fixed(4326, axisCount, scales);
            final double[] boundsPrecise = gfFixed.copyPrecise(bounds);
            assertBoundingBox(null, gfFixed.newBoundingBox(axisCount, points), gfFixed, false, axisCount, boundsPrecise);
        }
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Example 49 with GeometryFactory

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

the class BoundingBoxTest method testPoint.

@Test
public void testPoint() {
    for (final GeometryFactory geometryFactory : GEOMETRY_FACTORIES) {
        final Point empty = geometryFactory.point();
        final BoundingBox boundingBoxEmpty = empty.getBoundingBox();
        assertBoundingBox(empty, boundingBoxEmpty, geometryFactory, true, 2, NULL_BOUNDS);
        final Point geometry1 = geometryFactory.point(1, 2);
        final BoundingBox boundingBox10 = geometry1.getBoundingBox();
        assertBoundingBox(geometry1, boundingBox10, geometryFactory, false, 2, 1.0, 2.0, 1.0, 2.0);
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Example 50 with GeometryFactory

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

the class LineStringImplTest method testEquals10.

public void testEquals10() throws Exception {
    final GeometryFactory geometryFactotyr = GeometryFactory.fixed2d(0, 1.0, 1.0);
    Geometry l1 = geometryFactotyr.geometry("POLYGON((1732328800 519578384, 1732026179 519976285, 1731627364 519674014, 1731929984 519276112, 1732328800 519578384))");
    Geometry l2 = geometryFactotyr.geometry("POLYGON((1731627364 519674014, 1731929984 519276112, 1732328800 519578384, 1732026179 519976285, 1731627364 519674014))");
    l1 = l1.normalize();
    l2 = l2.normalize();
    assertTrue(l1.equals(2, l2));
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory)

Aggregations

GeometryFactory (com.revolsys.geometry.model.GeometryFactory)360 Point (com.revolsys.geometry.model.Point)142 Geometry (com.revolsys.geometry.model.Geometry)72 BoundingBox (com.revolsys.geometry.model.BoundingBox)70 LineString (com.revolsys.geometry.model.LineString)61 ArrayList (java.util.ArrayList)45 DataType (com.revolsys.datatype.DataType)25 FieldDefinition (com.revolsys.record.schema.FieldDefinition)24 Polygon (com.revolsys.geometry.model.Polygon)22 List (java.util.List)18 RecordDefinition (com.revolsys.record.schema.RecordDefinition)17 Test (org.junit.Test)16 CoordinateSystem (com.revolsys.geometry.cs.CoordinateSystem)15 Vertex (com.revolsys.geometry.model.vertex.Vertex)14 Record (com.revolsys.record.Record)14 IOException (java.io.IOException)13 PathName (com.revolsys.io.PathName)12 LinearRing (com.revolsys.geometry.model.LinearRing)10 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)10 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)8