Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.CoordinateSequence


                MathTransform worldToGridTransform) throws TransformException {
            final boolean isIdentity = worldToGridTransform.isIdentity();
            final java.awt.Polygon retValue = new java.awt.Polygon();
            final double coords[] = new double[2];
            final LineString exteriorRing = roiInput.getExteriorRing();
            final CoordinateSequence exteriorRingCS = exteriorRing.getCoordinateSequence();
            final int numCoords = exteriorRingCS.size();
            for (int i = 0; i < numCoords; i++) {
                coords[0] = exteriorRingCS.getX(i);
                coords[1] = exteriorRingCS.getY(i);
                if (!isIdentity)
                    worldToGridTransform.transform(coords, 0, coords, 0, 1);
                retValue.addPoint((int) round(coords[0] + 0.5d), (int) round(coords[1] + 0.5d));
            }
            return retValue;
View Full Code Here


            throw new RuntimeException("LinearRing must have at least 4 coordinates");
        }

        if (!coordinates.isEmpty()) {
            Node cnode = (Node) coordinates.get(0);
            CoordinateSequence seq = (CoordinateSequence) cnode.getValue();
            int dimension = GMLUtil.getDimension(seq);

            CoordinateSequence lineSeq = csFactory.create(coordinates.size(), dimension);

            for (int i = 0; i < coordinates.size(); i++) {
                cnode = (Node) coordinates.get(i);
                seq = (CoordinateSequence) cnode.getValue();

                for (int j = 0; j < dimension; j++) {
                    lineSeq.setOrdinate(i, j, seq.getOrdinate(0, j));
                }
            }

            return gFactory.createLinearRing(lineSeq);
        }

        if (node.getChild("coordinates") != null) {
            Node cnode = (Node) node.getChild("coordinates");
            CoordinateSequence lineSeq = (CoordinateSequence) cnode.getValue();

            return gFactory.createLinearRing(lineSeq);
        }

        throw new RuntimeException("Could not find coordinates to build linestring");
View Full Code Here

        Node node = createNode(coordinates, null, null, null, null);
        GMLCoordinatesTypeBinding strategy = (GMLCoordinatesTypeBinding) container
            .getComponentInstanceOfType(GMLCoordinatesTypeBinding.class);

        CoordinateSequence c = (CoordinateSequence) strategy.parse(coordinates, node, null);
        assertNotNull(c);
        assertEquals(3, c.size());
        assertEquals(c.getCoordinate(0), new Coordinate(12.34, 56.78));
        assertEquals(c.getCoordinate(1), new Coordinate(9.10, 11.12));
        assertEquals(c.getCoordinate(2), new Coordinate(13.14, 15.16));
    }
View Full Code Here

                new String[] { ":", ";" });

        GMLCoordinatesTypeBinding strategy = (GMLCoordinatesTypeBinding) container
            .getComponentInstanceOfType(GMLCoordinatesTypeBinding.class);

        CoordinateSequence c = (CoordinateSequence) strategy.parse(coordinates, node, null);
        assertNotNull(c);
        assertEquals(3, c.size());
        assertEquals(c.getCoordinate(0), new Coordinate(12.34, 56.78));
        assertEquals(c.getCoordinate(1), new Coordinate(9.10, 11.12));
        assertEquals(c.getCoordinate(2), new Coordinate(13.14, 15.16));
    }
View Full Code Here

        Node node = createNode(coordinates, null, null, null, null);
        GMLCoordinatesTypeBinding strategy = (GMLCoordinatesTypeBinding) container
            .getComponentInstanceOfType(GMLCoordinatesTypeBinding.class);

        CoordinateSequence c = (CoordinateSequence) strategy.parse(coordinates, node, null);
        assertNotNull(c);
        assertEquals(3, c.size());
        assertEquals(c.getCoordinate(0), new Coordinate(12.34, 56.78));
        assertEquals(c.getCoordinate(1), new Coordinate(9.10, 11.12));
        assertEquals(c.getCoordinate(2), new Coordinate(13.14, 15.16));
    }
View Full Code Here

            return gFactory.createPoint(c);
        }

        if (node.getChild("coordinates") != null) {
            CoordinateSequence seq = (CoordinateSequence) node.getChild("coordinates").getValue();

            return gFactory.createPoint(seq);
        }

        throw new RuntimeException("Could not find a coordinate");
