1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| import {
| MapGeographicPosition,
| } from '/@/types/map'
|
| export type GeojsonCoordinate = [number, number, number?]
|
| export interface GeojsonLine {
| type: 'Feature'
| properties: {
| color: string
| directConnected?: boolean
| }
| geometry: {
| type: 'LineString'
| coordinates: GeojsonCoordinate[]
| }
| }
|
| export interface GeojsonPolygon {
| type: 'Feature'
| properties: {
| color: string
| }
| geometry: {
| type: 'Polygon'
| coordinates: GeojsonCoordinate[][]
| }
| }
|
| export interface GeojsonPoint {
| type: 'Feature'
| properties: {
| color: string
| clampToGround?: boolean
| }
| geometry: {
| type: 'Point'
| coordinates: GeojsonCoordinate
| }
| }
|
| export type GeojsonFeature = GeojsonLine | GeojsonPolygon | GeojsonPoint
|
| export function geographic2Coordinate (position: MapGeographicPosition): GeojsonCoordinate {
| const coordinates: GeojsonCoordinate = [position.longitude, position.latitude]
| if (position.height !== undefined) coordinates.push(position.height)
| return coordinates
| }
|
| export function generateLine (coordinates: MapGeographicPosition[], properties: GeojsonLine['properties']): GeojsonFeature {
| return {
| type: 'Feature',
| properties,
| geometry: {
| type: 'LineString',
| coordinates: coordinates.map(geographic2Coordinate),
| },
| }
| }
|
| export function generatePolygon (coordinates: MapGeographicPosition[], properties: GeojsonPolygon['properties']): GeojsonFeature {
| return {
| type: 'Feature',
| properties,
| geometry: {
| type: 'Polygon',
| coordinates: [coordinates.map(geographic2Coordinate)],
| },
| }
| }
|
| export function generatePoint (position: MapGeographicPosition, properties: GeojsonPoint['properties']): GeojsonFeature {
| return {
| type: 'Feature',
| properties,
| geometry: {
| type: 'Point',
| coordinates: geographic2Coordinate(position),
| },
| }
| }
|
|