Changeset 20084 in osm
- Timestamp:
- 2010-02-20T17:43:55+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/terracer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/terracer/build.xml
r19678 r20084 32 32 33 33 34 <property name="commit.message" value="josm terracer plugin: fixed reverse terrace, minor updates" />34 <property name="commit.message" value="josm terracer plugin: minor bug (Broken test, whether two sements are next to each other for a closed way.)" /> 35 35 <property name="plugin.main.version" value="2830" /> 36 36 -
applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java
r19678 r20084 191 191 // create intermediate nodes by interpolating. 192 192 for (int i = 0; i <= nb; ++i) { 193 new_nodes[0][i] = interpolateAlong(interp.a, frontLength * (i) 194 / (nb)); 195 new_nodes[1][i] = interpolateAlong(interp.b, backLength * (i) 196 / (nb)); 193 new_nodes[0][i] = interpolateAlong(interp.a, frontLength * i / nb); 194 new_nodes[1][i] = interpolateAlong(interp.b, backLength * i / nb); 197 195 commands.add(new AddCommand(new_nodes[0][i])); 198 196 commands.add(new AddCommand(new_nodes[1][i])); … … 323 321 // than a quadrilateral would have been rejected at an earlier 324 322 // stage. 325 if ( Math.abs(side1 - side2) < 2) {323 if (indexDistance(side1, side2, indexes.length) < 2) { 326 324 side2 = indexes[2]; 327 325 } 328 if ( Math.abs(side1 - side2) < 2) {326 if (indexDistance(side1, side2, indexes.length) < 2) { 329 327 side2 = indexes[3]; 330 328 } … … 366 364 367 365 /** 366 * returns the distance of two segments of a closed polygon 367 */ 368 private int indexDistance(int i1, int i2, int n) { 369 return Math.min(positiveModulus(i1 - i2, n), positiveModulus(i2 - i1, n)); 370 } 371 372 /** 373 * return the modulus in the range [0, n) 374 */ 375 private int positiveModulus(int a, int n) { 376 if (n <=0) 377 throw new IllegalArgumentException(); 378 int res = a % n; 379 if (res < 0) { 380 res += n; 381 } 382 return res; 383 } 384 385 /** 368 386 * Calculate the length of a side (from node i to i+1) in a way. This assumes that 369 387 * the way is closed, but I only ever call it for buildings.
Note:
See TracChangeset
for help on using the changeset viewer.