Skip to content

Commit d32f9c4

Browse files
committed
docs(preview): update browser share link preview
Update the Pages preview with the current OAM browser and issue 346 share-link change.
1 parent a0c32f5 commit d32f9c4

15 files changed

Lines changed: 248 additions & 150 deletions

File tree

799 KB
Loading

‎frontend/src/App.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export default function App() {
1111
// subdirectory (a preview build on GitHub Pages) as well as from the root.
1212
// BASE_URL is "/" in production, where this is a no-op.
1313
const base = import.meta.env.BASE_URL.replace(/\/+$/, "");
14-
const path = window.location.pathname
15-
.replace(new RegExp(`^${base}`), "")
16-
.replace(/\/+$/, "");
14+
const path = window.location.pathname.replace(new RegExp(`^${base}`), "").replace(/\/+$/, "");
1715
if (path === "/browse" || path.startsWith("/browse/")) {
1816
return (
1917
<Suspense

‎frontend/src/Contribute.tsx‎

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ const CHECKS: { q: string; why: string; href?: string }[] = [
8181
why: "URLs that keep pointing at the same file, so the index stays correct.",
8282
},
8383
{
84-
q: "Acquisition dates",
85-
why: "Often missing, and hard to add later. Map data is dated from the imagery it came from.",
84+
q: "Basic metadata per image",
85+
href: DOCS_SCHEMA,
86+
why: "Acquisition date, sensor or platform, provider and license. A STAC catalog is preferred and read as-is; other formats are mapped.",
8687
},
8788
{
88-
q: "Resolution",
89-
why: "Buildings and roads are traceable below about 70 cm. Most mapping uses 35 to 50 cm.",
89+
q: "Resolution fit for mapping",
90+
why: "Detailed enough to trace buildings and roads: drone imagery at a few centimetres per pixel, satellite imagery at 30 to 50 cm.",
9091
},
9192
{
9293
q: "An open license",
@@ -103,9 +104,7 @@ export default function Contribute() {
103104
<section className="contribute-hero">
104105
<div className="contribute-shell">
105106
<p className="contribute-eyebrow">Contribute imagery</p>
106-
<h1 className="contribute-title">
107-
Add your imagery to OpenAerialMap
108-
</h1>
107+
<h1 className="contribute-title">Add your imagery to OpenAerialMap</h1>
109108
<p className="contribute-lede">
110109
OpenAerialMap is an open service providing access to a commons of openly licensed
111110
satellite and drone imagery. Providers host their own data and maintain their own
@@ -201,8 +200,8 @@ export default function Contribute() {
201200
<section className="contribute-shell contribute-block">
202201
<h2 className="contribute-h2">Matching your metadata fields</h2>
203202
<p className="contribute-lead">
204-
Catalogs use different names for the same things. OAM translates them when it reads
205-
your catalog. Your own metadata stays as it is.
203+
Catalogs use different names for the same things. OAM translates them when it reads your
204+
catalog. Your own metadata stays as it is.
206205
</p>
207206
<figure className="contribute-figure">
208207
<div className="contribute-figure-scroll">
@@ -257,10 +256,10 @@ export default function Contribute() {
257256
</a>
258257
</span>
259258
))}{" "}
260-
are indexed today. CC0, ODbL and other standard
261-
open licenses are accepted too, but are not implemented yet; support for them is coming.
262-
A custom open data license can also be added, as long as it maps onto one of the standard
263-
ones so the catalog can filter and publish it consistently.
259+
are indexed today. CC0, ODbL and other standard open licenses are accepted too, but are
260+
not implemented yet; support for them is coming. A custom open data license can also be
261+
added, as long as it maps onto one of the standard ones so the catalog can filter and
262+
publish it consistently.
264263
</p>
265264

266265
<h3 className="contribute-h3">Tracing into OpenStreetMap</h3>
@@ -272,10 +271,10 @@ export default function Contribute() {
272271
<p className="contribute-lead">
273272
A short written permission alongside the license solves this. Some satellite imagery
274273
providers publish their open data as CC-BY-NC 4.0 and add written permission to trace it
275-
into OpenStreetMap, so volunteers can map buildings and roads during a response while the
276-
commercial terms hold everywhere else. Any provider can add the same permission to any
277-
license. It is optional and it changes nothing else about how the imagery is indexed or
278-
credited.
274+
into OpenStreetMap, so volunteers can map buildings and roads during a response while
275+
the commercial terms hold everywhere else. Any provider can add the same permission to
276+
any license. It is optional and it changes nothing else about how the imagery is indexed
277+
or credited.
279278
</p>
280279
<p className="contribute-note">
281280
Every item carries your attribution, shown wherever the imagery appears. You set the
@@ -290,15 +289,19 @@ export default function Contribute() {
290289
The form asks everything needed to index a catalog.
291290
</p>
292291
<div className="contribute-actions">
293-
<a className="contribute-cta-button" href={INTAKE_URL} target="_blank" rel="noopener noreferrer">
292+
<a
293+
className="contribute-cta-button"
294+
href={INTAKE_URL}
295+
target="_blank"
296+
rel="noopener noreferrer"
297+
>
294298
Open an intake ticket
295299
</a>
296300
</div>
297301
<p className="contribute-cta-note">
298-
Contributing files rather than a catalog? The{" "}
299-
<a href={UPLOADER_URL}>uploader</a> needs no ticket. If a public tracker will not work
300-
for your organization, write to <a href={`mailto:${CONTACT}`}>{CONTACT}</a> and tell
301-
us which route applies.
302+
Contributing files rather than a catalog? The <a href={UPLOADER_URL}>uploader</a>{" "}
303+
needs no ticket. If a public tracker will not work for your organization, write to{" "}
304+
<a href={`mailto:${CONTACT}`}>{CONTACT}</a> and tell us which route applies.
302305
</p>
303306
</div>
304307
</section>

‎frontend/src/Landing.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useEffect, useState } from "react";
2-
import SiteHeader, { appUrl } from "./SiteHeader";
2+
import SiteHeader from "./SiteHeader";
3+
import { appUrl } from "./appUrl";
34
import {
45
PACKAGER_URL,
56
STAC_BROWSER_CATALOG_URL,
@@ -207,9 +208,8 @@ export default function Landing() {
207208
</wa-button>
208209
</div>
209210
<p className="landing-hero-note">
210-
Have imagery to share?{" "}
211-
<a href={appUrl("/contribute")}>See the ways to contribute</a>, from single files to
212-
a catalog.
211+
Have imagery to share? <a href={appUrl("/contribute")}>See the ways to contribute</a>,
212+
from single files to a catalog.
213213
</p>
214214
</div>
215215
</section>

‎frontend/src/SiteHeader.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import { useEffect, useRef } from "react";
22

33
import { ANNOUNCEMENT_URL, API_URL, UPLOADER_URL } from "./browse/utils/constants";
4+
import { appUrl } from "./appUrl";
45

56
// Keep these tabs aligned with backend/uploader-api/app/templates/layout.html.
67

7-
// In-app paths have to be resolved against Vite's base, or they point at the
8-
// server root and 404 whenever the app is served from a subdirectory. BASE_URL
9-
// is "/" in production, so this is a no-op there.
10-
export function appUrl(path: string): string {
11-
return `${import.meta.env.BASE_URL.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
12-
}
13-
148
interface HeaderTab {
159
label: string;
1610
href?: string;

‎frontend/src/appUrl.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// In-app paths have to be resolved against Vite's base, or they point at the
2+
// server root and 404 whenever the app is served from a subdirectory. BASE_URL
3+
// is "/" in production, so this is a no-op there.
4+
//
5+
// Its own module rather than a second export from SiteHeader: react-refresh
6+
// requires a file exporting a component to export nothing else.
7+
export function appUrl(path: string): string {
8+
return `${import.meta.env.BASE_URL.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
9+
}

‎frontend/src/browse/Browse.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ export default function Browse() {
8181
setMapBounds(exactBounds);
8282
};
8383

84-
// Sources seen in the tiles so far. Accumulates rather than tracking the
85-
// current view, for two reasons: selecting a source filters `features` down
86-
// to that one source, which would otherwise collapse the chip to a single
87-
// option and strand the user with no way back; and panning to an area
88-
// covered by only one source should not make the others unselectable.
84+
// Accumulate collections so filtering and panning cannot remove source options.
8985
const handleCollectionsUpdate = (ids: string[]) => {
9086
setSeenCollections((prev) => {
9187
const next = new Set(prev);

‎frontend/src/browse/components/ImageCard.tsx‎

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,29 @@ export default function ImageCard({ feature, onSelect, isSelected }: Props) {
162162
};
163163

164164
const stop = (e: React.MouseEvent) => e.stopPropagation();
165-
const handleCopy = (e: React.MouseEvent, text: string, feedbackId: string) => {
165+
const handleCopy = async (e: React.MouseEvent, text: string, feedbackId: string) => {
166166
e.stopPropagation();
167-
navigator.clipboard.writeText(text);
168-
setCopyFeedback(feedbackId);
167+
try {
168+
await navigator.clipboard.writeText(text);
169+
setCopyFeedback(feedbackId);
170+
} catch {
171+
setCopyFeedback(`${feedbackId}-failed`);
172+
}
169173
setTimeout(() => setCopyFeedback(null), 2000);
170174
};
171175

176+
const copyLabel = (feedbackId: string, defaultLabel: string) => {
177+
if (copyFeedback === feedbackId) return "Copied!";
178+
if (copyFeedback === `${feedbackId}-failed`) return "Copy failed";
179+
return defaultLabel;
180+
};
181+
182+
const shareUrl = () => {
183+
const url = new URL(window.location.href);
184+
if (p.id) url.searchParams.set("selected_id", p.id);
185+
return url.toString();
186+
};
187+
172188
const handleOpenJosm = async (e: React.MouseEvent) => {
173189
e.stopPropagation();
174190
const url = tmsTemplate(p);
@@ -210,6 +226,13 @@ export default function ImageCard({ feature, onSelect, isSelected }: Props) {
210226
: "border-gray-100 bg-white hover:bg-gray-50 border-l-4 border-l-transparent"
211227
}`}
212228
>
229+
<span className="sr-only" aria-live="polite" aria-atomic="true">
230+
{copyFeedback
231+
? copyFeedback.endsWith("-failed")
232+
? `Could not copy the ${copyFeedback.startsWith("link") ? "link" : "TMS URL"}. Try again.`
233+
: `${copyFeedback === "link" ? "Link" : "TMS URL"} copied to clipboard.`
234+
: ""}
235+
</span>
213236
{isSelected && (
214237
// Prominent deselect affordance. When an image is selected the
215238
// map fades non-selected footprints, so the user needs an
@@ -263,9 +286,6 @@ export default function ImageCard({ feature, onSelect, isSelected }: Props) {
263286
<span className="truncate max-w-[130px]" title={p.provider}>
264287
{p.provider}
265288
</span>
266-
{/* Which STAC collection this item came from. Neutral grey rather
267-
than a per-source colour: sources are open-ended, so a colour
268-
scheme would need a palette entry for every new catalogue. */}
269289
<span
270290
className="ml-auto shrink-0 px-2 py-0.5 rounded-full border border-gray-200 bg-gray-50 text-[10px] font-medium tracking-wide text-gray-600 uppercase"
271291
title={`STAC source: ${p.collection}`}
@@ -310,15 +330,34 @@ export default function ImageCard({ feature, onSelect, isSelected }: Props) {
310330

311331
{isExpanded && (
312332
<div className="bg-gray-50 px-4 py-4 text-xs border-t border-gray-100 text-gray-600">
313-
<div className="mb-4 pb-3 border-b border-gray-200 space-y-2">
333+
<div className="mb-4 pb-3 border-b border-gray-200">
334+
<div className="flex items-center justify-between mb-2">
335+
<span className="text-[10px] font-semibold text-gray-400 uppercase tracking-wider">
336+
Image actions
337+
</span>
338+
<button
339+
type="button"
340+
className="flex items-center gap-1 text-xs font-semibold text-cyan-600 hover:text-cyan-700 transition-colors cursor-pointer"
341+
onClick={(e) => handleCopy(e, shareUrl(), "link")}
342+
>
343+
<wa-icon
344+
name="link"
345+
variant="solid"
346+
auto-width
347+
class="text-[11px]"
348+
aria-hidden="true"
349+
/>
350+
{copyLabel("link", "Copy link")}
351+
</button>
352+
</div>
314353
<div className="flex gap-2">
315354
<wa-button
316355
size="s"
317356
appearance="outlined"
318357
class="flex-1"
319358
onClick={(e) => handleCopy(e, tmsTemplate(p), "tms")}
320359
>
321-
{copyFeedback === "tms" ? "Copied!" : "Copy TMS"}
360+
{copyLabel("tms", "Copy TMS")}
322361
</wa-button>
323362
<wa-button size="s" appearance="outlined" class="flex-1" onClick={handleOpenId}>
324363
Open iD
@@ -327,7 +366,7 @@ export default function ImageCard({ feature, onSelect, isSelected }: Props) {
327366
Open JOSM
328367
</wa-button>
329368
</div>
330-
<div className="flex gap-2">
369+
<div className="flex gap-2 mt-2">
331370
<TilepackButton
332371
format="pmtiles"
333372
state={pmtilesState}

‎frontend/src/browse/components/Map.tsx‎

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ import {
2424
DEFAULT_ZOOM,
2525
} from "../utils/constants";
2626
import { readInitialView, writeView } from "../utils/url";
27-
import { buildFilter, densityCountExpr, matchesFilters } from "../utils/filters";
27+
import {
28+
buildFilter,
29+
densityCountExpr,
30+
isDensityCountApproximate,
31+
matchesFilters,
32+
} from "../utils/filters";
2833
import { transformFeature } from "../utils/format";
2934
import { bboxAreaKm2, getFullBbox, type BBox } from "../utils/geo";
3035
import { ItemBoundsCache, fetchItemBounds, getTmsUrl, thumbUrl } from "../utils/tiles";
@@ -42,10 +47,7 @@ interface Props {
4247
selectedFeature: ImageFeature | null;
4348
onSelect: (f: ImageFeature | null) => void;
4449
onFeaturesUpdate: (fs: ImageFeature[]) => void;
45-
// Collections present in the tile SOURCE, independent of the active layer
46-
// filter. Reported separately from onFeaturesUpdate because the rendered
47-
// features are already filtered, so they cannot tell the UI which other
48-
// sources exist to switch to.
50+
// Collection IDs available independently of the active filter.
4951
onCollectionsUpdate?: (ids: string[]) => void;
5052
searchBbox: BBox | null;
5153
onSearchArea: (bbox: BBox, center: [number, number], exactBounds: BBox) => void;
@@ -136,7 +138,7 @@ export default function OamMap({
136138
useEffect(() => {
137139
onFeaturesUpdateRef.current = onFeaturesUpdate;
138140
onCollectionsUpdateRef.current = onCollectionsUpdate;
139-
}, [onFeaturesUpdate]);
141+
}, [onFeaturesUpdate, onCollectionsUpdate]);
140142
useEffect(() => {
141143
filtersRef.current = filters;
142144
}, [filters]);
@@ -163,9 +165,6 @@ export default function OamMap({
163165
// triggers the Sidebar's built-in "Zoom in to see images" prompt.
164166
const emitVisibleFeatures = () => {
165167
if (!map.current || !onFeaturesUpdateRef.current) return;
166-
// Before the zoom gate: which sources exist is a different question from
167-
// which images are listable, and the answer must survive zooming out.
168-
emitSeenCollections();
169168
if (map.current.getZoom() < FOOTPRINT_MIN_ZOOM) {
170169
onFeaturesUpdateRef.current([]);
171170
return;
@@ -193,17 +192,10 @@ export default function OamMap({
193192
} catch (e) {
194193
console.error("Error querying rendered features:", e);
195194
}
196-
197195
};
198196

199-
// Which sources the catalogue holds, independent of zoom and of the active
200-
// filter. Read from two places because neither covers the whole zoom range:
201-
// footprints carry `collection` but only exist at FOOTPRINT_MIN_ZOOM and
202-
// above, and below that the density cells carry the same answer in their
203-
// per-source bucket keys. Without the second half the Source chip
204-
// disappears when you zoom out, which reads as the filter being broken.
205-
// querySourceFeatures ignores the layer filter, so both still see every
206-
// source in the loaded tiles while a source filter is active.
197+
// Read collections from footprints at high zoom and density buckets at low zoom.
198+
// querySourceFeatures is unaffected by layer filters.
207199
const emitSeenCollections = () => {
208200
if (!map.current || !onCollectionsUpdateRef.current) return;
209201
const ids = new Set<string>();
@@ -276,10 +268,14 @@ export default function OamMap({
276268
] as FilterSpecification);
277269
}
278270
if (map.current.getLayer("density-count")) {
279-
map.current.setLayoutProperty("density-count", "text-field", [
280-
"to-string",
281-
countExpr,
282-
] as unknown as maplibregl.DataDrivenPropertyValueSpecification<string>);
271+
const countText = isDensityCountApproximate(f)
272+
? ["concat", "up to ", ["to-string", countExpr]]
273+
: ["to-string", countExpr];
274+
map.current.setLayoutProperty(
275+
"density-count",
276+
"text-field",
277+
countText as unknown as maplibregl.DataDrivenPropertyValueSpecification<string>,
278+
);
283279
map.current.setFilter("density-count", [
284280
"all",
285281
["==", ["geometry-type"], "Point"],
@@ -642,6 +638,7 @@ export default function OamMap({
642638
});
643639

644640
map.current!.on("idle", () => {
641+
emitSeenCollections();
645642
emitVisibleFeatures();
646643
setMapZoom(map.current!.getZoom());
647644
setIdleTick((t) => t + 1);

0 commit comments

Comments
 (0)