Package com.vividsolutions.jts.geom.prep

Examples of com.vividsolutions.jts.geom.prep.PreparedPolygon


            ArrayList<Polygon> holes = new ArrayList();

            for (int i = 0; i < polys.size(); i++) {
                boolean found = false;
                Polygon p = (Polygon) polys.get(i);
                PreparedPolygon ppoly = new PreparedPolygon(p);

                for (final Object o : idx.query(p.getEnvelopeInternal())) {
                    SimpleFeature f = (SimpleFeature) o;

                    // Funktioniert auch intersect? Schneller?
                    if (ppoly.contains(((Geometry) f.getAttribute(geomName
                            + "_point")))) {
                        f.setAttribute(geomName, p);
                        features.add(f);
                        found = true;
                        break;
                    }
                }

                if (!found) {

                    // Falls wirklich bewusste Löcher im Datensatz sind, führt
                    // das zu falschen
                    // Resultaten. Nur zu den "holes" hinzufügen, falls kleiner
                    // als ein bestimmter Wert.
                    if (p.getArea() < 1.0) {
                        holes.add(p);
                    }
                }
            }

            // Restflächen, die aufgrund des neu Verknotens entstanden sind,
            // werden dem Polygon mit der längsten gemeinsamen Kanten
            // zugewiesen.
            // Mal schauen obs schon hinhaut.
            boolean repair = true;
            if (repair) {
                final SpatialIndex spatialIndex = new STRtree();
                Iterator nt = features.iterator();

                while (nt.hasNext()) {
                    SimpleFeature feat = (SimpleFeature) nt.next();
                    Geometry point = (Geometry) feat.getAttribute(geomName);
                    spatialIndex.insert(point.getEnvelopeInternal(), feat);
                }

                logger.debug("Anzahl Löcher: ");
                logger.debug(holes.size());
                for (int i = 0; i < holes.size(); i++) {
                    Polygon p = holes.get(i);
                    PreparedPolygon ppoly = new PreparedPolygon(p);

                    double length = 0.0;
                    SimpleFeature feat = null;

                    for (final Object o : spatialIndex.query(p
                            .getEnvelopeInternal())) {
                        SimpleFeature f = (SimpleFeature) o;
                        Geometry g = ((Geometry) f.getAttribute(geomName));
                        if (ppoly.intersects(g)) {
                            // logger.debug("***************************");
                            // logger.debug(p.toString());
                            // logger.debug(g.toString());
                            Geometry geom = p.intersection(g);
                            // logger.debug(geom.toString());
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.prep.PreparedPolygon

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.