- Timestamp:
- 2014-08-14T11:27:38+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r7012 r7392 27 27 import org.openstreetmap.josm.command.Command; 28 28 import org.openstreetmap.josm.command.SequenceCommand; 29 import org.openstreetmap.josm.data.osm.Multipolygon Create;30 import org.openstreetmap.josm.data.osm.Multipolygon Create.JoinedPolygon;29 import org.openstreetmap.josm.data.osm.MultipolygonBuilder; 30 import org.openstreetmap.josm.data.osm.MultipolygonBuilder.JoinedPolygon; 31 31 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 32 import org.openstreetmap.josm.data.osm.Relation; … … 191 191 ways.addAll(selectedMultipolygonRelation.getMemberPrimitives(Way.class)); 192 192 193 final Multipolygon Createpolygon = analyzeWays(ways, true);193 final MultipolygonBuilder polygon = analyzeWays(ways, true); 194 194 if (polygon == null) { 195 195 return null; //could not make multipolygon. … … 204 204 public static Pair<Relation, Relation> createMultipolygonRelation(Collection<Way> selectedWays, boolean showNotif) { 205 205 206 final Multipolygon Createpolygon = analyzeWays(selectedWays, showNotif);206 final MultipolygonBuilder polygon = analyzeWays(selectedWays, showNotif); 207 207 if (polygon == null) { 208 208 return null; //could not make multipolygon. … … 265 265 * @return <code>null</code>, if there was a problem with the ways. 266 266 */ 267 private static Multipolygon CreateanalyzeWays(Collection < Way > selectedWays, boolean showNotif) {268 269 Multipolygon Create pol = new MultipolygonCreate();267 private static MultipolygonBuilder analyzeWays(Collection < Way > selectedWays, boolean showNotif) { 268 269 MultipolygonBuilder pol = new MultipolygonBuilder(); 270 270 String error = pol.makeFromWays(selectedWays); 271 271 … … 287 287 * @return multipolygon relation 288 288 */ 289 private static Relation createRelation(Multipolygon Createpol, final Relation rel) {289 private static Relation createRelation(MultipolygonBuilder pol, final Relation rel) { 290 290 // Create new relation 291 291 rel.put("type", "multipolygon"); -
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; -
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r7119 r7392 21 21 public abstract class FileImporter implements Comparable<FileImporter>, LayerChangeListener { 22 22 23 /** 24 * The extension file filter used to accept files. 25 */ 23 26 public final ExtensionFileFilter filter; 24 27 25 28 private boolean enabled; 26 29 30 /** 31 * Constructs a new {@code FileImporter} with the given extension file filter. 32 * @param filter The extension file filter 33 */ 27 34 public FileImporter(ExtensionFileFilter filter) { 28 35 this.filter = filter; … … 30 37 } 31 38 39 /** 40 * Determines if this file importer accepts the given file. 41 * @param pathname The file to test 42 * @return {@code true} if this file importer accepts the given file, {@code false} otherwise 43 */ 32 44 public boolean acceptFile(File pathname) { 33 45 return filter.acceptName(pathname.getName()); -
trunk/src/org/openstreetmap/josm/io/OsmImporter.java
r7037 r7392 18 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 19 19 import org.openstreetmap.josm.gui.util.GuiHelper; 20 import org.openstreetmap.josm.tools.Utils;21 20 22 21 public class OsmImporter extends FileImporter { 23 22 23 /** 24 * The OSM file filter (*.osm and *.xml files). 25 */ 24 26 public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter( 25 27 "osm,xml", "osm", tr("OSM Server Files") + " (*.osm *.xml)"); 26 28 29 /** 30 * Utility class containing imported OSM layer, and a task to run after it is added to MapView. 31 */ 27 32 public static class OsmImporterData { 28 33 … … 51 56 } 52 57 58 /** 59 * Constructs a new {@code OsmImporter} with the given extension file filter. 60 * @param filter The extension file filter 61 */ 53 62 public OsmImporter(ExtensionFileFilter filter) { 54 63 super(filter); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7193 r7392 24 24 import org.openstreetmap.josm.data.coor.LatLon; 25 25 import org.openstreetmap.josm.data.osm.BBox; 26 import org.openstreetmap.josm.data.osm.Multipolygon Create;26 import org.openstreetmap.josm.data.osm.MultipolygonBuilder; 27 27 import org.openstreetmap.josm.data.osm.Node; 28 28 import org.openstreetmap.josm.data.osm.NodePositionComparator; … … 899 899 final MultiPolygonMembers mpm = new MultiPolygonMembers(multiPolygon); 900 900 // Construct complete rings for the inner/outer members 901 final List<Multipolygon Create.JoinedPolygon> outerRings;902 final List<Multipolygon Create.JoinedPolygon> innerRings;901 final List<MultipolygonBuilder.JoinedPolygon> outerRings; 902 final List<MultipolygonBuilder.JoinedPolygon> innerRings; 903 903 try { 904 outerRings = Multipolygon Create.joinWays(mpm.outers);905 innerRings = Multipolygon Create.joinWays(mpm.inners);906 } catch (Multipolygon Create.JoinedPolygonCreationException ex) {904 outerRings = MultipolygonBuilder.joinWays(mpm.outers); 905 innerRings = MultipolygonBuilder.joinWays(mpm.inners); 906 } catch (MultipolygonBuilder.JoinedPolygonCreationException ex) { 907 907 Main.debug("Invalid multipolygon " + multiPolygon); 908 908 return false; 909 909 } 910 910 // Test if object is inside an outer member 911 for (Multipolygon Create.JoinedPolygon out : outerRings) {911 for (MultipolygonBuilder.JoinedPolygon out : outerRings) { 912 912 if (nodes.size() == 1 913 913 ? nodeInsidePolygon(nodes.get(0), out.getNodes()) … … 915 915 boolean insideInner = false; 916 916 // If inside an outer, check it is not inside an inner 917 for (Multipolygon Create.JoinedPolygon in : innerRings) {917 for (MultipolygonBuilder.JoinedPolygon in : innerRings) { 918 918 if (polygonIntersection(in.getNodes(), out.getNodes()) == PolygonIntersection.FIRST_INSIDE_SECOND 919 919 && (nodes.size() == 1
Note:
See TracChangeset
for help on using the changeset viewer.