File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 1
1
import { geojson as flatgeobuf } from "flatgeobuf" ;
2
-
3
- export function fbgBbox ( map : any ) {
4
- const { lng, lat } = map . getCenter ( ) ;
5
- const { _sw, _ne } = map . getBounds ( ) ;
6
- const distanceX =
7
- Math . min ( Math . abs ( _sw . lng - lng ) , Math . abs ( _ne . lng - lng ) ) * 0.9 ;
8
- const distanceY =
9
- Math . min ( Math . abs ( _sw . lat - lat ) , Math . abs ( _ne . lat - lat ) ) * 0.9 ;
10
- return {
11
- minX : lng - distanceX ,
12
- minY : lat - distanceY ,
13
- maxX : lng + distanceX ,
14
- maxY : lat + distanceY ,
15
- } ;
16
- }
2
+ import { getFlatGeobufRectangle } from "../utils/get-flatgeobuf-rect" ;
17
3
18
4
export async function getFgbData ( map : any ) {
19
5
let i = 0 ;
20
6
const geojson = { type : "FeatureCollection" , features : [ ] as any [ ] } ;
21
7
22
8
const iter = flatgeobuf . deserialize (
23
9
"https://storage.googleapis.com/osm-tardis/2013-02-03T15%3A00.fgb" ,
24
- fbgBbox ( map ) ,
10
+ getFlatGeobufRectangle ( map ) ,
25
11
) as AsyncGenerator < any > ;
26
12
27
13
const timestamps = new Set ( ) ;
Original file line number Diff line number Diff line change
1
+ import { Map } from "maplibre-gl" ;
2
+
3
+ export function getFlatGeobufRectangle ( map : Map ) {
4
+ const { lng, lat } = map . getCenter ( ) ;
5
+ const { _sw, _ne } = map . getBounds ( ) ;
6
+ const distanceX =
7
+ Math . min ( Math . abs ( _sw . lng - lng ) , Math . abs ( _ne . lng - lng ) ) * 0.9 ;
8
+ const distanceY =
9
+ Math . min ( Math . abs ( _sw . lat - lat ) , Math . abs ( _ne . lat - lat ) ) * 0.9 ;
10
+ return {
11
+ minX : lng - distanceX ,
12
+ minY : lat - distanceY ,
13
+ maxX : lng + distanceX ,
14
+ maxY : lat + distanceY ,
15
+ } ;
16
+ }
You can’t perform that action at this time.
0 commit comments