Revize 812b9f90
Přidáno uživatelem Václav Honzík před asi 2 roky(ů)
frontend/src/features/TrackingTool/Upload/GeoJsonIo.ts | ||
---|---|---|
1 |
import { isMapPointDisplayable, PathVariant } from '../pathUtils'
|
|
1 |
import { isMapPointDisplayable, MapPoint, MapPointType, PathVariant } from '../Map/pathUtils'
|
|
2 | 2 |
import * as yup from 'yup' |
3 |
import generateUuid from '../../../utils/id/uuidGenerator' |
|
3 | 4 |
|
4 | 5 |
export const exportAsGeoJsonString = (path: PathVariant) => JSON.stringify({ |
5 | 6 |
type: 'FeatureCollection', |
... | ... | |
28 | 29 |
}) |
29 | 30 |
|
30 | 31 |
const catalogItemValidationSchema = yup.object({ |
31 |
id: yup.string().required(),
|
|
32 |
name: yup.string().required(),
|
|
33 |
allNames: yup.array().of(yup.string()).required(),
|
|
34 |
description: yup.string(), |
|
32 |
id: yup.string().optional(),
|
|
33 |
name: yup.string().optional(),
|
|
34 |
allNames: yup.array().of(yup.string()).optional(),
|
|
35 |
description: yup.string().optional(),
|
|
35 | 36 |
latitude: yup.number().required(), |
36 | 37 |
longitude: yup.number().required(), |
37 | 38 |
}) |
... | ... | |
52 | 53 |
} |
53 | 54 |
const path: PathVariant = features.map((feature: any) => { |
54 | 55 |
const catalogItemDto = feature.properties.catalogItem |
55 |
|
|
56 |
|
|
56 | 57 |
if (!catalogItemDto) { |
57 | 58 |
throw new Error('GeoJson file does not have a valid structure') |
58 | 59 |
} |
... | ... | |
60 | 61 |
const catalogItem = catalogItemValidationSchema.validateSync(catalogItemDto) |
61 | 62 |
|
62 | 63 |
return { |
64 |
id: generateUuid(), |
|
63 | 65 |
idx: feature.properties.idx, |
64 | 66 |
active: true, |
65 | 67 |
catalogItem: { |
... | ... | |
69 | 71 |
latitude: catalogItem.latitude, |
70 | 72 |
longitude: catalogItem.longitude, |
71 | 73 |
}, |
72 |
} |
|
74 |
type: MapPointType.GeoJson, |
|
75 |
} as MapPoint |
|
73 | 76 |
}) |
74 | 77 |
return path |
75 | 78 |
} |
Také k dispozici: Unified diff
draggable list start
re #9741