Changeset 28116 in osm for applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap
- Timestamp:
- 2012-03-19T01:57:46+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java
r28045 r28116 1 1 package org.openstreetmap.josm.plugins.utilsplugin2.replacegeometry; 2 2 3 import edu.princeton.cs.algs4.AssignmentProblem; 3 4 import java.awt.geom.Area; 4 5 import java.awt.geom.Point2D; … … 264 265 } 265 266 266 boolean use Hungarian = Main.pref.getBoolean("utilsplugin2.replace-geometry.robustAssignment", false);267 boolean useRobust = Main.pref.getBoolean("utilsplugin2.replace-geometry.robustAssignment", true); 267 268 268 269 // Find new nodes that are closest to the old ones, remove matching old ones from the pool … … 270 271 Map<Node, Node> nodeAssoc = new HashMap<Node, Node>(); 271 272 if (geometryPool.size() > 0 && nodePool.size() > 0) { 272 if (use Hungarian) { // use robust, but slower assignment273 if (useRobust) { // use robust, but slower assignment 273 274 int gLen = geometryPool.size(); 274 275 int nLen = nodePool.size(); 275 double cost[][] = new double[nLen][gLen]; 276 int N = Math.max(gLen, nLen); 277 double cost[][] = new double[N][N]; 278 for (int i = 0; i < N; i++) { 279 for (int j = 0; j < N; j++) { 280 cost[i][j] = Double.MAX_VALUE; 281 } 282 } 276 283 277 284 double maxDistance = Double.parseDouble(Main.pref.get("utilsplugin2.replace-geometry.max-distance", "1")); … … 286 293 } 287 294 } 288 int[][] assignment = HungarianAlgorithm.hgAlgorithm(cost, "min");289 for (int i = 0; i < nLen; i++) {290 int nIdx = assignment[i][0];291 int gIdx = assignment [i][1];295 AssignmentProblem assignment = new AssignmentProblem(cost); 296 for (int i = 0; i < N; i++) { 297 int nIdx = i; 298 int gIdx = assignment.sol(i); 292 299 if (cost[nIdx][gIdx] != Double.MAX_VALUE) { 293 300 nodeAssoc.put(geometryPool.get(gIdx), nodePool.get(nIdx));
Note:
See TracChangeset
for help on using the changeset viewer.