cache areas of Rings

This commit is contained in:
Sander Deryckere 2012-09-18 13:01:15 +02:00
parent a6c5950d31
commit 2f74329bd6

View file

@ -30,6 +30,11 @@ public class Ring implements Comparable<Ring> {
*/
private Way border;
/**
* area can be asked a lot of times when comparing rings, chace it
*/
private double area = -1;
/**
@ -349,7 +354,11 @@ public class Ring implements Comparable<Ring> {
}
public double getArea() {
return MapAlgorithms.getArea(getBorder());
if (area == -1) {
//cache the area
area = MapAlgorithms.getArea(getBorder());
}
return area;
}