add sort by area (largest to smallest)

This commit is contained in:
Tonny2442 2022-04-06 13:05:44 -04:00
parent 16267a7562
commit 67c91eada1
2 changed files with 16 additions and 0 deletions

View file

@ -449,6 +449,21 @@ function initView(){
return 0;
}
break;
case "area":
sortFunction = function(a, b){
// todo: not exactly optimised
let areaA = calcPolygonArea(a.path);
let areaB = calcPolygonArea(b.path);
if (areaA > areaB) {
return -1;
}
if (areaA < areaB) {
return 1;
}
// areaA must be equal to areaB
return 0;
}
break;
case "relevant":
sortFunction = function(a, b){
if(a.name.toLowerCase().indexOf(filter) !== -1 && b.name.toLowerCase().indexOf(filter) !== -1){

View file

@ -126,6 +126,7 @@ <h1 id="title">The 2022 /r/place Atlas</h1>
<option value="alphaDesc">↑ Alphabetical</option>
<option value="newest">Newest</option>
<option value="oldest">Oldest</option>
<option value="area">Area</option>
</select>
</div>
</div>