@@ -24,6 +24,19 @@ import { ClimbType } from '../../../ClimbTypes.js'
24
24
import MutableMediaDataSource from '../../../../model/MutableMediaDataSource.js'
25
25
import { workingDir } from './init.js'
26
26
27
+ const MEDIA_PROJECTION = {
28
+ width : 1 ,
29
+ height : 1 ,
30
+ mediaUrl : 1 ,
31
+ format : 1 ,
32
+ _id : 0 ,
33
+ 'entityTags.targetId' : 1 ,
34
+ 'entityTags.ancestors' : 1 ,
35
+ 'entityTags.climbName' : 1 ,
36
+ 'entityTags.areaName' : 1 ,
37
+ 'entityTags.type' : 1
38
+ }
39
+
27
40
/**
28
41
* Export leaf areas as Geojson. Leaf areas are crags/boulders that have climbs.
29
42
*/
@@ -72,8 +85,8 @@ async function exportLeafCrags (): Promise<void> {
72
85
content,
73
86
media : await MutableMediaDataSource . getInstance ( ) . findMediaByAreaId (
74
87
metadata . area_id ,
75
- ancestors
76
- ) ,
88
+ MEDIA_PROJECTION ,
89
+ true ) ,
77
90
climbs : climbs . map ( ( { _id, name, type, grades } : ClimbType ) => ( {
78
91
id : _id . toUUID ( ) . toString ( ) ,
79
92
name,
@@ -169,7 +182,8 @@ async function exportAreas (): Promise<void> {
169
182
metadata : {
170
183
isDestination : 1 ,
171
184
polygon : 1 ,
172
- leftRightIndex : 1
185
+ leftRightIndex : 1 ,
186
+ level : { $size : { $split : [ '$ancestors' , ',' ] } }
173
187
} ,
174
188
pathTokens : 1 ,
175
189
ancestors : { $split : [ '$ancestors' , ',' ] } ,
@@ -192,19 +206,7 @@ async function exportAreas (): Promise<void> {
192
206
{
193
207
type : 'areas' ,
194
208
...doc ,
195
- media : await MutableMediaDataSource . getInstance ( ) . findMediaByAreaId ( muuid . from ( doc . id ) , {
196
- width : 1 ,
197
- height : 1 ,
198
- mediaUrl : 1 ,
199
- format : 1 ,
200
- _id : 0 ,
201
- 'entityTags.targetId' : 1 ,
202
- 'entityTags.ancestors' : 1 ,
203
- 'entityTags.climbName' : 1 ,
204
- 'entityTags.areaName' : 1 ,
205
- 'entityTags.type' : 1
206
- } ,
207
- true ) ,
209
+ media : await MutableMediaDataSource . getInstance ( ) . findMediaByAreaId ( muuid . from ( doc . id ) , MEDIA_PROJECTION , true ) ,
208
210
metadata : doc . metadata
209
211
} ,
210
212
{
0 commit comments