View Full Code Here

        final String singleSpace = " ";
        text = text.replaceAll(anyBlankSeq, singleSpace);

        //first tokenize by tuple seperators
        StringTokenizer tuples = new StringTokenizer(text, ts);
        CoordinateSequence seq = null;
        int i = 0;
        int ncoords = tuples.countTokens(); //number of coordinates

        while (tuples.hasMoreTokens()) {
            String tuple = tuples.nextToken();

            //next tokenize by coordinate seperator
            String[] oords = tuple.split(cs);

            //next tokenize by decimal
            String x = null;

            //next tokenize by decimal
            String y = null;

            //next tokenize by decimal
            String z = null;

            //must be at least 1D     
            x = ".".equals(decimal) ? oords[0] : oords[0].replaceAll(decimal, ".");

            //check for 2 and 3 D
            if (oords.length > 1) {
                y = ".".equals(decimal) ? oords[1] : oords[1].replaceAll(decimal, ".");
            }

            if (oords.length > 2) {
                z = ".".equals(decimal) ? oords[2] : oords[2].replaceAll(decimal, ".");
            }

            if (seq == null) {
                seq = csFactory.create(ncoords, oords.length);
            }

            seq.setOrdinate(i, CoordinateSequence.X, Double.parseDouble(x));

            if (y != null) {
                seq.setOrdinate(i, CoordinateSequence.Y, Double.parseDouble(y));
            }

            if (z != null) {
                seq.setOrdinate(i, CoordinateSequence.Z, Double.parseDouble(z));
            }

            i++;
        }
View Full Code Here

        return seq;
    }

    public Element encode(Object object, Document document, Element value)
        throws Exception {
        CoordinateSequence coordinates = (CoordinateSequence) object;
        StringBuffer buf = new StringBuffer();

        for (int i = 0; i < coordinates.size(); i++) {
            Coordinate c = coordinates.getCoordinate(i);
            buf.append(c.x);

            boolean y = (coordinates.getDimension() > 1) && !new Double(c.y).isNaN();

            if (y) {
                buf.append("," + c.y);
            }

            boolean z = y && (coordinates.getDimension() > 2) && !new Double(c.z).isNaN();

            if (z) {
                buf.append("," + c.z);
            }

            if (i < (coordinates.size() - 1)) {
                buf.append(" ");
            }
        }

        value.appendChild(document.createTextNode(buf.toString()));
View Full Code Here

            throw new RuntimeException("Linestring must have at least 2 coordinates");
        }

        if (!coordinates.isEmpty()) {
            Node cnode = (Node) coordinates.get(0);
            CoordinateSequence seq = (CoordinateSequence) cnode.getValue();
            int dimension = GMLUtil.getDimension(seq);

            CoordinateSequence lineSeq = csFactory.create(coordinates.size(), dimension);

            for (int i = 0; i < coordinates.size(); i++) {
                cnode = (Node) coordinates.get(i);
                seq = (CoordinateSequence) cnode.getValue();

                for (int j = 0; j < dimension; j++) {
                    lineSeq.setOrdinate(i, j, seq.getOrdinate(0, j));
                }
            }

            return gFactory.createLineString(lineSeq);
        }

        if (node.getChild("coordinates") != null) {
            Node cnode = (Node) node.getChild("coordinates");
            CoordinateSequence lineSeq = (CoordinateSequence) cnode.getValue();

            return gFactory.createLineString(lineSeq);
        }

        throw new RuntimeException("Could not find coordinates to build linestring");
View Full Code Here

        if (!coordinates.isEmpty()) {
            throw new RuntimeException("Envelope can have only two coordinates");
        }

        if (node.getChild("coordinates") != null) {
            CoordinateSequence cs = (CoordinateSequence) node.getChild("coordinates").getValue();

            if (cs.size() != 2) {
                throw new RuntimeException("Envelope can have only two coordinates");
            }

            return new Envelope(cs.getX(0), cs.getX(1), cs.getY(0), cs.getY(1));
        }

        throw new RuntimeException("Could not find coordinates for envelope");
    }
View Full Code Here

TOP

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

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.