|
1 | | -# Actions |
| 1 | +# Actions <!-- omit in toc --> |
2 | 2 |
|
3 | 3 | STAC Browser has a pluggable interface to share or open assets and links with other services, which we call "actions". |
4 | 4 |
|
5 | 5 | An action adds a button to an asset or link if certain requirements are met, which can then be executed by users. |
6 | 6 | For example, you could open COPC files in a dedicated COPC Viewer, which otherwise you could only download. |
7 | 7 |
|
8 | | -## Assets |
| 8 | +- [User Guide](#user-guide) |
| 9 | + - [Assets](#assets) |
| 10 | + - [Links](#links) |
| 11 | +- [Developer Guide](#developer-guide) |
9 | 12 |
|
10 | | -All actions for assets are stored in the folder [`src/actions/assets`](../src/actions/assets). |
11 | | -They all implement the [`AssetActionPlugin` interface](../src/actions/AssetActionPlugin.js). |
12 | | -The actions can be enabled by adding them to the [`assetActions.config.js`](../assetActions.config.js) file. |
| 13 | +## User Guide |
13 | 14 |
|
14 | | -### copc.io |
| 15 | +### Assets |
15 | 16 |
|
16 | | -Adds an `Open in copc.io` button that allows to open Cloud-Optimized Point Cloud (COPC) files on <https://viewer.copc.io>. |
| 17 | +The following actions are available: |
17 | 18 |
|
18 | | -```js |
19 | | -import CopcViewer from './src/actions/assets/CopcViewer.js'; |
20 | | -export default { CopcViewer }; |
21 | | -``` |
| 19 | +- `Cesium`: Allows to open OGC 3D Tiles (media type `application/3dtiles+json`) files through the Cesium Sandcastle at <https://sandcastle.cesium.com>. |
| 20 | +- `CopcViewer`: Allows to open Cloud-Optimized Point Cloud (COPC, media type `application/vnd.laszip+copc`) files through the Hobu COPC Viewer at <https://viewer.copc.io>. |
| 21 | +- `F3D`: Allows to open 3D models (media types `model/gltf-binary`, `model/gltf+json`, and `application/fbx`) files through the F3D Web App at <https://f3d.app/web>. |
| 22 | +- `Felt`: Allows to open GeoTIFF, GeoJON and KML/KMZ files through Felt at <https://felt.com/map/>. |
| 23 | +- `Geofox`: Allows to open OGC 3D Tiles (media type `application/3dtiles+json`) files through the 3D Assets Viewer at <https://viewer.geofox.ai>. |
| 24 | +- `GeoJsonIo`: Allows to open GeoJON files through [geojson.io](https://geojson.io). |
| 25 | +- `Potree`: Allows to open Cloud-Optimized Point Cloud (COPC, media type `application/vnd.laszip+copc`) and Potree files (file names `cloud.js`, `metadata.json`, `ept.json`) files through the Potree Viewer at <https://3d.iconem.com/apps/load_potree_project_from_urlparam/>. |
| 26 | +- `Protomaps`: Allows to open PMTiles (media type `application/vnd.pmtiles`) files through PMTiles Viewer at <https://pmtiles.io>. |
22 | 27 |
|
23 | | -### Felt (Assets) |
| 28 | +All actions for assets are stored in the folder [`src/actions/assets`](../src/actions/assets) if you want to inspect them. |
24 | 29 |
|
25 | | -Adds an `Open in Felt` button that allows to import KML, KMZ, GeoTiff and GeoJSON assets to <https://felt.com>. |
| 30 | +The actions can be enabled by adding them to the [`assetActions.config.js`](../assetActions.config.js) file. |
| 31 | +Open the file and you'll see a number of imports and exports. |
| 32 | +Import the file for the action that you want to enable, e.g. for Felt: |
26 | 33 |
|
27 | 34 | ```js |
28 | 35 | import Felt from './src/actions/assets/Felt.js'; |
29 | | -export default { Felt }; |
30 | 36 | ``` |
31 | 37 |
|
32 | | -### geojson.io |
| 38 | +The path is fixed to `./src/actions/assets/`, the file extension is always `.js`. |
| 39 | +In-between add the file name from the list above. |
| 40 | +The import name should be the file name without extension (i.e. `Felt` again). |
33 | 41 |
|
34 | | -Adds an `Open in geojson.io` button that allows to open GeoJSON files on <https://geojson.io>. |
| 42 | +Lastly, add the import name to the list of exports, e.g. |
35 | 43 |
|
36 | 44 | ```js |
37 | | -import GeoJsonIo from './src/actions/assets/GeoJsonIo.js'; |
38 | | -export default { GeoJsonIo }; |
| 45 | +export default { |
| 46 | + OtherAction, |
| 47 | + Felt |
| 48 | +}; |
39 | 49 | ``` |
40 | 50 |
|
41 | | -### OGC3dTiles |
| 51 | +Save the file and restart / rebuild STAC Browser. |
42 | 52 |
|
43 | | -Adds an `Open in Geofox.ai` button that allows to open OGC 3D Tiles files on <https://viewer.geofox.ai> or Cesium Sandcastle. |
| 53 | +### Links |
44 | 54 |
|
45 | | -```js |
46 | | -import OGC3dTiles from './src/actions/assets/OGC3dTiles.js'; |
47 | | -export default { OGC3dTiles }; |
48 | | -``` |
| 55 | +The following actions are available: |
49 | 56 |
|
50 | | -### geoparquet.info |
| 57 | +- `Cesium`: Allows to open OGC 3D Tiles (relation type `3d-tiles`, see [web-map-links extension](https://github.com/stac-extensions/web-map-links/blob/v1.2.0/README.md#3d-tiles)) files through the Cesium Sandcastle at <https://sandcastle.cesium.com>. |
| 58 | +- `Felt`: Allows to open XYZ tile services (relation type `xyz`, see [web-map-links extension](https://github.com/stac-extensions/web-map-links/blob/v1.2.0/README.md#xyz)) files through Felt at <https://felt.com/map/>. |
| 59 | +- `Geofox`: Allows to open OGC 3D Tiles (relation type `3d-tiles`, see [web-map-links extension](https://github.com/stac-extensions/web-map-links/blob/v1.2.0/README.md#3d-tiles)) files through the 3D Assets Viewer at <https://viewer.geofox.ai>. |
| 60 | +- `Protomaps`: Allows to open PMTiles (relation type `pmtiles`, see [web-map-links extension](https://github.com/stac-extensions/web-map-links/blob/v1.2.0/README.md#pmtiles)) files through PMTiles Viewer at <https://pmtiles.io>. |
51 | 61 |
|
52 | | -Adds an `Open in geoparquet.info` button that allows to open GeoParquet files on <https://geoparquet.info>. |
| 62 | +All actions for assets are stored in the folder [`src/actions/links`](../src/actions/links) if you want to inspect them. |
53 | 63 |
|
54 | | -```js |
55 | | -import Geoparquet from './src/actions/assets/Geoparquet.js'; |
56 | | -export default { Geoparquet }; |
57 | | -``` |
58 | | - |
59 | | -### potree.org |
60 | | - |
61 | | -Adds an `Open in potree.org` button that allows to open COPC and Potree files on <https://potree.org> (via [Darren Wiens](https://mpc-copc-viewer.netlify.app) or [Iconem](https://3d.iconem.com/apps/load_potree_project_from_urlparam) apps) |
| 64 | +The actions can be enabled by adding them to the [`linkActions.config.js`](../linkActions.config.js) file. |
| 65 | +Open the file and you'll see a number of imports and exports. |
| 66 | +Import the file for the action that you want to enable, e.g. for PMTiles / Protomaps: |
62 | 67 |
|
63 | 68 | ```js |
64 | | -import Potree from './src/actions/assets/Potree.js'; |
65 | | -export default { Potree }; |
| 69 | +import Protomaps from './src/actions/links/Protomaps.js'; |
66 | 70 | ``` |
67 | 71 |
|
68 | | -### pmtiles.io |
| 72 | +The path is fixed to `./src/actions/links/`, the file extension is always `.js`. |
| 73 | +In-between add the file name from the list above. |
| 74 | +The import name should be the file name without extension (i.e. `Protomaps` again). |
69 | 75 |
|
70 | | -Adds an `Open in pmtiles.io` button that allows to open Protomaps PMTiles files on <https://pmtiles.io>. |
| 76 | +Lastly, add the import name to the list of exports, e.g. |
71 | 77 |
|
72 | 78 | ```js |
73 | | -import Protomaps from './src/actions/assets/Protomaps.js'; |
74 | | -export default { Protomaps }; |
| 79 | +export default { |
| 80 | + OtherAction, |
| 81 | + Protomaps |
| 82 | +}; |
75 | 83 | ``` |
76 | 84 |
|
| 85 | +Save the file and rebuild / restart STAC Browser. |
77 | 86 |
|
| 87 | +## Developer Guide |
78 | 88 |
|
79 | | -## Links |
| 89 | +Implementing actions for assets and links follows a very similar pattern. |
| 90 | +The main difference is that assets implement the [`AssetActionPlugin` interface](../src/actions/AssetActionPlugin.js) while links implement the [`LinkActionPlugin` interface](../src/actions/LinkActionPlugin.js). |
| 91 | +Similarly, actions for assets are stored in the folder links are stored in the folder [`src/actions/assets`](../src/actions/assets) while links are stored in the folder [`src/actions/links`](../src/actions/links). |
80 | 92 |
|
81 | | -All actions for links are stored in the folder [`src/actions/links`](../src/actions/links). |
82 | | -They all implement the [`LinkActionPlugin` interface](../src/actions/LinkActionPlugin.js). |
83 | | -The actions can be enabled by adding them to the [`linkActions.config.js`](../linkActions.config.js) file. |
84 | | - |
85 | | -### Felt (Links) |
86 | | - |
87 | | -Adds an `Open in Felt` button that allows to show XYZ tile services on <https://felt.com>. |
88 | | -The link to the XYZ has to follow the [web-map-links extension](https://github.com/stac-extensions/web-map-links/blob/v1.0.0/README.md#xyz). |
89 | | - |
90 | | -```js |
91 | | -import Felt from './src/actions/links/Felt.js'; |
92 | | -export default { Felt }; |
93 | | -``` |
| 93 | +The interfaces for both look as follows: |
94 | 94 |
|
95 | | -### pmtiles.io |
| 95 | +- `constructor(data: object, component: Vue, id: string)` |
| 96 | + - `data`: The asset or link object, it is available in the class throuh `this.asset` (for assets) and `this.link` (for links). |
| 97 | + - `component`: The parent Asset/Link Vue component (available in the class through `this.component`) |
| 98 | + - `id`: Internal ID of the asset or link, not meant to be used. |
| 99 | +- `get btnOptions() : object` |
| 100 | + - This should return an object of button options, see [VueBootstrap b-button](https://bootstrap-vue.org/docs/components/button/#component-reference) for details. Returns `href`, `rel` (only for links) and `target` (set to `_blank`) by default. |
| 101 | +- `get onClick() : function(event: MouseEvent)` |
| 102 | + - Returns a function that accepts a [MouseEvent](https://developer.mozilla.org/de/docs/Web/API/MouseEvent). This is the action to execute in case no `href` is set. |
| 103 | +- `get uri() : string` |
| 104 | + - Reurns the URL to use as `href` for the button/link. This should a valid URL that a browser can navigate to, including the asset or link URL as a query parameter or so. |
| 105 | +- `get show() : boolean` |
| 106 | + - Return `true` if the action should be shown for the given asset or link. Return `false` otherwise, default to `false`. |
| 107 | +- `get text() : string` |
| 108 | + - Returns the text that is displayed for the button, defaults to "Open". Should be using the [i18n methods](https://kazupon.github.io/vue-i18n/api/#methods) to localize the text. |
| 109 | +- `get icon() : Vue` |
| 110 | + - Returns a Vue component that should be the icon for the button. Defaults to `BIconBoxArrowUpRight`, see <https://bootstrap-vue.org/docs/icons#icons-1> and search for `arrow-up-right`. |
96 | 111 |
|
97 | | -Adds an `Open in pmtiles.io` button that allows to open Protomaps PMTiles files on <https://pmtiles.io>. |
| 112 | +Each action should at least implement custom behaviour for `uri`, `show` and `text`. |
98 | 113 |
|
99 | | -```js |
100 | | -import Protomaps from './src/actions/assets/Protomaps.js'; |
101 | | -export default { Protomaps }; |
102 | | -``` |
| 114 | +It is recommended to inspect the existing actions to get an impression of what is possible and how it is implemented. |
103 | 115 |
|
104 | | -### OGC3dTiles |
| 116 | +Some notes: |
105 | 117 |
|
106 | | -Adds an `Open in Geofox.ai` button that allows to open OGC 3D Tiles files on <https://viewer.geofox.ai> or Cesium Sandcastle. |
| 118 | +- It is recommended to use [urijs](https://www.npmjs.com/package/urijs) for URL manipulations, it comes packages with STAC Browser anyway. |
| 119 | +- It can be helpful to use the Vue component that is available through `this.component`, for example: |
| 120 | + - `this.component.href` is the absolute asset URL (while `this.asset.href` could be relative or absolute) |
| 121 | + - `this.component.isBrowserProtocol` returns whether it's a http/https URL |
| 122 | + - `this.asset.type` / `this.link.type` contains the media type of the asset/link |
107 | 123 |
|
108 | | -```js |
109 | | -import OGC3dTiles from './src/actions/assets/OGC3dTiles.js'; |
110 | | -export default { OGC3dTiles }; |
111 | | -``` |
| 124 | +To enable a newly implemented action in STAC Browser, please follow the [User Guide](#user-guide). |
0 commit comments