1
1
import { geojson as flatgeobuf } from "flatgeobuf" ;
2
2
import { getFlatGeobufRectangle } from "./get-fgb-rect" ;
3
- import { Map } from "maplibre-gl" ;
3
+ import { GeoJSONFeature , Map } from "maplibre-gl" ;
4
4
5
5
export async function getFgbData ( {
6
6
map,
@@ -9,8 +9,10 @@ export async function getFgbData({
9
9
map : Map ;
10
10
timestamp : Date ;
11
11
} ) {
12
- let i = 0 ;
13
- const geojson = { type : "FeatureCollection" , features : [ ] as any [ ] } ;
12
+ const geojson = {
13
+ type : "FeatureCollection" ,
14
+ features : [ ] as GeoJSONFeature [ ] ,
15
+ } ;
14
16
15
17
const filename = `https://storage.googleapis.com/osm-tardis/${ timestamp
16
18
. toISOString ( )
@@ -19,9 +21,7 @@ export async function getFgbData({
19
21
const iter = flatgeobuf . deserialize (
20
22
filename ,
21
23
getFlatGeobufRectangle ( map ) ,
22
- ) as AsyncGenerator < any > ;
23
-
24
- const timestamps = new Set ( ) ;
24
+ ) as AsyncGenerator < GeoJSONFeature > ;
25
25
26
26
for await ( const feature of iter ) {
27
27
const { properties } = feature ;
@@ -36,11 +36,9 @@ export async function getFgbData({
36
36
properties . changeType === "modifiedNew" ||
37
37
properties . changeType === "deletedNew" )
38
38
) {
39
- geojson . features . push ( { ...feature , id : i } ) ;
40
- i += 1 ;
41
- timestamps . add ( properties . timestamp ) ;
39
+ geojson . features = [ ...geojson . features , feature ] ;
42
40
}
43
41
}
44
42
45
- return { geojson, timestamps : Array . from ( timestamps ) . sort ( ) } ;
43
+ return { geojson } ;
46
44
}
0 commit comments