Search in sources :

Example 21 with PointDouble

use of com.revolsys.geometry.model.impl.PointDouble in project com.revolsys.open by revolsys.

the class CoordinateTest method testConstructor3D.

public void testConstructor3D() {
    final Point c = new PointDouble(350.2, 4566.8, 5266.3);
    assertEquals(c, 350.2, 4566.8, 5266.3);
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) Point(com.revolsys.geometry.model.Point)

Example 22 with PointDouble

use of com.revolsys.geometry.model.impl.PointDouble in project com.revolsys.open by revolsys.

the class CoordinateTest method testToString.

public void testToString() {
    final String expectedResult = "POINT Z(100 200 50)";
    final String actualResult = new PointDouble(100.0, 200.0, 50.0).toString();
    assertEquals(expectedResult, actualResult);
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble)

Example 23 with PointDouble

use of com.revolsys.geometry.model.impl.PointDouble in project com.revolsys.open by revolsys.

the class LineStringTest method constructLineString.

@Test
public void constructLineString() {
    for (int axisCount = 2; axisCount < 4; axisCount++) {
        int axisCountLess = axisCount;
        if (axisCountLess > 2) {
            axisCountLess--;
        }
        final GeometryFactory geometryFactory = GeometryFactory.fixed(26910, axisCount, GeometryFactory.newScalesFixed(axisCount, 1000.0));
        final GeometryFactory geometryFactoryExtra = GeometryFactory.floating(26910, axisCount + 1);
        final GeometryFactory geometryFactoryLess = GeometryFactory.floating(26910, axisCountLess);
        final double[] coordinatesExtra = new double[axisCount + 1];
        final double[] coordinates = new double[axisCount];
        final double[] coordinatesLess = new double[axisCountLess];
        final double[] coordinatesLessNaN = new double[axisCount];
        for (int i = 0; i < axisCount; i++) {
            double value;
            switch(i) {
                case 0:
                    value = START_X;
                    break;
                case 1:
                    value = START_Y;
                    break;
                default:
                    value = i * 10 + i;
            }
            coordinates[i] = value;
            coordinatesExtra[i] = value;
            coordinatesLessNaN[i] = value;
            if (i < axisCountLess) {
                coordinatesLess[i] = value;
            } else {
                coordinatesLessNaN[i] = Double.NaN;
            }
        }
        coordinatesExtra[coordinatesExtra.length - 1] = 6;
        // double[]
        final Point pointDoubleAllAxis = geometryFactory.point(coordinates);
        final Point pointDoubleExtraAxis = geometryFactory.point(coordinatesExtra);
        final Point pointDoubleLessAxis = geometryFactory.point(coordinatesLess);
        assertEquals(coordinates, coordinatesLessNaN, pointDoubleAllAxis, pointDoubleExtraAxis, pointDoubleLessAxis);
        assertObjectContsructor(geometryFactory, coordinates, coordinatesLessNaN, pointDoubleAllAxis, pointDoubleExtraAxis, pointDoubleLessAxis);
        // Coordinates
        final Point pointCoordinatesAllAxis = geometryFactory.point(new PointDouble(coordinates));
        final Point pointCoordinatesExtraAxis = geometryFactory.point(new PointDouble(coordinatesExtra));
        final Point pointCoordinatesLessAxis = geometryFactory.point(new PointDouble(coordinatesLess));
        assertEquals(coordinates, coordinatesLessNaN, pointCoordinatesAllAxis, pointCoordinatesExtraAxis, pointCoordinatesLessAxis);
        assertObjectContsructor(geometryFactory, coordinates, coordinatesLessNaN, pointCoordinatesAllAxis, pointCoordinatesExtraAxis, pointCoordinatesLessAxis);
        // Object Point
        final Point pointAll = pointDoubleAllAxis;
        final Point pointExtra = geometryFactoryExtra.point(coordinatesExtra);
        final Point pointLess = geometryFactoryLess.point(coordinatesLess);
        assertObjectContsructor(geometryFactory, coordinates, coordinatesLessNaN, pointAll, pointExtra, pointLess);
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Example 24 with PointDouble

use of com.revolsys.geometry.model.impl.PointDouble in project com.revolsys.open by revolsys.

the class PointTest method constructPoint.

@Test
public void constructPoint() {
    for (int axisCount = 2; axisCount < 4; axisCount++) {
        int axisCountLess = axisCount;
        if (axisCountLess > 2) {
            axisCountLess--;
        }
        final GeometryFactory geometryFactory = GeometryFactory.fixed(26910, axisCount, GeometryFactory.newScalesFixed(axisCount, 1000.0));
        final GeometryFactory geometryFactoryExtra = GeometryFactory.floating(26910, axisCount + 1);
        final GeometryFactory geometryFactoryLess = GeometryFactory.floating(26910, axisCountLess);
        final double[] coordinatesExtra = new double[axisCount + 1];
        final double[] coordinates = new double[axisCount];
        final double[] coordinatesLess = new double[axisCountLess];
        final double[] coordinatesLessNaN = new double[axisCount];
        for (int i = 0; i < axisCount; i++) {
            double value;
            switch(i) {
                case 0:
                    value = UTM10_X_START;
                    break;
                case 1:
                    value = UTM10_Y_START;
                    break;
                default:
                    value = i * 10 + i;
            }
            coordinates[i] = value;
            coordinatesExtra[i] = value;
            coordinatesLessNaN[i] = value;
            if (i < axisCountLess) {
                coordinatesLess[i] = value;
            } else {
                coordinatesLessNaN[i] = Double.NaN;
            }
        }
        coordinatesExtra[coordinatesExtra.length - 1] = 6;
        // double[]
        final Point pointDoubleAllAxis = geometryFactory.point(coordinates);
        final Point pointDoubleExtraAxis = geometryFactory.point(coordinatesExtra);
        final Point pointDoubleLessAxis = geometryFactory.point(coordinatesLess);
        assertEquals(coordinates, coordinatesLessNaN, pointDoubleAllAxis, pointDoubleExtraAxis, pointDoubleLessAxis);
        assertObjectContsructor(geometryFactory, coordinates, coordinatesLessNaN, pointDoubleAllAxis, pointDoubleExtraAxis, pointDoubleLessAxis);
        // Coordinates
        final Point pointCoordinatesAllAxis = geometryFactory.point(new PointDouble(coordinates));
        final Point pointCoordinatesExtraAxis = geometryFactory.point(new PointDouble(coordinatesExtra));
        final Point pointCoordinatesLessAxis = geometryFactory.point(new PointDouble(coordinatesLess));
        assertEquals(coordinates, coordinatesLessNaN, pointCoordinatesAllAxis, pointCoordinatesExtraAxis, pointCoordinatesLessAxis);
        assertObjectContsructor(geometryFactory, coordinates, coordinatesLessNaN, pointCoordinatesAllAxis, pointCoordinatesExtraAxis, pointCoordinatesLessAxis);
        // Object Point
        final Point pointAll = pointDoubleAllAxis;
        final Point pointExtra = geometryFactoryExtra.point(coordinatesExtra);
        final Point pointLess = geometryFactoryLess.point(coordinatesLess);
        assertObjectContsructor(geometryFactory, coordinates, coordinatesLessNaN, pointAll, pointExtra, pointLess);
    }
}
Also used : PointDouble(com.revolsys.geometry.model.impl.PointDouble) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point) Test(org.junit.Test)

Aggregations

PointDouble (com.revolsys.geometry.model.impl.PointDouble)24 Point (com.revolsys.geometry.model.Point)22 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)4 Test (org.junit.Test)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 ArrayList (java.util.ArrayList)2 KdNode (com.revolsys.geometry.index.kdtree.KdNode)1 KdTree (com.revolsys.geometry.index.kdtree.KdTree)1 LineString (com.revolsys.geometry.model.LineString)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 LineStringDouble (com.revolsys.geometry.model.impl.LineStringDouble)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 PointDoubleXYZ (com.revolsys.geometry.model.impl.PointDoubleXYZ)1 List (java.util.List)1