Changeset 25560 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-03-10T22:28:29+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java
r25488 r25560 316 316 317 317 private void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) { 318 // System.out.println("---------------- " + w.getId());319 320 318 final double angleThreshold = Main.pref.getDouble("simplify-area.angle.threshold", 10); 321 319 final double angleFactor = Main.pref.getDouble("simplify-area.angle.factor", 1.0); … … 346 344 347 345 while (true) { 348 // System.out.println(nodes.size());349 346 Node prevNode = null; 350 347 LatLon coord1 = null; 351 348 LatLon coord2 = null; 349 int prevIndex = -1; 352 350 353 351 double minWeight = Double.MAX_VALUE; 354 352 Node bestMatch = null; 355 353 356 for (int i = 0, len = nodes.size() + (closed ? 2 : 1); i < len; i++) { 357 final int index = i % nodes.size(); 354 final int size2 = nodes.size(); 355 356 for (int i = 0, len = size2 + (closed ? 2 : 1); i < len; i++) { 357 final int index = i % size2; 358 358 359 359 final Node n = nodes.get(index); … … 363 363 final double weight; 364 364 365 if (weightList.get( index) == null) {365 if (weightList.get(prevIndex) == null) { 366 366 final double angleWeight = computeConvectAngle(coord1, coord2, coord3) / angleThreshold; 367 367 final double areaWeight = computeArea(coord1, coord2, coord3) / areaThreshold; 368 368 final double distanceWeight = Math.abs(crossTrackError(coord1, coord2, coord3)) / distanceThreshold; 369 369 370 weight = /*isRequiredNode(w, prevNode, minUse) ||*/ 371 !closed && i == len - 1 || // don't remove last node of the not closed way 372 angleWeight > 1.0 || areaWeight > 1.0 || distanceWeight > 1.0 ? Double.MAX_VALUE : 373 angleWeight * angleFactor + areaWeight * areaFactor + distanceWeight * distanceFactor; 374 375 weightList.set(index, weight); 370 weight = !closed && i == len - 1 || // don't remove last node of the not closed way 371 angleWeight > 1.0 || areaWeight > 1.0 || distanceWeight > 1.0 ? Double.MAX_VALUE : 372 angleWeight * angleFactor + areaWeight * areaFactor + distanceWeight * distanceFactor; 373 374 weightList.set(prevIndex, weight); 376 375 } else { 377 weight = weightList.get( index);376 weight = weightList.get(prevIndex); 378 377 } 379 378 … … 387 386 coord2 = coord3; 388 387 prevNode = n; 388 prevIndex = index; 389 389 } 390 390 … … 395 395 final int index = nodes.indexOf(bestMatch); 396 396 397 final int size2 = nodes.size();398 397 weightList.set((index - 1 + size2) % size2, null); 399 398 weightList.set((index + 1 + size2) % size2, null);
Note:
See TracChangeset
for help on using the changeset viewer.