@osm-editor-kit/street-imagery-react 0.1.0-alpha.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +113 -8
- package/dist/MapillaryPanel-SOHGB7JA.js +3 -0
- package/dist/PanoramaxPanel-5P5LWMRY.js +3 -0
- package/dist/StreetLevelImageryViewer.d.ts +18 -4
- package/dist/{chunk-6EMFFIL2.js → chunk-3DFVM6VK.js} +57 -13
- package/dist/{chunk-25UGGXIE.js → chunk-GYUS2JVV.js} +24 -4
- package/dist/chunk-LZR5SZDS.js +498 -0
- package/dist/chunk-R6BDVYWM.js +665 -0
- package/dist/chunk-XLBFXACK.js +56 -0
- package/dist/filters/PhotoDateRangeFilter.d.ts +4 -1
- package/dist/filters/dateSliderPointer.d.ts +21 -0
- package/dist/hooks/useMapViewportBbox.d.ts +3 -5
- package/dist/hooks/useProviderData.d.ts +9 -3
- package/dist/index.d.ts +11 -10
- package/dist/index.js +3921 -1558
- package/dist/mapillary/useMapillaryFeatures.d.ts +5 -5
- package/dist/panels/MapillaryPanel.d.ts +7 -2
- package/dist/panels/PanoramaxPanel.d.ts +16 -9
- package/dist/panels/PanoramaxWebViewerPanel.d.ts +25 -0
- package/dist/panels/panoramaxDataProvider.d.ts +44 -0
- package/dist/panels/panoramaxItem.d.ts +98 -0
- package/dist/panels/photoView.d.ts +19 -0
- package/dist/panoramax-web-viewer/index.d.ts +1 -0
- package/dist/{chunk-KZTMKQT5.js → panoramax-web-viewer.js} +299 -93
- package/dist/photo-details.js +222 -151
- package/dist/viewer-panels/index.d.ts +3 -1
- package/dist/viewer-panels.js +4 -3
- package/dist/viewpoints/FloatingPhotoViewer.d.ts +22 -7
- package/dist/viewpoints/floatingViewerPosition.d.ts +18 -0
- package/dist/viewpoints/usePhotosLookingAt.d.ts +26 -0
- package/package.json +24 -6
- package/dist/MapillaryPanel-FAXVZH37.js +0 -2
- package/dist/PanoramaxPanel-BTHEMKYY.js +0 -2
- package/dist/chunk-SGIB7AVC.js +0 -309
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/panels/photoView.ts
|
|
2
|
+
var REPORT_DELAY_MS = 200;
|
|
3
|
+
var PANORAMAX_MIN_FOV = 5;
|
|
4
|
+
var PANORAMAX_MAX_FOV = 90;
|
|
5
|
+
var tanOfHalf = (degrees) => Math.tan(degrees * Math.PI / 360);
|
|
6
|
+
var panoramaxZoomLevel = (verticalFov, horizontalFovOfPicture) => {
|
|
7
|
+
const maxFov = Math.min(horizontalFovOfPicture * 3 / 4, PANORAMAX_MAX_FOV);
|
|
8
|
+
const fov = horizontalFovOfPicture >= 360 ? verticalFov : tanOfHalf(verticalFov) / tanOfHalf(horizontalFovOfPicture) * horizontalFovOfPicture;
|
|
9
|
+
const level = (maxFov - fov) / (maxFov - PANORAMAX_MIN_FOV) * 100;
|
|
10
|
+
return Math.min(100, Math.max(0, level));
|
|
11
|
+
};
|
|
12
|
+
var viewKey = (view) => JSON.stringify(view, (_, value) => typeof value === "number" ? Number(value.toFixed(4)) : value);
|
|
13
|
+
var createPhotoViewReporter = (read, report, delayMs = REPORT_DELAY_MS) => {
|
|
14
|
+
let timer;
|
|
15
|
+
let last = null;
|
|
16
|
+
let stopped = false;
|
|
17
|
+
const send = () => {
|
|
18
|
+
void read().then((view) => {
|
|
19
|
+
if (view && !stopped && viewKey(view) !== last) {
|
|
20
|
+
last = viewKey(view);
|
|
21
|
+
report(view);
|
|
22
|
+
}
|
|
23
|
+
}).catch(() => {
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
viewChanged: () => {
|
|
28
|
+
clearTimeout(timer);
|
|
29
|
+
timer = setTimeout(send, delayMs);
|
|
30
|
+
},
|
|
31
|
+
stop: () => {
|
|
32
|
+
stopped = true;
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var watchMapillaryJsView = (viewer, read, report) => {
|
|
38
|
+
const reporter = createPhotoViewReporter(read, report);
|
|
39
|
+
const {
|
|
40
|
+
viewChanged
|
|
41
|
+
} = reporter;
|
|
42
|
+
viewer.on("image", viewChanged);
|
|
43
|
+
viewer.on("pov", viewChanged);
|
|
44
|
+
viewer.on("fov", viewChanged);
|
|
45
|
+
viewer.on("moveend", viewChanged);
|
|
46
|
+
viewChanged();
|
|
47
|
+
return () => {
|
|
48
|
+
reporter.stop();
|
|
49
|
+
viewer.off("image", viewChanged);
|
|
50
|
+
viewer.off("pov", viewChanged);
|
|
51
|
+
viewer.off("fov", viewChanged);
|
|
52
|
+
viewer.off("moveend", viewChanged);
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { createPhotoViewReporter, panoramaxZoomLevel, watchMapillaryJsView };
|
|
@@ -10,7 +10,10 @@ export type PhotoDateMarker = {
|
|
|
10
10
|
export type PhotoDateRangeFilterProps = {
|
|
11
11
|
/** The chosen range, days as `YYYY-MM-DD`. No `from` and no `to`: all dates. */
|
|
12
12
|
value: DateRange;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Called when a handle is released, the chart is clicked, a year label is clicked or a date
|
|
15
|
+
* input changes.
|
|
16
|
+
*/
|
|
14
17
|
onChange: (range: DateRange) => void;
|
|
15
18
|
/**
|
|
16
19
|
* Capture times (ms) of the photos to show as marks above the slider, usually all photos in
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DateSliderPositions } from '@osm-editor-kit/street-imagery';
|
|
2
|
+
export type DateSliderHandle = 'from' | 'to';
|
|
3
|
+
/** Size of one step of the slider, in positions: about a day to a month, depending on the age. */
|
|
4
|
+
export declare const DATE_SLIDER_STEP = 0.001;
|
|
5
|
+
/** The handles as they show. */
|
|
6
|
+
export declare const HANDLE_PX = 16;
|
|
7
|
+
/** Position of a point `leftPx` from the start of the track, in steps like the native handles. */
|
|
8
|
+
export declare const positionOnTrack: (leftPx: number, widthPx: number) => number;
|
|
9
|
+
/**
|
|
10
|
+
* The handle a press takes. `null` when the handles overlap under the press: they can only move
|
|
11
|
+
* apart, so the direction of the drag decides (`handleOfDrag`), also when both are at one end.
|
|
12
|
+
*/
|
|
13
|
+
export declare const pressedHandle: (positions: DateSliderPositions, press: number, widthPx: number) => DateSliderHandle | null;
|
|
14
|
+
export declare const handleOfDrag: (deltaPx: number) => DateSliderHandle;
|
|
15
|
+
/** A drag keeps the distance between a grabbed handle and the pointer: the handle does not jump. */
|
|
16
|
+
export declare const dragPositions: (start: DateSliderPositions, press: number, handle: DateSliderHandle, deltaPx: number, widthPx: number) => DateSliderPositions;
|
|
17
|
+
/** A click or tap moves the nearer handle there, or does nothing on a handle itself. */
|
|
18
|
+
export declare const tapPositions: (start: DateSliderPositions, press: number, widthPx: number) => {
|
|
19
|
+
handle: DateSliderHandle;
|
|
20
|
+
positions: DateSliderPositions | null;
|
|
21
|
+
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Bbox } from '@osm-editor-kit/street-imagery';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* WGS84 bbox of a react-map-gl map, updated when a move of the map ends. The array stays the same
|
|
4
|
+
* object while the viewport is the same, so it works as a dependency and as a prop.
|
|
4
5
|
* @param mapId - react-map-gl `<Map id=…>`
|
|
5
|
-
* @param viewportTrigger - optional value that changes when the camera moves
|
|
6
|
-
* (e.g. URL map param) so the bbox recomputes after pan/zoom without relying
|
|
7
|
-
* on MapLibre events.
|
|
8
6
|
*/
|
|
9
|
-
export declare const useMapViewportBbox: (mapId: string
|
|
7
|
+
export declare const useMapViewportBbox: (mapId: string) => Bbox | null;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { Bbox } from '@osm-editor-kit/street-imagery';
|
|
2
2
|
import { type ProviderId } from '@osm-editor-kit/street-imagery';
|
|
3
|
+
import { keepPreviousData } from '@tanstack/react-query';
|
|
4
|
+
/**
|
|
5
|
+
* Keeps the last result on screen while the next viewport loads. Only while the query is on:
|
|
6
|
+
* a query that is off (provider turned off, zoomed out too far) would show that result forever.
|
|
7
|
+
*/
|
|
8
|
+
export declare const previousDataWhile: (enabled: boolean) => typeof keepPreviousData | undefined;
|
|
3
9
|
/** Host limit on top of the provider's own minimum zooms: below it nothing is requested. */
|
|
4
10
|
type ProviderDataOptions = {
|
|
5
11
|
minZoom?: number;
|
|
6
12
|
};
|
|
7
|
-
export declare const useProviderPhotos: (providerId: ProviderId, bbox: Bbox | null, zoom: number, { minZoom }?: ProviderDataOptions) => import("@tanstack/react-query").UseQueryResult<
|
|
8
|
-
export declare const useProviderSequences: (providerId: ProviderId, bbox: Bbox | null, zoom: number, { minZoom }?: ProviderDataOptions) => import("@tanstack/react-query").UseQueryResult<
|
|
9
|
-
export declare const useProviderMapFeatures: (providerId: ProviderId, bbox: Bbox | null, zoom: number, { minZoom }?: ProviderDataOptions) => import("@tanstack/react-query").UseQueryResult<
|
|
13
|
+
export declare const useProviderPhotos: (providerId: ProviderId, bbox: Bbox | null, zoom: number, { minZoom }?: ProviderDataOptions) => import("@tanstack/react-query").UseQueryResult<import("@osm-editor-kit/street-imagery").NormalizedPhoto[], Error>;
|
|
14
|
+
export declare const useProviderSequences: (providerId: ProviderId, bbox: Bbox | null, zoom: number, { minZoom }?: ProviderDataOptions) => import("@tanstack/react-query").UseQueryResult<import("@osm-editor-kit/street-imagery").NormalizedSequence[], Error>;
|
|
15
|
+
export declare const useProviderMapFeatures: (providerId: ProviderId, bbox: Bbox | null, zoom: number, { minZoom }?: ProviderDataOptions) => import("@tanstack/react-query").UseQueryResult<import("@osm-editor-kit/street-imagery").NormalizedMapFeature[], Error>;
|
|
10
16
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,21 +4,22 @@ export { StreetLevelImageryViewCone, VIEW_SHAPE_FILL_OPACITY } from './StreetLev
|
|
|
4
4
|
export { StreetLevelImageryViewer } from './StreetLevelImageryViewer';
|
|
5
5
|
export type { StreetImageryPhotoSelection } from './types';
|
|
6
6
|
export { queryStreetImageryFeatures, streetImageryInteractiveLayerIds, type StreetImageryClickFeature, } from './streetImageryClick';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
7
|
+
export { useAllProviderMapFeatures } from './hooks/useAllProviderMapFeatures';
|
|
8
|
+
export { useAllProviderPhotos, type AllProviderPhotosResult } from './hooks/useAllProviderPhotos';
|
|
9
|
+
export { useMapViewportBbox } from './hooks/useMapViewportBbox';
|
|
10
|
+
export { useProviderMapFeatures, useProviderPhotos, useProviderSequences, } from './hooks/useProviderData';
|
|
11
|
+
export { usePhotoFullUrl, usePhotoThumbnail } from './hooks/usePhotoThumbnails';
|
|
12
|
+
export { useViewerActions, useViewerBearing, useViewerHfov, useViewerLngLat, } from './useViewerStore';
|
|
13
13
|
export { FloatingPhotoViewer, FloatingViewerInfoButton, type FloatingPhotoViewerProps, } from './viewpoints/FloatingPhotoViewer';
|
|
14
14
|
export { VIEWPOINT_DEFAULT_COLOR, VIEWPOINT_DIRECTION_LAYER_ID, ViewpointLayer, viewDirectionKeyFromFeatures, type ViewpointLayerProps, } from './viewpoints/ViewpointLayer';
|
|
15
15
|
export { viewSuggestionLabel } from './viewpoints/viewDirectionLabels';
|
|
16
|
-
export
|
|
17
|
-
export
|
|
16
|
+
export { getViewpointSession, useActiveDirectionKey, useCanGoBack, useCanGoForward, useCurrentHistoryEntry, useViewpointLine, useViewpoints, type ViewpointHistoryEntry, } from './viewpoints/useViewpointSessionStore';
|
|
17
|
+
export { useViewSuggestions, type ViewSuggestionsOptions, type ViewSuggestionsResult, } from './viewpoints/useViewSuggestions';
|
|
18
|
+
export { usePhotosLookingAt, type PhotosLookingAtOptions, type PhotosLookingAtResult, } from './viewpoints/usePhotosLookingAt';
|
|
18
19
|
export type { MapillaryLookAt, MapillaryViewerOutline } from './panels/mapillaryLookAt';
|
|
19
|
-
export
|
|
20
|
+
export { useMapillaryImageDetections, useMapillaryMapFeatureImages, useMapillaryMapFeaturesNear, useSelectedMapillaryFeature, } from './mapillary/useMapillaryFeatures';
|
|
20
21
|
export { LocationPickOnMap, type LocationPickOnMapProps } from './openers/LocationPickOnMap';
|
|
21
|
-
export
|
|
22
|
+
export { useArmedLocationOpenerId, useLocationPickActions } from './openers/useLocationPickStore';
|
|
22
23
|
export { SelectedMapFeatureLayer, type SelectedMapFeatureLayerProps, } from './mapillary/SelectedMapFeatureLayer';
|
|
23
24
|
export { MapillaryFeatureBar, type MapillaryFeatureBarProps } from './mapillary/MapillaryFeatureBar';
|
|
24
25
|
export { MAPILLARY_FEATURE_BAR_LABELS, type MapillaryFeatureBarLabels, } from './mapillary/featureBarLabels';
|