File tree Expand file tree Collapse file tree 4 files changed +39
-38
lines changed Expand file tree Collapse file tree 4 files changed +39
-38
lines changed Original file line number Diff line number Diff line change 1
- import { geojson as flatgeobuf } from "flatgeobuf" ;
2
- import { getFlatGeobufRectangle } from "../utils/get-flatgeobuf-rect" ;
3
-
4
- export async function getFgbData ( map : any ) {
5
- let i = 0 ;
6
- const geojson = { type : "FeatureCollection" , features : [ ] as any [ ] } ;
7
-
8
- const iter = flatgeobuf . deserialize (
9
- "https://storage.googleapis.com/osm-tardis/2013-02-03T15%3A00.fgb" ,
10
- getFlatGeobufRectangle ( map ) ,
11
- ) as AsyncGenerator < any > ;
12
-
13
- const timestamps = new Set ( ) ;
14
-
15
- for await ( const feature of iter ) {
16
- const { properties } = feature ;
17
-
18
- if ( ! properties || properties === null || properties === undefined ) {
19
- continue ;
20
- }
21
-
22
- if (
23
- properties . type !== "relation" &&
24
- ( properties . changeType === "added" ||
25
- properties . changeType === "modifiedNew" ||
26
- properties . changeType === "deletedNew" )
27
- ) {
28
- geojson . features . push ( { ...feature , id : i } ) ;
29
- i += 1 ;
30
- timestamps . add ( properties . timestamp ) ;
31
- }
32
- }
33
-
34
- return { geojson, timestamps : Array . from ( timestamps ) . sort ( ) } ;
35
- }
36
-
37
1
export function calculateStats ( geojson : any ) {
38
2
const stats = {
39
3
tags : { } ,
Original file line number Diff line number Diff line change 1
1
import { useReducerAsync } from "use-reducer-async" ;
2
2
import logReducer from "./log.ts" ;
3
- import { calculateStats , getFgbData } from "../map/utils.ts" ;
3
+ import { calculateStats } from "../map/utils.ts" ;
4
4
import tArea from "@turf/area" ;
5
5
import tBboxPolygon from "@turf/bbox-polygon" ;
6
+ import { getFgbData } from "../utils/get-fgb-data.ts" ;
6
7
7
8
// TODO move to types.ts
8
9
/* eslint-disable no-unused-vars */
@@ -151,7 +152,7 @@ const asyncActionHandlers: any = {
151
152
type : AppActionTypes . UPDATE_VIEW_START ,
152
153
} ) ;
153
154
154
- const { geojson, timestamps } = await getFgbData ( map ) ;
155
+ const { geojson, timestamps } = await getFgbData ( { map } ) ;
155
156
156
157
map . getSource ( "data" ) . setData ( geojson ) ;
157
158
Original file line number Diff line number Diff line change
1
+ import { geojson as flatgeobuf } from "flatgeobuf" ;
2
+ import { getFlatGeobufRectangle } from "./get-fgb-rect" ;
3
+ import { Map } from "maplibre-gl" ;
4
+
5
+ export async function getFgbData ( { map } : { map : Map } ) {
6
+ let i = 0 ;
7
+ const geojson = { type : "FeatureCollection" , features : [ ] as any [ ] } ;
8
+
9
+ const iter = flatgeobuf . deserialize (
10
+ "https://storage.googleapis.com/osm-tardis/2013-02-03T15%3A00.fgb" ,
11
+ getFlatGeobufRectangle ( map ) ,
12
+ ) as AsyncGenerator < any > ;
13
+
14
+ const timestamps = new Set ( ) ;
15
+
16
+ for await ( const feature of iter ) {
17
+ const { properties } = feature ;
18
+
19
+ if ( ! properties || properties === null || properties === undefined ) {
20
+ continue ;
21
+ }
22
+
23
+ if (
24
+ properties . type !== "relation" &&
25
+ ( properties . changeType === "added" ||
26
+ properties . changeType === "modifiedNew" ||
27
+ properties . changeType === "deletedNew" )
28
+ ) {
29
+ geojson . features . push ( { ...feature , id : i } ) ;
30
+ i += 1 ;
31
+ timestamps . add ( properties . timestamp ) ;
32
+ }
33
+ }
34
+
35
+ return { geojson, timestamps : Array . from ( timestamps ) . sort ( ) } ;
36
+ }
File renamed without changes.
You can’t perform that action at this time.
0 commit comments