Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.CoordinateSequence


    protected final CoordinateSequence toCoords(double[] coordList,
            final CoordinateSequenceFactory csFact) {

        final int dimension = 2;

        CoordinateSequence cs;

        if (csFact instanceof LiteCoordinateSequenceFactory) {
            cs = ((LiteCoordinateSequenceFactory) csFact).create(coordList, dimension);
        } else {
            final int nCoords = coordList.length / dimension;
            cs = csFact.create(nCoords, dimension);
            for (int coordN = 0; coordN < nCoords; coordN++) {
                cs.setOrdinate(coordN, 0, coordList[dimension * coordN]);
                cs.setOrdinate(coordN, 1, coordList[dimension * coordN + 1]);
            }
        }
        return cs;
    }
View Full Code Here


        protected final LineString constructLineString(final double[] linearCoords,
                final GeometryFactory geometryFactory) throws DataSourceException {
            LineString ls = null;

            CoordinateSequence coords = toCoords(linearCoords,
                    geometryFactory.getCoordinateSequenceFactory());

            ls = geometryFactory.createLineString(coords);

            return ls;
View Full Code Here

                final GeometryFactory geometryFactory) {
            Polygon p = null;

            final CoordinateSequenceFactory sequenceFactory = geometryFactory
                    .getCoordinateSequenceFactory();
            final CoordinateSequence coords = toCoords(shellCoords, sequenceFactory);
            final LinearRing shell = geometryFactory.createLinearRing(coords);
            final int nHoles = holes.length;

            LinearRing[] polygonHoles = new LinearRing[nHoles];
View Full Code Here

     * @param gf
     * @return
     */
    public CoordinateSequence toCoordinateSequence(GeometryFactory gf) {
        double[] data = getData();
        CoordinateSequence cs = gf.getCoordinateSequenceFactory().create(data.length / 2, 2);
        for (int i = 0; i < cs.size(); i++) {
            cs.setOrdinate(i, 0, data[i * 2]);
            cs.setOrdinate(i, 1, data[i * 2 + 1]);
        }
        return cs;
    }
View Full Code Here

            Map hints) throws IOException, OperationNotSupportedException {
            if (!canEncode(element, value, hints)) {
                throw new OperationNotSupportedException("Cannot encode");
            }

            CoordinateSequence g = (CoordinateSequence) value;

            GMLComplexTypes.encodeCoords(element, g, output);
        }
View Full Code Here

        boolean ring) {
        if (node.hasChild(DirectPosition.class)) {
            List dps = node.getChildValues(DirectPosition.class);
            DirectPosition dp = (DirectPosition) dps.get(0);

            CoordinateSequence seq = csf.create(dps.size(), dp.getDimension());

            for (int i = 0; i < dps.size(); i++) {
                dp = (DirectPosition) dps.get(i);

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

            return ring ? gf.createLinearRing(seq) : gf.createLineString(seq);
        }

        if (node.hasChild(Point.class)) {
            List points = node.getChildValues(Point.class);
            Coordinate[] coordinates = new Coordinate[points.size()];

            for (int i = 0; i < points.size(); i++) {
                coordinates[i] = ((Point) points.get(0)).getCoordinate();
            }

            return ring ? gf.createLinearRing(coordinates) : gf.createLineString(coordinates);
        }

        if (node.hasChild(Coordinate.class)) {
            List list = node.getChildValues(Coordinate.class);
            Coordinate[] coordinates = (Coordinate[]) list.toArray(new Coordinate[list.size()]);

            return ring ? gf.createLinearRing(coordinates) : gf.createLineString(coordinates);
        }

        if (node.hasChild(DirectPosition[].class)) {
            DirectPosition[] dps = (DirectPosition[]) node.getChildValue(DirectPosition[].class);

            CoordinateSequence seq = null;

            if (dps.length == 0) {
                seq = csf.create(0, 0);
            } else {
                seq = csf.create(dps.length, dps[0].getDimension());

                for (int i = 0; i < dps.length; i++) {
                    DirectPosition dp = (DirectPosition) dps[i];

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

            return ring ? gf.createLinearRing(seq) : gf.createLineString(seq);
        }

        if (node.hasChild(CoordinateSequence.class)) {
            CoordinateSequence seq = (CoordinateSequence) node.getChildValue(CoordinateSequence.class);

            return ring ? gf.createLinearRing(seq) : gf.createLineString(seq);
        }

        return null;
View Full Code Here

*
* @source $URL$
*/
public class GML3EncodingUtils {
    static DirectPosition[] positions(LineString line) {
        CoordinateSequence coordinates = line.getCoordinateSequence();
        DirectPosition[] dps = new DirectPosition[coordinates.size()];

        double x;
        double y;

        for (int i = 0; i < dps.length; i++) {
            x = coordinates.getOrdinate(i, 0);
            y = coordinates.getOrdinate(i, 1);
            dps[i] = new DirectPosition2D(x, y);
        }

        return dps;
    }
View Full Code Here

        return ordinates(list, geom);
    }
   
    public static CoordinateSequence getCS(Geometry geom)
    {
        CoordinateSequence cs = null;
        switch (TT(geom)) {
        case TT.UNKNOWN:
            break; // extend with your own custom types

        case TT.POINT:
View Full Code Here

        final int TT = SDO.TT(GTYPE);

        //      POINT_TYPE Special Case
        //
        if ((D == 2) && (L == 0) && (TT == 1)) {
            CoordinateSequence cs = f.create(1, 2);
            for (int i = 0; i < 2; i++)
                cs.setOrdinate(0, i, ordinates[i]);
            return cs;
        }

        final int LEN = D; // bugfix 20121231-BK: LEN = D instead of LEN = D + L as Oracle supports only one LRS ordinate!
View Full Code Here

     */
    public static CoordinateSequence coordiantes(CoordinateSequenceFactory f,
        OrdinateList x, OrdinateList y, OrdinateList z) {
        final int LENGTH = x.size();
        // Coordinate[] array = new Coordinate[LENGTH];
        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));
            }
        } else {
            for (int i = 0; i < LENGTH; i++) {
                cs.setOrdinate(i, 0, x.getDouble(i));
                cs.setOrdinate(i, 1, y.getDouble(i));
            }
        }

        return cs;
    }
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.