mirror of
https://github.com/placeAtlas/atlas.git
synced 2024-09-26 12:09:00 +02:00
add sort by area (largest to smallest)
This commit is contained in:
parent
16267a7562
commit
67c91eada1
2 changed files with 16 additions and 0 deletions
|
@ -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){
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue