Changeset 7392 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2014-08-14T11:27:38+02:00 (10 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java
r7391 r7392 16 16 import org.openstreetmap.josm.tools.MultiMap; 17 17 18 public class MultipolygonCreate { 18 /** 19 * Helper class to build multipolygons from multiple ways. 20 * @author viesturs 21 * @since 7392 (rename) 22 * @since 3704 23 */ 24 public class MultipolygonBuilder { 19 25 20 26 /** 21 27 * Represents one polygon that consists of multiple ways. 22 * @author Viesturs23 *24 28 */ 25 29 public static class JoinedPolygon { … … 29 33 public final Area area; 30 34 35 /** 36 * Constructs a new {@code JoinedPolygon} from given list of ways. 37 * @param ways The ways used to build joined polygon 38 */ 31 39 public JoinedPolygon(List<Way> ways, List<Boolean> reversed) { 32 40 this.ways = ways; … … 55 63 boolean reversed = this.reversed.get(waypos).booleanValue(); 56 64 57 if (!reversed) {65 if (!reversed) { 58 66 for (int pos = 0; pos < way.getNodesCount() - 1; pos++) { 59 67 nodes.add(way.getNode(pos)); … … 71 79 } 72 80 73 74 81 /** 75 82 * Helper storage class for finding findOuterWays 76 * @author viesturs77 83 */ 78 84 static class PolygonLevel { … … 89 95 } 90 96 91 public List<JoinedPolygon> outerWays; 92 public List<JoinedPolygon> innerWays; 93 94 public MultipolygonCreate(List<JoinedPolygon> outerWays, List<JoinedPolygon> innerWays){ 97 /** List of outer ways **/ 98 public final List<JoinedPolygon> outerWays; 99 /** List of inner ways **/ 100 public final List<JoinedPolygon> innerWays; 101 102 /** 103 * Constructs a new {@code MultipolygonBuilder} initialized with given ways. 104 * @param outerWays The outer ways 105 * @param innerWays The inner ways 106 */ 107 public MultipolygonBuilder(List<JoinedPolygon> outerWays, List<JoinedPolygon> innerWays) { 95 108 this.outerWays = outerWays; 96 109 this.innerWays = innerWays; 97 110 } 98 111 99 public MultipolygonCreate(){ 112 /** 113 * Constructs a new empty {@code MultipolygonBuilder}. 114 */ 115 public MultipolygonBuilder() { 100 116 this.outerWays = new ArrayList<>(0); 101 117 this.innerWays = new ArrayList<>(0); … … 122 138 */ 123 139 public static class JoinedPolygonCreationException extends RuntimeException { 140 /** 141 * Constructs a new {@code JoinedPolygonCreationException}. 142 * @param message the detail message. The detail message is saved for 143 * later retrieval by the {@link #getMessage()} method 144 */ 124 145 public JoinedPolygonCreationException(String message) { 125 146 super(message); … … 159 180 //process unclosed ways 160 181 for (Way startWay: ways) { 161 if (usedWays.contains(startWay)) {182 if (usedWays.contains(startWay)) { 162 183 continue; 163 184 } … … 191 212 192 213 Way nextWay = null; 193 for(Way way: adjacentWays) {194 if (way != curWay) {214 for(Way way: adjacentWays) { 215 if (way != curWay) { 195 216 nextWay = way; 196 217 } … … 217 238 List<PolygonLevel> list = findOuterWaysRecursive(0, polygons); 218 239 219 if (list == null) {240 if (list == null) { 220 241 return tr("There is an intersection between ways."); 221 242 } 222 243 223 this.outerWays = new ArrayList<>(0);224 this.innerWays = new ArrayList<>(0);244 this.outerWays.clear(); 245 this.innerWays.clear(); 225 246 226 247 //take every other level … … 265 286 innerCandidates.add(innerWay); 266 287 } 267 else if (intersection == PolygonIntersection.CROSSING) 268 { 288 else if (intersection == PolygonIntersection.CROSSING) { 269 289 //ways intersect 270 290 return null;
Note:
See TracChangeset
for help on using the changeset viewer.