* http://valis.cs.uiuc.edu/~sariel/research/CG/compgeom/msg00831.html\r
* http://stackoverflow.com/questions/451426/how-do-i-calculate-the-surface-area-of-a-2d-polygon\r
* http://www.wikihow.com/Calculate-the-Area-of-a-Polygon\r
+ * According to http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u33.html\r
+ * this algorithm works OK with holes, and it seems to (see test)\r
*/\r
public static Amount<Area> area(java.awt.geom.Area a) {\r
- if ( !a.isSingular() )\r
- throw new IllegalArgumentException("Can not calculate area of non-singular shape!");\r
+ //if ( !a.isSingular() )\r
+ //throw new IllegalArgumentException("Can not calculate area of non-singular shape!");\r
PathIterator i = a.getPathIterator(new AffineTransform(), .001);\r
\r
\r
\r
area = area / 2.0; // Result so far is double the signed area\r
\r
- if ( area < 0 ) //Depending on winding it could be negative\r
+ if ( area < 0 ){ //Depending on winding it could be negative\r
area = area * -1.0;\r
+ }\r
\r
\r
return Amount.valueOf(area, SI.MILLIMETER.pow(2)).to(Area.UNIT);\r