Skip to content

Commit ea7cf3b

Browse files
authored
fix: display item collections (#125)
Closes #86
1 parent db2e289 commit ea7cf3b

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/components/item-collection.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ export default function ItemCollection({
2424

2525
return (
2626
<Stack>
27-
<Value value={itemCollection}></Value>
27+
<Value value={itemCollection}>
28+
{itemCollection.features.length > 0 &&
29+
itemCollection.features.length +
30+
" item" +
31+
(itemCollection.features.length > 1 ? "s" : "")}
32+
</Value>
2833
{isStacGeoparquet &&
2934
((stacGeoparquetMetadata && (
3035
<StacGeoparquetInfo

src/components/map.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { Layer, type DeckProps } from "@deck.gl/core";
33
import { GeoJsonLayer } from "@deck.gl/layers";
44
import { MapboxOverlay } from "@deck.gl/mapbox";
55
import { GeoArrowPolygonLayer } from "@geoarrow/deck.gl-layers";
6+
import { bbox as turfBbox } from "@turf/bbox";
67
import bboxPolygon from "@turf/bbox-polygon";
78
import { featureCollection } from "@turf/helpers";
8-
import type { BBox, Feature, GeoJSON } from "geojson";
9+
import type { BBox, Feature, FeatureCollection, GeoJSON } from "geojson";
910
import "maplibre-gl/dist/maplibre-gl.css";
1011
import { useEffect, useRef, type RefObject } from "react";
1112
import {
@@ -118,6 +119,7 @@ export default function Map() {
118119
updateTriggers: [picked, items],
119120
}),
120121
];
122+
console.log(geojson);
121123

122124
if (stacGeoparquetTable) {
123125
layers.push(
@@ -229,7 +231,11 @@ function useStacValueLayerProperties(
229231
filled: true,
230232
};
231233
case "FeatureCollection":
232-
return { geojson: undefined, bbox: undefined, filled: undefined };
234+
return {
235+
geojson: value.features as Feature[],
236+
bbox: turfBbox(value as FeatureCollection),
237+
filled: true,
238+
};
233239
}
234240
} else {
235241
return { geojson: undefined, bbox: undefined, filled: undefined };

src/components/value.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, ButtonGroup } from "@chakra-ui/react";
1+
import { Button, ButtonGroup, Stack } from "@chakra-ui/react";
22
import { type ReactNode } from "react";
33
import { LuExternalLink } from "react-icons/lu";
44
import { MarkdownHooks } from "react-markdown";
@@ -28,17 +28,19 @@ export default function Value({
2828
title={(value.title as string) || value.id || value.type}
2929
titleSize="xl"
3030
>
31-
{thumbnailAsset && <Thumbnail asset={thumbnailAsset}></Thumbnail>}
31+
<Stack>
32+
{thumbnailAsset && <Thumbnail asset={thumbnailAsset}></Thumbnail>}
3233

33-
{!!value.description && (
34-
<Prose>
35-
<MarkdownHooks>{value.description as string}</MarkdownHooks>
36-
</Prose>
37-
)}
34+
{!!value.description && (
35+
<Prose>
36+
<MarkdownHooks>{value.description as string}</MarkdownHooks>
37+
</Prose>
38+
)}
3839

39-
{children}
40+
{children}
4041

41-
{selfHref && <SelfHrefButtons href={selfHref}></SelfHrefButtons>}
42+
{selfHref && <SelfHrefButtons href={selfHref}></SelfHrefButtons>}
43+
</Stack>
4244
</Section>
4345
);
4446
}

0 commit comments

Comments
 (0)