Changeset 5313 in josm


Ignore:
Timestamp:
2012-07-01T14:49:03+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7829 - Division by zero in Geometry.getCentroid()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r5275 r5313  
    628628        BigDecimal d = new BigDecimal(3, MathContext.DECIMAL128); // 1/2 * 6 = 3
    629629        area  = area.multiply(d, MathContext.DECIMAL128);
    630         north = north.divide(area, MathContext.DECIMAL128);
    631         east = east.divide(area, MathContext.DECIMAL128);
     630        if (area.compareTo(BigDecimal.ZERO) != 0) {
     631            north = north.divide(area, MathContext.DECIMAL128);
     632            east = east.divide(area, MathContext.DECIMAL128);
     633        }
    632634
    633635        return new EastNorth(east.doubleValue(), north.doubleValue());
Note: See TracChangeset for help on using the changeset viewer.