Revision 2616 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.split/src/main/java/org/gvsig/vectorediting/lib/prov/split/operation/splitsurface/SurfaceSplitOperation.java

View differences:

SurfaceSplitOperation.java
24 24

  
25 25
package org.gvsig.vectorediting.lib.prov.split.operation.splitsurface;
26 26

  
27
import java.util.ArrayList;
28
import java.util.Iterator;
29
import java.util.List;
30

  
31 27
import com.vividsolutions.jts.algorithm.CGAlgorithms;
32 28
import com.vividsolutions.jts.geom.Coordinate;
33 29
import com.vividsolutions.jts.geom.CoordinateArrays;
......
40 36
import com.vividsolutions.jts.geom.Polygon;
41 37
import com.vividsolutions.jts.geomgraph.DirectedEdge;
42 38
import com.vividsolutions.jts.geomgraph.Node;
43

  
39
import java.util.ArrayList;
40
import java.util.Arrays;
41
import java.util.Iterator;
42
import java.util.List;
44 43
import org.gvsig.fmap.geom.Geometry;
45 44
import org.gvsig.fmap.geom.GeometryLocator;
46 45
import org.gvsig.fmap.geom.GeometryManager;
......
93 92
     * @author Mauricio Pazos, Axios Engineering
94 93
     * @since 1.1.0
95 94
     */
95
    @Override
96 96
    public Geometry split(Geometry geometryToBeSplitted, Geometry splitter)
97 97
        throws GeometryOperationNotSupportedException,
98 98
        GeometryOperationException {
......
133 133

  
134 134
        final GeometryFactory gf = jtsMultiPoligon.getFactory();
135 135
        com.vividsolutions.jts.geom.Geometry result;
136
        List<com.vividsolutions.jts.geom.Geometry> splittedGeometries = new ArrayList<com.vividsolutions.jts.geom.Geometry>();
136
        List<com.vividsolutions.jts.geom.Geometry> splittedGeometries = new ArrayList<>();
137 137
        for (int i = 0; i < jtsMultiPoligon.getNumGeometries(); i++) {
138 138
            com.vividsolutions.jts.geom.Geometry jtsGeom = jtsMultiPoligon.getGeometryN(i);
139 139
            com.vividsolutions.jts.geom.Geometry splittedGeometry;
......
155 155
            result = splittedGeometries.get(0);
156 156
        } else {
157 157
            Polygon[] array =
158
                splittedGeometries.toArray(new Polygon[splittedGeometries
159
                    .size()]);
158
                splittedGeometries.toArray(new Polygon[splittedGeometries.size()]);
160 159
            result = gf.createMultiPolygon(array);
161 160
        }
162 161
        return result;
......
199 198
     */
200 199
    private List<LinearRing> findUnsplittedHoles(SplitGraph graph,
201 200
        GeometryFactory gf) {
202
        final List<LinearRing> unsplittedHoles = new ArrayList<LinearRing>(2);
201
        final List<LinearRing> unsplittedHoles = new ArrayList<>(2);
203 202

  
204
        final List<SplitEdge> edges = new ArrayList<SplitEdge>();
203
        final List<SplitEdge> edges = new ArrayList<>();
205 204
        for (Iterator it = graph.getEdgeIterator(); it.hasNext();) {
206 205
            SplitEdge edge = (SplitEdge) it.next();
207 206
            edges.add(edge);
208 207
        }
209 208

  
210
        for (Iterator it = edges.iterator(); it.hasNext();) {
211
            SplitEdge edge = (SplitEdge) it.next();
209
        for (SplitEdge edge : edges) {
212 210
            if (edge.isHoleEdge()) {
213 211
                Coordinate[] coordinates = edge.getCoordinates();
214 212
                Coordinate start = coordinates[0];
......
231 229
     * @return
232 230
     */
233 231
    private List<List<SplitEdge>> findRings(SplitGraph graph) {
234
        final List<List<SplitEdge>> rings = new ArrayList<List<SplitEdge>>();
232
        final List<List<SplitEdge>> rings = new ArrayList<>();
235 233

  
236 234
        DirectedEdge startEdge;
237 235
        // build each ring starting with the first edge belonging to the
......
272 270

  
273 271
    private List<SplitEdge> buildRing(final SplitGraph graph,
274 272
        final DirectedEdge startEdge) {
275
        final List<SplitEdge> ring = new ArrayList<SplitEdge>();
273
        final List<SplitEdge> ring = new ArrayList<>();
276 274

  
277 275
        // follow this tessellation direction while possible,
278 276
        // switch to the opposite when not, and continue with
......
336 334
    private List<Polygon> buildSimplePolygons(List<List<SplitEdge>> allRings,
337 335
        List<LinearRing> unsplittedHoles, GeometryFactory gf) {
338 336

  
339
        List<Polygon> polygons = new ArrayList<Polygon>(allRings.size());
337
        List<Polygon> polygons = new ArrayList<>(allRings.size());
340 338

  
341 339
        for (List<SplitEdge> edgeList : allRings) {
342 340
            Polygon poly = buildPolygon(edgeList, gf);
343 341
            List<LinearRing> thisPolyHoles =
344
                new ArrayList<LinearRing>(unsplittedHoles.size());
342
                new ArrayList<>(unsplittedHoles.size());
345 343
            for (LinearRing holeRing : unsplittedHoles) {
346 344
                if (poly.covers(holeRing)) {
347 345
                    thisPolyHoles.add(holeRing);
......
365 363
    }
366 364

  
367 365
    private Polygon buildPolygon(List<SplitEdge> edgeList, GeometryFactory gf) {
368
        List<Coordinate> coords = new ArrayList<Coordinate>();
366
        List<Coordinate> coords = new ArrayList<>();
369 367
        Coordinate[] lastCoordinates = null;
370 368
        for (SplitEdge edge : edgeList) {
371 369
            Coordinate[] coordinates = edge.getCoordinates();
......
379 377
                }
380 378
            }
381 379
            lastCoordinates = coordinates;
382
            for (int i = 0; i < coordinates.length; i++) {
383
                Coordinate coord = coordinates[i];
384
                coords.add(coord);
385
            }
380
            coords.addAll(Arrays.asList(coordinates));
386 381
        }
387 382
        Coordinate[] shellCoords = new Coordinate[coords.size()];
388 383
        coords.toArray(shellCoords);

Also available in: Unified diff