Skip to content

Commit 5204af2

Browse files
committed
Improve types, do not collect timestamps from features
1 parent 2b1917a commit 5204af2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { geojson as flatgeobuf } from "flatgeobuf";
22
import { getFlatGeobufRectangle } from "./get-fgb-rect";
3-
import { Map } from "maplibre-gl";
3+
import { GeoJSONFeature, Map } from "maplibre-gl";
44

55
export async function getFgbData({
66
map,
@@ -9,8 +9,10 @@ export async function getFgbData({
99
map: Map;
1010
timestamp: Date;
1111
}) {
12-
let i = 0;
13-
const geojson = { type: "FeatureCollection", features: [] as any[] };
12+
const geojson = {
13+
type: "FeatureCollection",
14+
features: [] as GeoJSONFeature[],
15+
};
1416

1517
const filename = `https://storage.googleapis.com/osm-tardis/${timestamp
1618
.toISOString()
@@ -19,9 +21,7 @@ export async function getFgbData({
1921
const iter = flatgeobuf.deserialize(
2022
filename,
2123
getFlatGeobufRectangle(map),
22-
) as AsyncGenerator<any>;
23-
24-
const timestamps = new Set();
24+
) as AsyncGenerator<GeoJSONFeature>;
2525

2626
for await (const feature of iter) {
2727
const { properties } = feature;
@@ -36,11 +36,9 @@ export async function getFgbData({
3636
properties.changeType === "modifiedNew" ||
3737
properties.changeType === "deletedNew")
3838
) {
39-
geojson.features.push({ ...feature, id: i });
40-
i += 1;
41-
timestamps.add(properties.timestamp);
39+
geojson.features = [...geojson.features, feature];
4240
}
4341
}
4442

45-
return { geojson, timestamps: Array.from(timestamps).sort() };
43+
return { geojson };
4644
}

0 commit comments

Comments
 (0)