Changeset 29272 in osm for applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
- Timestamp:
- 2013-02-21T21:01:44+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
r29271 r29272 201 201 202 202 public boolean hasNext() { 203 return (edge != null) && ((it == null) || ( forward && it.hasNext()) || (!forward && it.hasPrevious()));203 return (edge != null) && ((it == null) || (edge.nodes.isEmpty()) || (forward && it.hasNext()) || (!forward && it.hasPrevious())); 204 204 } 205 205 … … 371 371 372 372 public void tagsDone(long id) { 373 if ((feature.type != Obj.UNKOBJ) && !((edge != null) && (edge.last == 0))) {374 index.put(id, feature);375 if (features.get(feature.type) == null) {376 features.put(feature.type, new ArrayList<Feature>());377 }378 features.get(feature.type).add(feature);379 }380 373 switch (feature.flag) { 381 374 case POINT: … … 432 425 break; 433 426 } 434 feature.centre = findCentroid(feature); 427 if ((feature.type != Obj.UNKOBJ) && !((edge != null) && (edge.last == 0))) { 428 index.put(id, feature); 429 if (features.get(feature.type) == null) { 430 features.put(feature.type, new ArrayList<Feature>()); 431 } 432 feature.centre = findCentroid(feature); 433 features.get(feature.type).add(feature); 434 } 435 435 } 436 436 … … 461 461 462 462 public Snode findCentroid(Feature feature) { 463 double lat, lon, slat, slon, sarc, llat, llon; 464 lat = lon = slat = slon = sarc = llat = llon = 0; 463 double lat, lon, slat, slon, llat, llon; 464 llat = llon = lat = lon = slat = slon = 0; 465 double sarc = 0; 466 boolean first = true; 465 467 switch (feature.flag) { 466 468 case POINT: … … 473 475 lat = node.lat; 474 476 lon = node.lon; 475 sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat))); 477 if (first) { 478 first = false; 479 } else { 480 sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat))); 481 } 476 482 llat = lat; 477 483 llon = lon; … … 479 485 double harc = sarc / 2; 480 486 sarc = 0; 487 first = true; 481 488 eit = new EdgeIterator(edge, true); 482 489 while (eit.hasNext()) { … … 484 491 lat = node.lat; 485 492 lon = node.lon; 486 sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat))); 487 if (sarc > harc) 488 break; 493 if (first) { 494 first = false; 495 } else { 496 sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat))); 497 if (sarc > harc) 498 break; 499 } 489 500 harc -= sarc; 490 501 llat = lat; … … 497 508 BoundIterator bit = new BoundIterator(bound); 498 509 while (bit.hasNext()) { 499 llon = lon;500 llat = lat;501 510 Snode node = bit.next(); 502 511 lat = node.lat; 503 512 lon = node.lon; 504 double arc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat))); 505 slat += (lat * arc); 506 slon += (lon * arc); 507 sarc += arc; 513 if (first) { 514 first = false; 515 } else { 516 double arc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat))); 517 slat += (lat * arc); 518 slon += (lon * arc); 519 sarc += arc; 520 } 521 llon = lon; 522 llat = lat; 508 523 } 509 524 return new Snode((sarc > 0.0 ? slat / sarc : 0.0), (sarc > 0.0 ? slon / sarc : 0.0));
Note:
See TracChangeset
for help on using the changeset viewer.