Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.MultiPoint


    }

    public void testParse() throws Exception {
        GML2MockData.multiPoint(document, document);

        MultiPoint mp = (MultiPoint) parse();
        assertEquals(2, mp.getNumGeometries());
    }
View Full Code Here


        GMLGeometryCollectionTypeBinding s1 = (GMLGeometryCollectionTypeBinding) container
            .getComponentInstanceOfType(GMLGeometryCollectionTypeBinding.class);
        GMLMultiPointTypeBinding s2 = (GMLMultiPointTypeBinding) container
            .getComponentInstanceOfType(GMLMultiPointTypeBinding.class);

        MultiPoint mpoint = (MultiPoint) s2.parse(mp, node, s1.parse(mp, node, null));

        assertNotNull(mpoint);
        assertEquals(mpoint.getNumGeometries(), 2);

        assertEquals(((Point) mpoint.getGeometryN(0)).getX(), 0d, 0d);
        assertEquals(((Point) mpoint.getGeometryN(0)).getY(), 0d, 0d);
        assertEquals(((Point) mpoint.getGeometryN(1)).getX(), 1d, 0d);
        assertEquals(((Point) mpoint.getGeometryN(1)).getY(), 1d, 0d);
    }
View Full Code Here

    }

    public void testParse() throws Exception {
        GML2MockData.multiPointProperty(document, document);

        MultiPoint mp = (MultiPoint) parse();
        assertNotNull(mp);
    }
View Full Code Here

     *
     * @return int The length of the record that this shapepoint will take up in
     *         a shapefile
     */
    public int getLength(Object geometry) {
        MultiPoint mp = (MultiPoint) geometry;

        int length;

        if (shapeType == ShapeType.MULTIPOINT) {
            // two doubles per coord (16 * numgeoms) + 40 for header
            length = (mp.getNumGeometries() * 16) + 40;
        } else if (shapeType == ShapeType.MULTIPOINTM) {
            // add the additional MMin, MMax for 16, then 8 per measure
            length = (mp.getNumGeometries() * 16) + 40 + 16
                    + (8 * mp.getNumGeometries());
        } else if (shapeType == ShapeType.MULTIPOINTZ) {
            // add the additional ZMin,ZMax, plus 8 per Z
            length = (mp.getNumGeometries() * 16) + 40 + 16
                    + (8 * mp.getNumGeometries()) + 16
                    + (8 * mp.getNumGeometries());
        } else {
            throw new IllegalStateException("Expected ShapeType of Arc, got "
                    + shapeType);
        }

View Full Code Here

        return geometryFactory.createMultiPoint(cs);
    }

    public void write(ByteBuffer buffer, Object geometry) {
        MultiPoint mp = (MultiPoint) geometry;

        Envelope box = mp.getEnvelopeInternal();
        buffer.putDouble(box.getMinX());
        buffer.putDouble(box.getMinY());
        buffer.putDouble(box.getMaxX());
        buffer.putDouble(box.getMaxY());

        buffer.putInt(mp.getNumGeometries());

        for (int t = 0, tt = mp.getNumGeometries(); t < tt; t++) {
            Coordinate c = (mp.getGeometryN(t)).getCoordinate();
            buffer.putDouble(c.x);
            buffer.putDouble(c.y);
        }

        if (shapeType == ShapeType.MULTIPOINTZ) {
            double[] zExtreame = JTSUtilities.zMinMax(mp.getCoordinates());

            if (Double.isNaN(zExtreame[0])) {
                buffer.putDouble(0.0);
                buffer.putDouble(0.0);
            } else {
                buffer.putDouble(zExtreame[0]);
                buffer.putDouble(zExtreame[1]);
            }

            for (int t = 0; t < mp.getNumGeometries(); t++) {
                Coordinate c = (mp.getGeometryN(t)).getCoordinate();
                double z = c.z;

                if (Double.isNaN(z)) {
                    buffer.putDouble(0.0);
                } else {
                    buffer.putDouble(z);
                }
            }
        }

        if (shapeType == ShapeType.MULTIPOINTM
                || shapeType == ShapeType.MULTIPOINTZ) {
            buffer.putDouble(-10E40);
            buffer.putDouble(-10E40);

            for (int t = 0; t < mp.getNumGeometries(); t++) {
                buffer.putDouble(-10E40);
            }
        }
    }
View Full Code Here

        WKTReader reader = new WKTReader2();

        Geometry geometry = reader.read(WKT);
        assertNotNull(geometry);
        assertTrue(geometry instanceof MultiPoint);
        MultiPoint mp = (MultiPoint) geometry;
        assertEquals(2, mp.getNumGeometries());
        assertEquals(new Coordinate(111, -47), mp.getGeometryN(0).getCoordinate());
        assertEquals(new Coordinate(110, -46.5), mp.getGeometryN(1).getCoordinate());
    }
View Full Code Here

        WKTReader reader = new WKTReader2();

        Geometry geometry = reader.read(WKT);
        assertNotNull(geometry);
        assertTrue(geometry instanceof MultiPoint);
        MultiPoint mp = (MultiPoint) geometry;
        assertEquals(2, mp.getNumGeometries());
        assertEquals(new Coordinate(111, -47), mp.getGeometryN(0).getCoordinate());
        assertEquals(new Coordinate(110, -46.5), mp.getGeometryN(1).getCoordinate());
    }
View Full Code Here

   
    @Test
    public void multiPoint() throws Exception {
        double[] ords = { 1, 2, 3, 4 };

        MultiPoint mp = builder.multiPoint(ords[0], ords[1], ords[2], ords[3]);
        assertEquals(2, mp.getNumGeometries());

        Point p = (Point) mp.getGeometryN(0);
        assertEquals(2, p.getCoordinateSequence().getDimension());
    }
View Full Code Here

    @Test
    public void multiPointZ() throws Exception {
        double[] ords = { 1, 2, 3, 4, 5, 6 };

        MultiPoint mp = builder.multiPointZ(ords[0], ords[1], ords[2], ords[3], ords[4], ords[5]);
        assertEquals(2, mp.getNumGeometries());

        Point p = (Point) mp.getGeometryN(0);
        assertEquals(3, p.getCoordinateSequence().getDimension());
    }
View Full Code Here

     * @return Appropriate multi geometry type.
     */
    public Geometry create(GeometryFactory geometryFactory) {
        if (internalType.equals("Point")) {
            Point[] pointArray = geometryFactory.toPointArray(geometries);           
            MultiPoint multiPoint = geometryFactory.createMultiPoint(pointArray);
            multiPoint.setUserData( getSRS() );
            multiPoint.setSRID( getSRID() );
            LOGGER.fine("created " + multiPoint);

            return multiPoint;
        } else if (internalType.equals("LineString")) {
            LineString[] lineStringArray = geometryFactory
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.MultiPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.