Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.CoordinateSequence


    public static CoordinateSequence coordiantes(CoordinateSequenceFactory f,
        OrdinateList x, OrdinateList y, OrdinateList z, OrdinateList m) {
        final int LENGTH = x.size();
        // TODO org.geotools.geometry.jts.LiteCoordinateSequenceFactory does not support 4 dimensions!
        // CoordinateSequence cs = f.create(LENGTH, z == null ? 3: 4);
        CoordinateSequence cs = f.create(LENGTH, z == null ? 2: 3);

        if (z != null) {
            for (int i = 0; i < LENGTH; i++) {
                cs.setOrdinate(i, 0, x.getDouble(i));
                cs.setOrdinate(i, 1, y.getDouble(i));
                cs.setOrdinate(i, 2, z.getDouble(i));
                // cs.setOrdinate(i, 3, m.getDouble(i));
            }
        } else {
            for (int i = 0; i < LENGTH; i++) {
                cs.setOrdinate(i, 0, x.getDouble(i));
                cs.setOrdinate(i, 1, y.getDouble(i));
                // cs.setOrdinate(i, 2, m.getDouble(i));
            }
        }

        return cs;
View Full Code Here


        final int L = SDO.L(GTYPE);
        final int TT = SDO.TT(GTYPE);
        double[] list;
        double[][] lists;

        CoordinateSequence coords;


        if ((L == 0) && (TT == 01) && (point != null) && (elemInfo == null)) {
            // Single Point Type Optimization
            coords = SDO.coordinates(gf.getCoordinateSequenceFactory(), GTYPE,
View Full Code Here

            return null;
           

        LineString result;
        if (etype == ETYPE.LINE && INTERPRETATION == 1) {
            CoordinateSequence subList = subList(gf.getCoordinateSequenceFactory(), coords, GTYPE,
                    elemInfo, triplet, compoundElement);
            result = gf.createLineString(subList);
        } else if (etype == ETYPE.LINE && INTERPRETATION == 2) {
            CoordinateSequence subList = subList(gf.getCoordinateSequenceFactory(), coords, GTYPE,
                    elemInfo, triplet, compoundElement);
            result = gf.createCurvedGeometry(subList);
        } else if (etype == ETYPE.COMPOUND) {
            int triplets = INTERPRETATION;
            List<LineString> components = new ArrayList<>(triplets);
View Full Code Here

            ring = gf.createLinearRing(subList(gf.getCoordinateSequenceFactory(), coords, GTYPE,
                    elemInfo, triplet, false));
        } else if (INTERPRETATION == 3) {
            // rectangle does not maintain measures
            //
            CoordinateSequence ext = subList(gf.getCoordinateSequenceFactory(), coords, GTYPE,
                    elemInfo, triplet, false);
            Coordinate min = ext.getCoordinate(0);
            Coordinate max = ext.getCoordinate(1);
            ring = gf.createLinearRing(new Coordinate[] {
                        min, new Coordinate(max.x, min.y), max,
                        new Coordinate(min.x, max.y), min
                    });
        } else if (INTERPRETATION == 4) {
            // rectangle does not maintain measures
            //
            CoordinateSequence ext = subList(gf.getCoordinateSequenceFactory(), coords, GTYPE,
                    elemInfo, triplet, false);
            if (ext.size() != 3) {
                throw new IllegalArgumentException(
                        "The coordinate sequence for the circle creation must contain 3 points, the one at hand contains "
                                + ext.size() + " instead");
            }
            double[] cp = new double[ext.size() * 2 + 2];
            for (int i = 0; i < ext.size(); i++) {
                cp[i * 2] = ext.getOrdinate(i, 0);
                cp[i * 2 + 1] = ext.getOrdinate(i, 1);
            }
            // figure out the other point
            CircularArc arc = new CircularArc(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
            ring = CurvedGeometries.toCircle(arc, gf, gf.getTolerance());
        } else {
View Full Code Here

    //
    // Utility Methods
    //
    protected LinearRing ring(double coords[]) {
        CoordinateSequence seq = coords(coords);
        return gf.createLinearRing(seq);
    }
View Full Code Here

    }

    public void testParse() throws Exception {
        buildDocument("<coordinates>1,1 2,2</coordinates>");

        CoordinateSequence cs = (CoordinateSequence) parse();

        assertEquals(2, cs.size());
        assertEquals(new Coordinate(1, 1), cs.getCoordinate(0));
        assertEquals(new Coordinate(2, 2), cs.getCoordinate(1));

        buildDocument("<coordinates>1,1,1" + " 2,2,2" + " </coordinates>");
        cs = (CoordinateSequence) parse();

        assertEquals(2, cs.size());
        assertEquals(new Coordinate(1, 1), cs.getCoordinate(0));
        assertEquals(1d, cs.getCoordinate(0).z, 0.1);
        assertEquals(new Coordinate(2, 2), cs.getCoordinate(1));
        assertEquals(2d, cs.getCoordinate(1).z, 0.1);
    }
View Full Code Here

        assertEquals(new Coordinate(2, 2), cs.getCoordinate(1));
        assertEquals(2d, cs.getCoordinate(1).z, 0.1);
    }
   
    public void testEncode() throws Exception {
        CoordinateSequence cs = CoordinateArraySequenceFactory.instance().create(
            new Coordinate[]{ new Coordinate(1,1), new Coordinate(2,2) }
        );
        Document dom = encode( cs, KML.coordinates );
        assertEquals( "1.0,1.0 2.0,2.0", dom.getDocumentElement().getFirstChild().getTextContent() );
    }
View Full Code Here

            return c;
        }

        // handle coordinate sequence dimension correctly
        int size = toIndex - fromIndex;
        CoordinateSequence newSeq = factory.create(size, sequence.getDimension());
        CoordinateSequences.copy(sequence, fromIndex, newSeq, 0, size);
        return newSeq;
     }
View Full Code Here

            return c;
        } else // else CoordinateSequence
        {
            // handle coordinate sequence dimension correctly
            CoordinateSequence revSeq = factory.create(sequence);
            CoordinateSequences.reverse(revSeq);
            return revSeq;
        }
    }
View Full Code Here

            buffer.append(",NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),");
            buffer.append("MDSYS.SDO_ORDINATE_ARRAY(");

        CoordinateSequenceFactory fact = polygon.getFactory().getCoordinateSequenceFactory();
        CoordinateSequence exterior = polygon.getExteriorRing().getCoordinateSequence();
        CoordinateSequence coordSeq = SDO.counterClockWise(fact, exterior);

            for (int i = 0, size = coordSeq.size(); i < size; i++) {
        Coordinate cur = coordSeq.getCoordinate(i);
                buffer.append(cur.x);
                buffer.append(",");
                buffer.append(cur.y);

                if (i != (size - 1)) {
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.