Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.CoordinateSequenceFactory


     * @param geom
     *
     * @return <code>3</code>
     */
    public static int D(Geometry geom) {
        CoordinateSequenceFactory f = geom.getFactory()
                                          .getCoordinateSequenceFactory();

        if (f instanceof CoordinateAccessFactory) {
            return ((CoordinateAccessFactory) f).getDimension();
        } else {
View Full Code Here


     * @param geom
     *
     * @return <code>0</code>
     */
    public static int L(Geometry geom) {
        CoordinateSequenceFactory f = geom.getFactory()
                                          .getCoordinateSequenceFactory();

        if (f instanceof CoordinateAccessFactory) {
            return ((CoordinateAccessFactory) f).getDimension();
        } else {
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);
View Full Code Here

        public Envelope envelope() {
            return new Envelope(minX, maxX, minY, maxY);
        }
       
        public Object getSimplifiedShape() {
            CoordinateSequenceFactory csf = geometryFactory.getCoordinateSequenceFactory();
            if(type.isPointType()) {
                CoordinateSequence cs = csf.create(1, 2);
                cs.setOrdinate(0, 0, (minX + maxX) / 2);
                cs.setOrdinate(0, 1, (minY + maxY) / 2);
                return geometryFactory.createMultiPoint(new Point[] {geometryFactory.createPoint(cs)});
            } else if(type.isLineType()) {
                CoordinateSequence cs = csf.create(2, 2);
                cs.setOrdinate(0, 0, minX);
                cs.setOrdinate(0, 1, minY);
                cs.setOrdinate(1, 0, maxX);
                cs.setOrdinate(1, 1, maxY);
                return geometryFactory.createMultiLineString(new LineString[] {geometryFactory.createLineString(cs)});
            } else if(type.isPolygonType()) {
                CoordinateSequence cs = csf.create(5, 2);
                cs.setOrdinate(0, 0, minX);
                cs.setOrdinate(0, 1, minY);
                cs.setOrdinate(1, 0, minX);
                cs.setOrdinate(1, 1, maxY);
                cs.setOrdinate(2, 0, maxX);
View Full Code Here

        // grab a geometry factory... check for a special hint
        Hints hints = query.getHints();
        GeometryFactory geometryFactory = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY);
        if (geometryFactory == null) {
            // look for a coordinate sequence factory
            CoordinateSequenceFactory csFactory = (CoordinateSequenceFactory) hints
                    .get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY);

            if (csFactory != null) {
                geometryFactory = new GeometryFactory(csFactory);
            }
View Full Code Here

     *                The ring to reverse.
     * @return A new ring with the reversed Coordinates.
     */
    public static final LinearRing reverseRing(LinearRing lr) {
    GeometryFactory gf = lr.getFactory();
    CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();

    CoordinateSequence csOrig = lr.getCoordinateSequence();
    int numPoints = csOrig.size();
    int dimensions = csOrig.getDimension();
    CoordinateSequence csNew = csf.create(numPoints, dimensions);

    for (int i = 0; i < numPoints; i++) {
      for (int j = 0; j < dimensions; j++) {
        csNew.setOrdinate(numPoints-1-i, j, csOrig.getOrdinate(i, j));
      }
View Full Code Here

         * @return {@code true} if the {@code provider} meets the user requirements.
         */
        protected boolean isAcceptable(final Object provider, final Class category, final Hints hints) {
            if (GeometryFactory.class.isAssignableFrom(category)) {
                final GeometryFactory           factory   = (GeometryFactory) provider;
                final CoordinateSequenceFactory sequence  = factory.getCoordinateSequenceFactory();
                final PrecisionModel            precision = factory.getPrecisionModel();
                if (!isAcceptable(sequence,  hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY)) ||
                    !isAcceptable(precision, hints.get(Hints.JTS_PRECISION_MODEL)))
                {
                    return false;
View Full Code Here

        if (g instanceof LineString) {
            return clipLineString((LineString) g);
        } else if (g instanceof Polygon) {
            if(ensureValid) {
                GeometryFactory gf = g.getFactory();
                CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();
                return g.intersection(gf.createPolygon(buildBoundsString(gf, csf), null));
            } else {
                return clipPolygon((Polygon) g);
            }
        } else if (g instanceof GeometryCollection) {
View Full Code Here

        // the result
        List<LineString> clipped = new ArrayList<LineString>();

        // grab all the factories a
        final GeometryFactory gf = line.getFactory();
        final CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();
        final CoordinateSequence coords = line.getCoordinateSequence();

        // first step
        final Ordinates ordinates = new Ordinates(coords.size());
        double x0 = coords.getX(0);
        double y0 = coords.getY(0);
        boolean prevInside = contained(x0, y0);
        if (prevInside) {
            ordinates.add(x0, y0);
        }
        double[] segment = new double[4];
        final int size = coords.size();
        // loop over the other coordinates
        for (int i = 1; i < size; i++) {
            final double x1 = coords.getX(i);
            final double y1 = coords.getY(i);

            boolean inside = contained(x1, y1);
            if (inside == prevInside) {
                if (inside) {
                    // both segments were inside, not need for clipping
                    ordinates.add(x1, y1);
                } else {
                    // both were outside, this might still be caused by a line
                    // crossing the envelope but whose endpoints lie outside
                    if (!outside(x0, y0, x1, y1)) {
                        segment[0] = x0;
                        segment[1] = y0;
                        segment[2] = x1;
                        segment[3] = y1;
                        double[] clippedSegment = clipSegment(segment);
                        if (clippedSegment != null) {
                            CoordinateSequence cs = csf.create(2, 2);
                            cs.setOrdinate(0, 0, clippedSegment[0]);
                            cs.setOrdinate(0, 1, clippedSegment[1]);
                            cs.setOrdinate(1, 0, clippedSegment[2]);
                            cs.setOrdinate(1, 1, clippedSegment[3]);
                            clipped.add(gf.createLineString(cs));
                        }
                    }
                }
            } else {
                // one inside, the other outside, a clip must occurr
                segment[0] = x0;
                segment[1] = y0;
                segment[2] = x1;
                segment[3] = y1;
                double[] clippedSegment = clipSegment(segment);
                if (clippedSegment != null) {
                    if (prevInside) {
                        ordinates.add(clippedSegment[2], clippedSegment[3]);
                    } else {
                        ordinates.add(clippedSegment[0], clippedSegment[1]);
                        ordinates.add(clippedSegment[2], clippedSegment[3]);
                    }
                    // if we are going from inside to outside it's time to cut a linestring
                    // into the results
                    if (prevInside) {
                        // if(closed) {
                        // addClosingPoints(ordinates, shell);
                        // clipped.add(gf.createLinearRing(ordinates.toCoordinateSequence(csf)));
                        // } else {
                        clipped.add(gf.createLineString(ordinates.toCoordinateSequence(csf)));
                        // }
                        ordinates.clear();
                    }
                } else {
                    prevInside = false;
                }
            }
            prevInside = inside;
            x0 = x1;
            y0 = y1;
        }
        // don't forget the last linestring
        if (ordinates.size() > 1) {
            clipped.add(gf.createLineString(ordinates.toCoordinateSequence(csf)));
        }

        if (line.isClosed() && clipped.size() > 1) {
            // the first and last strings might be adjacent, in that case fuse them
            CoordinateSequence cs0 = clipped.get(0).getCoordinateSequence();
            CoordinateSequence cs1 = clipped.get(clipped.size() - 1).getCoordinateSequence();
            if (cs0.getOrdinate(0, 0) == cs1.getOrdinate(cs1.size() - 1, 0)
                    && cs0.getOrdinate(0, 1) == cs1.getOrdinate(cs1.size() - 1, 1)) {
                CoordinateSequence cs = csf.create(cs0.size() + cs1.size() - 1, 2);
                for (int i = 0; i < cs1.size(); i++) {
                    cs.setOrdinate(i, 0, cs1.getOrdinate(i, 0));
                    cs.setOrdinate(i, 1, cs1.getOrdinate(i, 1));
                }
                for (int i = 1; i < cs0.size(); i++) {
View Full Code Here

     * @param geometryType
     * @return
     */
    public Geometry getSimplifiedShape(double minx, double miny, double maxx, double maxy,
            GeometryFactory geometryFactory, Class geometryType) {
        CoordinateSequenceFactory csf = geometryFactory.getCoordinateSequenceFactory();
        double midx = (minx + maxx) / 2;
        double midy = (miny + maxy) / 2;
        double x0 = midx - spanX / 2;
        double x1 = midx + spanX / 2;
        double y0 = midy - spanY / 2;
        double y1 = midy + spanY / 2;
        if (Point.class.isAssignableFrom(geometryType)
                || MultiPoint.class.isAssignableFrom(geometryType)) {
            CoordinateSequence cs = csf.create(1, 2);
            cs.setOrdinate(0, 0, midx);
            cs.setOrdinate(0, 1, midy);
            if (Point.class.isAssignableFrom(geometryType)) {
                // people should not call this method for a point, but... whatever
                return geometryFactory.createPoint(cs);
            } else {
                return geometryFactory.createMultiPoint(new Point[] { geometryFactory
                        .createPoint(cs) });
            }
        } else if (LineString.class.isAssignableFrom(geometryType)
                || MultiLineString.class.isAssignableFrom(geometryType)) {
            CoordinateSequence cs = csf.create(2, 2);
            cs.setOrdinate(0, 0, x0);
            cs.setOrdinate(0, 1, y0);
            cs.setOrdinate(1, 0, x1);
            cs.setOrdinate(1, 1, y1);
            if (MultiLineString.class.isAssignableFrom(geometryType)) {
                return geometryFactory.createMultiLineString(new LineString[] { geometryFactory
                        .createLineString(cs) });
            } else {
                return geometryFactory.createLineString(cs);
            }
        } else {
            CoordinateSequence cs = csf.create(5, 2);
            cs.setOrdinate(0, 0, x0);
            cs.setOrdinate(0, 1, y0);
            cs.setOrdinate(1, 0, x0);
            cs.setOrdinate(1, 1, y1);
            cs.setOrdinate(2, 0, x1);
View Full Code Here

TOP

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

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.