cache areas of Rings
This commit is contained in:
parent
a6c5950d31
commit
2f74329bd6
1 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue