Skip to content

Commit 9fb4078

Browse files
committed
fix: use geojson types
1 parent 5bc0fdf commit 9fb4078

12 files changed

Lines changed: 56 additions & 41 deletions

File tree

package-lock.json

Lines changed: 22 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"scripts": {
1111
"test": "echo \"Error: no test specified\" && exit 1",
1212
"lint": "eslint . --fix",
13+
"dev": "vite",
1314
"build": "vite build",
1415
"prettier": "npx prettier . --write",
1516
"prepare": "husky",
@@ -40,6 +41,11 @@
4041
"@semantic-release/github"
4142
]
4243
},
44+
"peerDependencies": {
45+
"@chargetrip/frontend-utilities": "^1.4.1",
46+
"d3-geo": "^3.0.1",
47+
"three": "^0.133.1"
48+
},
4349
"devDependencies": {
4450
"@eslint/js": "^9.16.0",
4551
"@types/d3-geo": "^3.0.2",
@@ -56,9 +62,7 @@
5662
"vite-plugin-glsl": "^1.4.1"
5763
},
5864
"dependencies": {
59-
"@chargetrip/frontend-utilities": "^1.4.1",
60-
"d3-geo": "^3.0.1",
61-
"three": "^0.133.1",
65+
"geojson": "^0.5.0",
6266
"ts-deepmerge": "^7.0.3"
6367
}
6468
}

src/components/bar.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ export default class Bar {
1818

1919
draw(): THREE.Mesh {
2020
const targetVector = new THREE.Vector3(0, 0, 0)
21+
22+
const [lng, lat] = this.config.location.geometry.coordinates;
23+
24+
if(!lng || !lat) throw Error("Invalid coordinates");
25+
2126
const position = calculateVec3FromLatLon(
22-
this.config.location.geometry.coordinates[0],
23-
this.config.location.geometry.coordinates[1],
27+
lng, lat,
2428
600,
2529
)
2630

src/components/globe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import dotsFragmentShader from '../shaders/dots.frag.glsl'
1515
export default class Globe {
1616
readonly config: GlobeConfig
1717

18-
isAnimating = true
18+
// isAnimating = true
1919
#camera: THREE.PerspectiveCamera
2020

2121
constructor(config: GlobeConfig, camera: THREE.PerspectiveCamera) {

src/components/marker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ export default class Marker {
3636
depthTest: false,
3737
})
3838

39+
const [lng, lat] = this.config.location.geometry.coordinates;
40+
41+
if(!lng || !lat) throw Error("Invalid coordinates.");
42+
3943
const position = calculateVec3FromLatLon(
40-
this.config.location.geometry.coordinates[0],
41-
this.config.location.geometry.coordinates[1],
44+
lng,
45+
lat,
4246
600,
4347
)
4448

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ import Arc from './components/arc'
33
import Marker from './components/marker'
44
import Bar from './components/bar'
55

6-
import { GeoJSONType } from './types/geojson'
76

8-
export { GlobeScene, Arc, Bar, Marker, GeoJSONType }
7+
export { GlobeScene, Arc, Bar, Marker }

src/types/arc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Vector3 } from 'three'
2-
import type { GeoJSON } from './geojson'
2+
import type { Feature, Point } from 'geojson';
33

44
export interface ArcConfig {
5-
startLocation: GeoJSON
6-
endLocation: GeoJSON
5+
startLocation: Feature<Point>
6+
endLocation: Feature<Point>
77
startColor?: string
88
startColorOpacity?: number
99
endColor?: string

src/types/bar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { GeoJSON } from './geojson'
1+
import type { Feature, Point } from 'geojson';
22

33
export interface BarConfig {
4-
location: GeoJSON
4+
location: Feature<Point>
55
startColor?: string
66
startColorOpacity?: number
77
endColor?: string

src/types/geojson.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/types/marker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { GeoJSON } from './geojson'
1+
import type { Feature, Point } from 'geojson';
22

33
export interface MarkerConfig {
4-
location: GeoJSON
4+
location: Feature<Point>
55
color?: string
66
size?: number
77
circleRadius?: number

0 commit comments

Comments
 (0)