|
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 |
| - |
14 |
| -### cogeo.xyz |
| 13 | +## User Guide |
15 | 14 |
|
16 |
| -Adds an `Open in cogeo.xyz` button that allows to open Cloud-Optimized GeoTiff (COG) files on <https://cogeo.xyz>. |
| 15 | +### Assets |
17 | 16 |
|
18 |
| -```js |
19 |
| -import CoGeoXyz from './src/actions/assets/CoGeoXyz.js'; |
20 |
| -export default { CoGeoXyz }; |
21 |
| -``` |
| 17 | +The following actions are available: |
22 | 18 |
|
23 |
| -### copc.io |
| 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>. |
24 | 27 |
|
25 |
| -Adds an `Open in copc.io` button that allows to open Cloud-Optimized Point Cloud (COPC) files on <https://viewer.copc.io>. |
26 |
| - |
27 |
| -```js |
28 |
| -import CopcViewer from './src/actions/assets/CopcViewer.js'; |
29 |
| -export default { CopcViewer }; |
30 |
| -``` |
| 28 | +All actions for assets are stored in the folder [`src/actions/assets`](../src/actions/assets) if you want to inspect them. |
31 | 29 |
|
32 |
| -### Felt (Assets) |
33 |
| - |
34 |
| -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: |
35 | 33 |
|
36 | 34 | ```js
|
37 | 35 | import Felt from './src/actions/assets/Felt.js';
|
38 |
| -export default { Felt }; |
39 | 36 | ```
|
40 | 37 |
|
41 |
| -### 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). |
42 | 41 |
|
43 |
| -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. |
44 | 43 |
|
45 | 44 | ```js
|
46 |
| -import GeoJsonIo from './src/actions/assets/GeoJsonIo.js'; |
47 |
| -export default { GeoJsonIo }; |
| 45 | +export default { |
| 46 | + OtherAction, |
| 47 | + Felt |
| 48 | +}; |
48 | 49 | ```
|
49 | 50 |
|
50 |
| -### OGC3dTiles |
51 |
| - |
52 |
| -Adds an `Open in Geofox.ai` button that allows to open OGC 3D Tiles files on <https://viewer.geofox.ai> or Cesium Sandcastle. |
53 |
| - |
54 |
| -```js |
55 |
| -import OGC3dTiles from './src/actions/assets/OGC3dTiles.js'; |
56 |
| -export default { OGC3dTiles }; |
57 |
| -``` |
| 51 | +Save the file and restart / rebuild STAC Browser. |
58 | 52 |
|
59 |
| -### geoparquet.info |
| 53 | +### Links |
60 | 54 |
|
61 |
| -Adds an `Open in geoparquet.info` button that allows to open GeoParquet files on <https://geoparquet.info>. |
| 55 | +The following actions are available: |
62 | 56 |
|
63 |
| -```js |
64 |
| -import Geoparquet from './src/actions/assets/Geoparquet.js'; |
65 |
| -export default { Geoparquet }; |
66 |
| -``` |
| 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>. |
67 | 61 |
|
68 |
| -### potree.org |
| 62 | +All actions for assets are stored in the folder [`src/actions/links`](../src/actions/links) if you want to inspect them. |
69 | 63 |
|
70 |
| -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: |
71 | 67 |
|
72 | 68 | ```js
|
73 |
| -import Potree from './src/actions/assets/Potree.js'; |
74 |
| -export default { Potree }; |
| 69 | +import Protomaps from './src/actions/links/Protomaps.js'; |
75 | 70 | ```
|
76 | 71 |
|
77 |
| -### 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). |
78 | 75 |
|
79 |
| -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. |
80 | 77 |
|
81 | 78 | ```js
|
82 |
| -import Protomaps from './src/actions/assets/Protomaps.js'; |
83 |
| -export default { Protomaps }; |
| 79 | +export default { |
| 80 | + OtherAction, |
| 81 | + Protomaps |
| 82 | +}; |
84 | 83 | ```
|
85 | 84 |
|
| 85 | +Save the file and rebuild / restart STAC Browser. |
86 | 86 |
|
| 87 | +## Developer Guide |
87 | 88 |
|
88 |
| -## 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). |
89 | 92 |
|
90 |
| -All actions for links are stored in the folder [`src/actions/links`](../src/actions/links). |
91 |
| -They all implement the [`LinkActionPlugin` interface](../src/actions/LinkActionPlugin.js). |
92 |
| -The actions can be enabled by adding them to the [`linkActions.config.js`](../linkActions.config.js) file. |
| 93 | +The interfaces for both look as follows: |
93 | 94 |
|
94 |
| -### Felt (Links) |
| 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`. |
95 | 111 |
|
96 |
| -Adds an `Open in Felt` button that allows to show XYZ tile services on <https://felt.com>. |
97 |
| -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). |
| 112 | +Each action should at least implement custom behaviour for `uri`, `show` and `text`. |
98 | 113 |
|
99 |
| -```js |
100 |
| -import Felt from './src/actions/links/Felt.js'; |
101 |
| -export default { Felt }; |
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 |
| -### pmtiles.io |
| 116 | +Some notes: |
105 | 117 |
|
106 |
| -Adds an `Open in pmtiles.io` button that allows to open Protomaps PMTiles files on <https://pmtiles.io>. |
| 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 Protomaps from './src/actions/assets/Protomaps.js'; |
110 |
| -export default { Protomaps }; |
111 |
| -``` |
112 |
| - |
113 |
| -### OGC3dTiles |
114 |
| - |
115 |
| -Adds an `Open in Geofox.ai` button that allows to open OGC 3D Tiles files on <https://viewer.geofox.ai> or Cesium Sandcastle. |
116 |
| - |
117 |
| -```js |
118 |
| -import OGC3dTiles from './src/actions/assets/OGC3dTiles.js'; |
119 |
| -export default { OGC3dTiles }; |
120 |
| -``` |
| 124 | +To enable a newly implemented action in STAC Browser, please follow the [User Guide](#user-guide). |
0 commit comments