4
4
START_MAPPING_PAGE_CONTENT ,
5
5
TOAST_NOTIFICATIONS ,
6
6
} from "@/constants" ;
7
- import { BASE_MODELS } from "@/enums" ;
8
7
import { FitToBounds , LayerControl , ZoomLevel } from "@/components/map" ;
9
8
import { Head } from "@/components/seo" ;
10
9
import { LngLatBoundsLike } from "maplibre-gl" ;
@@ -18,11 +17,10 @@ import { useModelDetails } from "@/features/models/hooks/use-models";
18
17
import { useNavigate , useParams , useSearchParams } from "react-router-dom" ;
19
18
import { UserProfile } from "@/components/layout" ;
20
19
import {
21
- BBOX ,
22
20
Feature ,
23
21
TileJSON ,
24
22
TModelPredictions ,
25
- TModelPredictionsConfig ,
23
+ TTrainingDataset ,
26
24
} from "@/types" ;
27
25
import {
28
26
BrandLogoWithDropDown ,
@@ -38,7 +36,6 @@ import {
38
36
showSuccessToast ,
39
37
} from "@/utils" ;
40
38
import {
41
- PREDICTION_API_FILE_EXTENSIONS ,
42
39
REJECTED_MODEL_PREDICTIONS_FILL_LAYER_ID ,
43
40
REJECTED_MODEL_PREDICTIONS_OUTLINE_LAYER_ID ,
44
41
MIN_ZOOM_LEVEL_FOR_START_MAPPING_PREDICTION ,
@@ -70,22 +67,24 @@ export const StartMappingPage = () => {
70
67
const { map, mapContainerRef, currentZoom } = useMapInstance ( ) ;
71
68
const { isSmallViewport } = useScreenSize ( ) ;
72
69
const navigate = useNavigate ( ) ;
73
- const bounds = map ?. getBounds ( ) ;
70
+
74
71
const [ showModelDetailsPopup , setShowModelDetailsPopup ] =
75
72
useState < boolean > ( false ) ;
76
73
const { dropdownIsOpened, onDropdownHide, onDropdownShow } =
77
74
useDropdownMenu ( ) ;
78
75
79
- const { isError, isPending, data, error } = useModelDetails (
80
- modelId as string ,
81
- ! ! modelId ,
82
- ) ;
76
+ const {
77
+ isError,
78
+ isPending,
79
+ data : modelInfo ,
80
+ error,
81
+ } = useModelDetails ( modelId as string , ! ! modelId ) ;
83
82
84
83
const {
85
84
data : trainingDataset ,
86
85
isPending : trainingDatasetIsPending ,
87
86
isError : trainingDatasetIsError ,
88
- } = useGetTrainingDataset ( data ?. dataset as number , ! isPending ) ;
87
+ } = useGetTrainingDataset ( modelInfo ?. dataset as number , ! isPending ) ;
89
88
90
89
const tileJSONURL = extractTileJSONURL ( trainingDataset ?. source_imagery ?? "" ) ;
91
90
@@ -119,6 +118,7 @@ export const StartMappingPage = () => {
119
118
} ;
120
119
} ) ;
121
120
121
+ // Todo - move to local storage.
122
122
const [ modelPredictions , setModelPredictions ] = useState < TModelPredictions > ( {
123
123
all : [ ] ,
124
124
accepted : [ ] ,
@@ -149,25 +149,6 @@ export const StartMappingPage = () => {
149
149
[ searchParams , setSearchParams ] ,
150
150
) ;
151
151
152
- const trainingConfig : TModelPredictionsConfig = {
153
- tolerance : query [ SEARCH_PARAMS . tolerance ] as number ,
154
- area_threshold : query [ SEARCH_PARAMS . area ] as number ,
155
- use_josm_q : query [ SEARCH_PARAMS . useJOSMQ ] as boolean ,
156
- confidence : query [ SEARCH_PARAMS . confidenceLevel ] as number ,
157
- checkpoint : `/mnt/efsmount/data/trainings/dataset_${ data ?. dataset } /output/training_${ data ?. published_training } /checkpoint${ PREDICTION_API_FILE_EXTENSIONS [ data ?. base_model as BASE_MODELS ] } ` ,
158
- max_angle_change : 15 ,
159
- model_id : modelId as string ,
160
- skew_tolerance : 15 ,
161
- source : trainingDataset ?. source_imagery as string ,
162
- zoom_level : currentZoom ,
163
- bbox : [
164
- bounds ?. getWest ( ) ,
165
- bounds ?. getSouth ( ) ,
166
- bounds ?. getEast ( ) ,
167
- bounds ?. getNorth ( ) ,
168
- ] as BBOX ,
169
- } ;
170
-
171
152
const disablePrediction =
172
153
currentZoom < MIN_ZOOM_LEVEL_FOR_START_MAPPING_PREDICTION ;
173
154
@@ -225,18 +206,18 @@ export const StartMappingPage = () => {
225
206
...modelPredictions . all ,
226
207
] ,
227
208
} ,
228
- `all_predictions_${ data . dataset } ` ,
209
+ `all_predictions_${ modelInfo . dataset } ` ,
229
210
) ;
230
211
showSuccessToast ( TOAST_NOTIFICATIONS . startMapping . fileDownloadSuccess ) ;
231
- } , [ modelPredictions ] ) ;
212
+ } , [ modelPredictions , modelInfo ] ) ;
232
213
233
214
const handleAcceptedFeaturesDownload = useCallback ( async ( ) => {
234
215
geoJSONDowloader (
235
216
{ type : "FeatureCollection" , features : modelPredictions . accepted } ,
236
- `accepted_predictions_${ data . dataset } ` ,
217
+ `accepted_predictions_${ modelInfo . dataset } ` ,
237
218
) ;
238
219
showSuccessToast ( TOAST_NOTIFICATIONS . startMapping . fileDownloadSuccess ) ;
239
- } , [ modelPredictions ] ) ;
220
+ } , [ modelPredictions , modelInfo ] ) ;
240
221
241
222
const handleFeaturesDownloadToJOSM = useCallback (
242
223
( features : Feature [ ] ) => {
@@ -316,13 +297,12 @@ export const StartMappingPage = () => {
316
297
317
298
return (
318
299
< >
319
- < Head title = { START_MAPPING_PAGE_CONTENT . pageTitle ( data ?. name ) } />
300
+ < Head title = { START_MAPPING_PAGE_CONTENT . pageTitle ( modelInfo ?. name ) } />
320
301
{ /* Mobile dialog */ }
321
302
< div className = "h-screen flex flex-col fullscreen" >
322
303
< StartMappingMobileDrawer
323
304
isOpen = { isSmallViewport }
324
305
disablePrediction = { disablePrediction }
325
- trainingConfig = { trainingConfig }
326
306
setModelPredictions = { setModelPredictions }
327
307
modelPredictions = { modelPredictions }
328
308
map = { map }
@@ -332,31 +312,33 @@ export const StartMappingPage = () => {
332
312
updateQuery = { updateQuery }
333
313
modelDetailsPopupIsActive = { showModelDetailsPopup }
334
314
clearPredictions = { clearPredictions }
315
+ trainingDataset = { trainingDataset as TTrainingDataset }
316
+ currentZoom = { currentZoom }
317
+ modelInfo = { modelInfo }
335
318
/>
336
319
< div className = "sticky top-0 bg-white z-10 px-4 xl:px-large py-1 hidden md:block" >
337
320
{ /* Model Details Popup */ }
338
- { data && (
321
+ { modelInfo && (
339
322
< ModelDetailsPopUp
340
323
showPopup = { showModelDetailsPopup }
341
324
handlePopup = { handleModelDetailsPopup }
342
325
closeMobileDrawer = { ( ) => setShowModelDetailsPopup ( false ) }
343
326
anchor = { popupAnchorId }
344
- model = { data }
327
+ model = { modelInfo }
345
328
trainingDataset = { trainingDataset }
346
329
trainingDatasetIsPending = { trainingDatasetIsPending }
347
330
trainingDatasetIsError = { trainingDatasetIsError }
348
331
/>
349
332
) }
350
333
{ /* Web Header */ }
351
334
< StartMappingHeader
352
- data = { data }
335
+ modelInfo = { modelInfo }
353
336
trainingDatasetIsPending = { trainingDatasetIsPending }
354
337
modelPredictionsExist = { modelPredictionsExist }
355
338
trainingDatasetIsError = { trainingDatasetIsError }
356
339
modelPredictions = { modelPredictions }
357
340
query = { query }
358
341
updateQuery = { updateQuery }
359
- trainingConfig = { trainingConfig }
360
342
setModelPredictions = { setModelPredictions }
361
343
map = { map }
362
344
disablePrediction = { disablePrediction }
@@ -365,6 +347,8 @@ export const StartMappingPage = () => {
365
347
handleModelDetailsPopup = { handleModelDetailsPopup }
366
348
downloadOptions = { downloadOptions }
367
349
clearPredictions = { clearPredictions }
350
+ trainingDataset = { trainingDataset as TTrainingDataset }
351
+ currentZoom = { currentZoom }
368
352
/>
369
353
</ div >
370
354
< div className = "col-span-12 h-[70vh] md:h-full md:border-8 md:border-off-white flex-grow relative map-elements-z-index" >
@@ -408,7 +392,7 @@ export const StartMappingPage = () => {
408
392
currentZoom = { currentZoom }
409
393
layers = { mapLayers }
410
394
tmsBounds = { oamTileJSON ?. bounds as LngLatBoundsLike }
411
- trainingId = { data ?. published_training }
395
+ trainingId = { modelInfo ?. published_training }
412
396
/>
413
397
</ div >
414
398
</ div >
0 commit comments