Changeset 30791 in osm for applications/editors
- Timestamp:
- 2014-11-04T19:12:00+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java
r30689 r30791 32 32 import org.openstreetmap.josm.data.osm.Node; 33 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 34 35 import org.openstreetmap.josm.data.osm.Way; 35 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane; … … 38 39 import org.openstreetmap.josm.tools.Shortcut; 39 40 40 public class SimplifyAreaAction extends JosmAction {41 public final class SimplifyAreaAction extends JosmAction { 41 42 42 43 public SimplifyAreaAction() { … … 50 51 } 51 52 52 private boolean isInBounds(final Node node, final List<Bounds> bounds) {53 private static boolean isInBounds(final Node node, final List<Bounds> bounds) { 53 54 for (final Bounds b : bounds) { 54 55 if (b.contains(node.getCoor())) { … … 59 60 } 60 61 61 private boolean confirmWayWithNodesOutsideBoundingBox() {62 private static boolean confirmWayWithNodesOutsideBoundingBox() { 62 63 final ButtonSpec[] options = new ButtonSpec[] { new ButtonSpec(tr("Yes, delete nodes"), ImageProvider.get("ok"), tr("Delete nodes outside of downloaded data regions"), null), 63 64 new ButtonSpec(tr("No, abort"), ImageProvider.get("cancel"), tr("Cancel operation"), null) }; … … 175 176 } 176 177 178 private static boolean nodeGluesWays(final Node node) { 179 Set<Node> referenceNeighbours = null; 180 for (final OsmPrimitive ref : node.getReferrers()) { 181 if (ref.getType() == OsmPrimitiveType.WAY) { 182 final Way way = ((Way) ref); 183 final Set<Node> neighbours = way.getNeighbours(node); 184 if (referenceNeighbours == null) { 185 referenceNeighbours = neighbours; 186 } else if (!referenceNeighbours.containsAll(neighbours)) { 187 return true; 188 } 189 } 190 } 191 192 return false; 193 } 194 177 195 // average nearby nodes 178 private Collection<Command> averageNearbyNodes(final Collection<Way> ways, final Collection<Node> nodesAlreadyDeleted) {196 private static Collection<Command> averageNearbyNodes(final Collection<Way> ways, final Collection<Node> nodesAlreadyDeleted) { 179 197 final double mergeThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.MERGE_THRESHOLD, 0.2); 180 198 … … 200 218 201 219 while (true) { 202 double minDist = Double. MAX_VALUE;220 double minDist = Double.POSITIVE_INFINITY; 203 221 Node node1 = null; 204 222 Node node2 = null; … … 299 317 } 300 318 301 private void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) {319 private static void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) { 302 320 final double angleThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_THRESHOLD, 10); 303 321 final double angleFactor = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_FACTOR, 1.0); … … 333 351 int prevIndex = -1; 334 352 335 double minWeight = Double. MAX_VALUE;353 double minWeight = Double.POSITIVE_INFINITY; 336 354 Node bestMatch = null; 337 355 … … 357 375 358 376 weight = !closed && i == len - 1 || // don't remove last node of the not closed way 359 angleWeight > 1.0 || areaWeight > 1.0 || distanceWeight > 1.0 ? Double.MAX_VALUE : 377 nodeGluesWays(prevNode) || 378 angleWeight > 1.0 || areaWeight > 1.0 || distanceWeight > 1.0 ? Double.POSITIVE_INFINITY : 360 379 angleWeight * angleFactor + areaWeight * areaFactor + distanceWeight * distanceFactor; 361 380
Note:
See TracChangeset
for help on using the changeset viewer.