1
- import { geojson as flatgeobuf } from "flatgeobuf" ;
1
+ import { IGeoJsonFeature , geojson as flatgeobuf } from "flatgeobuf" ;
2
2
3
3
export function fbgBbox ( map : any ) {
4
4
const { lng, lat } = map . getCenter ( ) ;
@@ -17,25 +17,31 @@ export function fbgBbox(map: any) {
17
17
18
18
export async function getFgbData ( map : any ) {
19
19
let i = 0 ;
20
- const geojson = { type : "FeatureCollection" , features : [ ] } ;
20
+ const geojson = { type : "FeatureCollection" , features : [ ] as any [ ] } ;
21
21
22
22
const iter = flatgeobuf . deserialize (
23
23
"https://storage.googleapis.com/osm-tardis/2013-02-03T15%3A00.fgb" ,
24
24
fbgBbox ( map ) ,
25
- ) ;
25
+ ) as AsyncGenerator < IGeoJsonFeature > ;
26
26
27
27
const timestamps = new Set ( ) ;
28
28
29
29
for await ( const feature of iter ) {
30
+ const { properties } = feature ;
31
+
32
+ if ( ! properties || properties === null || properties === undefined ) {
33
+ continue ;
34
+ }
35
+
30
36
if (
31
- feature . properties . type !== "relation" &&
32
- ( feature . properties . changeType === "added" ||
33
- feature . properties . changeType === "modifiedNew" ||
34
- feature . properties . changeType === "deletedNew" )
37
+ properties . type !== "relation" &&
38
+ ( properties . changeType === "added" ||
39
+ properties . changeType === "modifiedNew" ||
40
+ properties . changeType === "deletedNew" )
35
41
) {
36
- geojson . features = geojson . features . concat ( { ...feature , id : i } ) ;
42
+ geojson . features . push ( { ...feature , id : i } ) ;
37
43
i += 1 ;
38
- timestamps . add ( feature . properties . timestamp ) ;
44
+ timestamps . add ( properties . timestamp ) ;
39
45
}
40
46
}
41
47
0 commit comments