forked from radiantearth/stac-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFelt.js
36 lines (31 loc) · 1.3 KB
/
Felt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import LinkActionPlugin from "../LinkActionPlugin";
import URI from 'urijs';
import i18n from "../../i18n";
export default class Felt extends LinkActionPlugin {
get show() {
// Docs: https://feltmaps.notion.site/Upload-Anything-b26d739e80184127872faa923b55d232#031104d5546b403bac111bca6685a225
// - Must end with file extension
// - Must contain x,y,z but not s variables
let valid = (this.link.rel === 'xyz' && this.link.href.match(/^(https?:\/\/)(.+)\.(png|jpeg|jpg)$/i));
if (valid) {
return !this.link.href.includes('{s}') || (Array.isArray(this.link['href:servers']) && this.link['href:servers'].length > 0);
}
return false;
}
get uri() {
// Docs: https://feltmaps.notion.site/Open-in-Felt-Button-22765a3427ff45e0a70218dca3f8acc0
let uri = new URI("https://felt.com/map/new");
let xyz = this.link.href;
if (xyz.includes('{s}' && Array.isArray(this.link['href:servers']) && this.link['href:servers'].length > 0)) {
xyz = xyz.replace('{s}', this.link['href:servers'][0]);
}
uri.addQuery('layer_urls[]', xyz);
// once we migrate to stac-js:
// todo: add title from STAC entity
// todo: add lat/lon from item/collection: lat=57.14926&lon=-2.09348
return uri;
}
get text() {
return i18n.t('actions.openIn', {service: 'Felt'});
}
}