@datagouv/components-next 0.2.0 → 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/README.md +1 -1
- package/assets/main.css +56 -1
- package/dist/Control-BNCDn-8E.js +148 -0
- package/dist/{Datafair.client-x39O4yfF.js → Datafair.client-Dls5AHTE.js} +1 -1
- package/dist/Event-BOgJUhNR.js +738 -0
- package/dist/Image-BN-4XkIn.js +247 -0
- package/dist/{JsonPreview.client-BMsC5JcY.js → JsonPreview.client-DPDTs433.js} +14 -14
- package/dist/Map-BdT3i2C4.js +7609 -0
- package/dist/MapContainer.client-BdAzd7bj.js +105 -0
- package/dist/OSM-CamriM9b.js +71 -0
- package/dist/{PdfPreview.client-COOkEkRA.js → PdfPreview.client-CopqSDyt.js} +3 -3
- package/dist/{Pmtiles.client-BaiIo4VZ.js → Pmtiles.client-mF6xaOO_.js} +2 -2
- package/dist/ScaleLine-BiesrgOv.js +165 -0
- package/dist/Swagger.client-eJ7gpfZA.js +4 -0
- package/dist/Tile-DCuqwNOI.js +1206 -0
- package/dist/TileImage-CmZf8EdU.js +1067 -0
- package/dist/View-DcDc7N2K.js +2858 -0
- package/dist/{XmlPreview.client-CAdN0w_Y.js → XmlPreview.client-C0OgBkSq.js} +7 -7
- package/dist/common-C4rDcQpp.js +243 -0
- package/dist/components-next.css +1 -1
- package/dist/components-next.js +153 -117
- package/dist/components.css +1 -1
- package/dist/{MapContainer.client-DeSo8EvG.js → index-BRGqW8aQ.js} +4975 -21416
- package/dist/leaflet-src-7m1mB8LI.js +6338 -0
- package/dist/{main-Dgri3TQL.js → main-CNHxAJ8J.js} +56758 -51450
- package/dist/proj-CKwYjU38.js +1569 -0
- package/dist/tilecoord-YW3qEH_j.js +884 -0
- package/dist/{vue3-xml-viewer.common-D6skc_Ai.js → vue3-xml-viewer.common-CmAdQfIy.js} +1 -1
- package/package.json +5 -1
- package/src/components/ActivityList/ActivityList.vue +6 -2
- package/src/components/AppLink.vue +4 -1
- package/src/components/Avatar.vue +2 -2
- package/src/components/AvatarWithName.vue +8 -4
- package/src/components/BouncingDots.vue +21 -0
- package/src/components/BrandedButton.vue +2 -0
- package/src/components/CopyButton.vue +19 -7
- package/src/components/DataserviceCard.vue +83 -118
- package/src/components/DatasetCard.vue +110 -171
- package/src/components/DatasetInformation/DatasetEmbedSection.vue +43 -0
- package/src/components/DatasetInformation/DatasetInformationSection.vue +73 -0
- package/src/components/DatasetInformation/DatasetSchemaSection.vue +74 -0
- package/src/components/DatasetInformation/DatasetSpatialSection.vue +59 -0
- package/src/components/DatasetInformation/DatasetTemporalitySection.vue +45 -0
- package/src/components/DatasetInformation/index.ts +5 -0
- package/src/components/DatasetQualityTooltipContent.vue +3 -3
- package/src/components/DescriptionList.vue +1 -4
- package/src/components/DescriptionListDetails.vue +5 -0
- package/src/components/DescriptionListTerm.vue +5 -0
- package/src/components/DiscussionMessageCard.vue +63 -0
- package/src/components/ExtraAccordion.vue +4 -4
- package/src/components/Form/BadgeSelect.vue +35 -0
- package/src/components/Form/FormatSelect.vue +28 -0
- package/src/components/Form/GeozoneSelect.vue +52 -0
- package/src/components/Form/GranularitySelect.vue +29 -0
- package/src/components/Form/LicenseSelect.vue +30 -0
- package/src/components/Form/OrganizationSelect.vue +62 -0
- package/src/components/Form/OrganizationTypeSelect.vue +34 -0
- package/src/components/Form/ReuseTopicSelect.vue +29 -0
- package/src/components/Form/SchemaSelect.vue +30 -0
- package/src/components/Form/SearchableSelect.vue +334 -0
- package/src/components/Form/SelectGroup.vue +132 -0
- package/src/components/Form/TagSelect.vue +38 -0
- package/src/components/LeafletMap.vue +31 -0
- package/src/components/LicenseBadge.vue +24 -0
- package/src/components/LoadingBlock.vue +23 -2
- package/src/components/MarkdownViewer.vue +3 -1
- package/src/components/ObjectCard.vue +42 -0
- package/src/components/ObjectCardBadge.vue +22 -0
- package/src/components/ObjectCardHeader.vue +35 -0
- package/src/components/ObjectCardOwner.vue +43 -0
- package/src/components/ObjectCardShortDescription.vue +28 -0
- package/src/components/OrganizationCard.vue +35 -20
- package/src/components/OrganizationLogo.vue +1 -1
- package/src/components/OrganizationNameWithCertificate.vue +13 -7
- package/src/components/OwnerTypeIcon.vue +1 -0
- package/src/components/Pagination.vue +1 -1
- package/src/components/Placeholder.vue +5 -2
- package/src/components/PostCard.vue +62 -0
- package/src/components/RadioGroup.vue +32 -0
- package/src/components/RadioInput.vue +64 -0
- package/src/components/ResourceAccordion/EditButton.vue +2 -3
- package/src/components/ResourceAccordion/MapContainer.client.vue +20 -16
- package/src/components/ResourceAccordion/Metadata.vue +11 -24
- package/src/components/ResourceAccordion/Pmtiles.client.vue +1 -1
- package/src/components/ResourceAccordion/Preview.vue +1 -1
- package/src/components/ResourceAccordion/ResourceAccordion.vue +30 -20
- package/src/components/ResourceAccordion/ResourceIcon.vue +1 -0
- package/src/components/ResourceAccordion/SchemaBadge.vue +2 -2
- package/src/components/ResourceExplorer/ResourceExplorer.vue +243 -0
- package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +116 -0
- package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +361 -0
- package/src/components/ReuseCard.vue +8 -28
- package/src/components/ReuseHorizontalCard.vue +80 -0
- package/src/components/Search/BasicAndAdvancedFilters.vue +49 -0
- package/src/components/Search/Filter/AccessTypeFilter.vue +37 -0
- package/src/components/Search/Filter/DatasetBadgeFilter.vue +40 -0
- package/src/components/Search/Filter/FilterButtonGroup.vue +78 -0
- package/src/components/Search/Filter/FormatFamilyFilter.vue +39 -0
- package/src/components/Search/Filter/LastUpdateRangeFilter.vue +37 -0
- package/src/components/Search/Filter/ProducerTypeFilter.vue +39 -0
- package/src/components/Search/Filter/ReuseTypeFilter.vue +42 -0
- package/src/components/Search/GlobalSearch.vue +611 -0
- package/src/components/Search/SearchInput.vue +63 -0
- package/src/components/Search/Sidemenu.vue +38 -0
- package/src/components/StatBox.vue +5 -5
- package/src/components/Tag.vue +30 -0
- package/src/components/Toggletip.vue +6 -2
- package/src/components/Tooltip.vue +2 -3
- package/src/components/TopicCard.vue +134 -0
- package/src/components/radioGroupContext.ts +9 -0
- package/src/composables/useDebouncedRef.ts +31 -0
- package/src/composables/useMetrics.ts +4 -3
- package/src/composables/useResourceCapabilities.ts +118 -0
- package/src/composables/useRouteQueryBoolean.ts +10 -0
- package/src/composables/useSelectModelSync.ts +89 -0
- package/src/composables/useStableQueryParams.ts +84 -0
- package/src/config.ts +4 -0
- package/src/functions/api.ts +17 -6
- package/src/functions/api.types.ts +4 -2
- package/src/functions/datasets.ts +1 -29
- package/src/functions/description.ts +33 -0
- package/src/functions/helpers.ts +11 -0
- package/src/functions/markdown.ts +60 -16
- package/src/functions/metrics.ts +33 -0
- package/src/functions/organizations.ts +5 -5
- package/src/main.ts +89 -7
- package/src/types/dataservices.ts +14 -12
- package/src/types/datasets.ts +20 -7
- package/src/types/discussions.ts +20 -0
- package/src/types/licenses.ts +3 -3
- package/src/types/organizations.ts +13 -1
- package/src/types/owned.ts +4 -2
- package/src/types/pages.ts +70 -0
- package/src/types/posts.ts +27 -0
- package/src/types/resources.ts +6 -0
- package/src/types/reuses.ts +14 -5
- package/src/types/search.ts +379 -0
- package/src/types/users.ts +12 -3
- package/dist/Swagger.client-CpLgaLg6.js +0 -4
- package/src/components/DatasetInformationPanel.vue +0 -211
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { defineComponent as G, useTemplateRef as W, ref as z, onMounted as B, createBlock as F, createElementBlock as N, openBlock as u, withCtx as V, createVNode as U, createElementVNode as q, unref as m, toDisplayString as A } from "vue";
|
|
2
|
+
import { a as D, _ as O, F as P } from "./main-CNHxAJ8J.js";
|
|
3
|
+
const j = /* @__PURE__ */ G({
|
|
4
|
+
__name: "MapContainer.client",
|
|
5
|
+
props: {
|
|
6
|
+
resource: {}
|
|
7
|
+
},
|
|
8
|
+
setup(f) {
|
|
9
|
+
const a = f, { t: d } = D();
|
|
10
|
+
let e = null;
|
|
11
|
+
const r = W("mapRef"), n = z(!1);
|
|
12
|
+
async function w() {
|
|
13
|
+
const [
|
|
14
|
+
{ default: i },
|
|
15
|
+
{ default: s },
|
|
16
|
+
{ default: y },
|
|
17
|
+
{ default: h },
|
|
18
|
+
{ default: C },
|
|
19
|
+
_
|
|
20
|
+
] = await Promise.all([
|
|
21
|
+
import("./View-DcDc7N2K.js").then((t) => t.M),
|
|
22
|
+
import("./Map-BdT3i2C4.js").then((t) => t.U),
|
|
23
|
+
import("./ScaleLine-BiesrgOv.js"),
|
|
24
|
+
import("./Tile-DCuqwNOI.js").then((t) => t.d),
|
|
25
|
+
import("./OSM-CamriM9b.js"),
|
|
26
|
+
// @ts-expect-error no types provided
|
|
27
|
+
import("./index-BRGqW8aQ.js")
|
|
28
|
+
]), { CRS: g, GeoportalAttribution: S, GeoportalFullScreen: M, GeoportalZoom: b, LayerImport: v, LayerSwitcher: L } = _;
|
|
29
|
+
await Promise.resolve({ }), await Promise.resolve({ }), await Promise.resolve({ }), await Promise.resolve({ }), g.load(), e = new s({
|
|
30
|
+
target: r.value,
|
|
31
|
+
layers: [
|
|
32
|
+
new h({
|
|
33
|
+
source: new C()
|
|
34
|
+
})
|
|
35
|
+
],
|
|
36
|
+
view: new i({
|
|
37
|
+
center: [288074.8449901076, 6247982515792289e-9],
|
|
38
|
+
zoom: 8,
|
|
39
|
+
constrainResolution: !0
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
const R = new y({
|
|
43
|
+
units: "metric",
|
|
44
|
+
bar: !1
|
|
45
|
+
});
|
|
46
|
+
e.addControl(R);
|
|
47
|
+
const k = new M({
|
|
48
|
+
position: "top-right"
|
|
49
|
+
});
|
|
50
|
+
e.addControl(k);
|
|
51
|
+
const T = new b({
|
|
52
|
+
position: "bottom-left"
|
|
53
|
+
});
|
|
54
|
+
e.addControl(T);
|
|
55
|
+
const x = new L({
|
|
56
|
+
options: {
|
|
57
|
+
position: "top-right"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
e.addControl(x);
|
|
61
|
+
const E = new S({
|
|
62
|
+
position: "bottom-right"
|
|
63
|
+
});
|
|
64
|
+
e.addControl(E);
|
|
65
|
+
const o = new v({
|
|
66
|
+
position: "bottom-left",
|
|
67
|
+
listable: !0,
|
|
68
|
+
layerTypes: ["WMS"]
|
|
69
|
+
});
|
|
70
|
+
o._serviceUrlImportInput.value = a.resource.url, o._formContainer.dispatchEvent(new CustomEvent("submit", { cancelable: !0 })), e.addControl(o);
|
|
71
|
+
const l = 500;
|
|
72
|
+
let p = 20;
|
|
73
|
+
function c() {
|
|
74
|
+
if (!o._getCapResponseWMSLayers)
|
|
75
|
+
p--, p > 0 ? setTimeout(c, l) : n.value = !0;
|
|
76
|
+
else {
|
|
77
|
+
const t = o._getCapResponseWMSLayers.filter((I) => I.Name == a.resource.title)[0];
|
|
78
|
+
o._addGetCapWMSLayer(t);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
setTimeout(c, l);
|
|
82
|
+
}
|
|
83
|
+
return B(() => {
|
|
84
|
+
w();
|
|
85
|
+
}), (i, s) => n.value ? (u(), F(O, {
|
|
86
|
+
key: 0,
|
|
87
|
+
type: "warning",
|
|
88
|
+
class: "flex items-center space-x-2"
|
|
89
|
+
}, {
|
|
90
|
+
default: V(() => [
|
|
91
|
+
U(m(P), { class: "shink-0 size-6" }),
|
|
92
|
+
q("span", null, A(m(d)("L'aperçu cartographique de ce fichier n'a pas pu être chargé.")), 1)
|
|
93
|
+
]),
|
|
94
|
+
_: 1
|
|
95
|
+
})) : (u(), N("div", {
|
|
96
|
+
key: 1,
|
|
97
|
+
id: "map",
|
|
98
|
+
ref_key: "mapRef",
|
|
99
|
+
ref: r
|
|
100
|
+
}, null, 512));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
export {
|
|
104
|
+
j as default
|
|
105
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { T as l, c as n, e as c } from "./TileImage-CmZf8EdU.js";
|
|
2
|
+
class u extends l {
|
|
3
|
+
/**
|
|
4
|
+
* @param {Options} [options] XYZ options.
|
|
5
|
+
*/
|
|
6
|
+
constructor(e) {
|
|
7
|
+
e = e || {};
|
|
8
|
+
const r = e.projection !== void 0 ? e.projection : "EPSG:3857", t = e.tileGrid !== void 0 ? e.tileGrid : n({
|
|
9
|
+
extent: c(r),
|
|
10
|
+
maxResolution: e.maxResolution,
|
|
11
|
+
maxZoom: e.maxZoom,
|
|
12
|
+
minZoom: e.minZoom,
|
|
13
|
+
tileSize: e.tileSize
|
|
14
|
+
});
|
|
15
|
+
super({
|
|
16
|
+
attributions: e.attributions,
|
|
17
|
+
cacheSize: e.cacheSize,
|
|
18
|
+
crossOrigin: e.crossOrigin,
|
|
19
|
+
interpolate: e.interpolate,
|
|
20
|
+
projection: r,
|
|
21
|
+
reprojectionErrorThreshold: e.reprojectionErrorThreshold,
|
|
22
|
+
tileGrid: t,
|
|
23
|
+
tileLoadFunction: e.tileLoadFunction,
|
|
24
|
+
tilePixelRatio: e.tilePixelRatio,
|
|
25
|
+
tileUrlFunction: e.tileUrlFunction,
|
|
26
|
+
url: e.url,
|
|
27
|
+
urls: e.urls,
|
|
28
|
+
wrapX: e.wrapX !== void 0 ? e.wrapX : !0,
|
|
29
|
+
transition: e.transition,
|
|
30
|
+
attributionsCollapsible: e.attributionsCollapsible,
|
|
31
|
+
zDirection: e.zDirection
|
|
32
|
+
}), this.gutter_ = e.gutter !== void 0 ? e.gutter : 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @return {number} Gutter.
|
|
36
|
+
* @override
|
|
37
|
+
*/
|
|
38
|
+
getGutter() {
|
|
39
|
+
return this.gutter_;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const d = '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';
|
|
43
|
+
class m extends u {
|
|
44
|
+
/**
|
|
45
|
+
* @param {Options} [options] Open Street Map options.
|
|
46
|
+
*/
|
|
47
|
+
constructor(e) {
|
|
48
|
+
e = e || {};
|
|
49
|
+
let r;
|
|
50
|
+
e.attributions !== void 0 ? r = e.attributions : r = [d];
|
|
51
|
+
const t = e.crossOrigin !== void 0 ? e.crossOrigin : "anonymous", a = e.url !== void 0 ? e.url : "https://tile.openstreetmap.org/{z}/{x}/{y}.png";
|
|
52
|
+
super({
|
|
53
|
+
attributions: r,
|
|
54
|
+
attributionsCollapsible: !1,
|
|
55
|
+
cacheSize: e.cacheSize,
|
|
56
|
+
crossOrigin: t,
|
|
57
|
+
interpolate: e.interpolate,
|
|
58
|
+
maxZoom: e.maxZoom !== void 0 ? e.maxZoom : 19,
|
|
59
|
+
reprojectionErrorThreshold: e.reprojectionErrorThreshold,
|
|
60
|
+
tileLoadFunction: e.tileLoadFunction,
|
|
61
|
+
transition: e.transition,
|
|
62
|
+
url: a,
|
|
63
|
+
wrapX: e.wrapX,
|
|
64
|
+
zDirection: e.zDirection
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
d as ATTRIBUTION,
|
|
70
|
+
m as default
|
|
71
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineComponent as B, defineAsyncComponent as q, ref as n, computed as w, onMounted as O, createElementBlock as p, openBlock as s, createBlock as d, createCommentVNode as L, createVNode as a, unref as o, toDisplayString as u, withCtx as f, createElementVNode as g } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { u as S, a as $, g as N, _ as h, F as m } from "./main-CNHxAJ8J.js";
|
|
3
3
|
const V = { class: "text-xs" }, A = { key: 0 }, H = {
|
|
4
4
|
key: 1,
|
|
5
5
|
class: "text-gray-medium"
|
|
6
|
-
},
|
|
6
|
+
}, M = /* @__PURE__ */ B({
|
|
7
7
|
__name: "PdfPreview.client",
|
|
8
8
|
props: {
|
|
9
9
|
resource: {}
|
|
@@ -103,5 +103,5 @@ const V = { class: "text-xs" }, A = { key: 0 }, H = {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
export {
|
|
106
|
-
|
|
106
|
+
M as default
|
|
107
107
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as ig, ref as rg, computed as Ol, useTemplateRef as ng, onMounted as ag, createElementBlock as Th, openBlock as nu, createBlock as sg, withCtx as wd, createVNode as Td, createElementVNode as ha, unref as La, toDisplayString as jl, createCommentVNode as og, createTextVNode as lg } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { b as cg, a as ug, c as hg, u as pg, d as dg, e as fg, _ as mg, F as gg, f as _g, h as yg, K as xg, t as vg } from "./main-CNHxAJ8J.js";
|
|
3
3
|
var tn = Uint8Array, So = Uint16Array, bg = Int32Array, Dd = new tn([
|
|
4
4
|
0,
|
|
5
5
|
0,
|
|
@@ -22680,7 +22680,7 @@ const T_ = 8, S_ = "Bright", P_ = { "mapbox:autocomposite": !1, "mapbox:groups":
|
|
|
22680
22680
|
}, B_ = {
|
|
22681
22681
|
key: 0,
|
|
22682
22682
|
class: "bg-blue-100 text-datagouv fr-hidden fr-unhidden-md p-4"
|
|
22683
|
-
}, O_ = { class: "fr-grid-row fr-grid-row--middle fr-grid-row--gutters" }, j_ = ["innerHTML"], N_ = { class: "fr-col" }, U_ = { class: "fr-text--bold fr-m-0" }, V_ = { class: "fr-text--sm fr-m-0
|
|
22683
|
+
}, O_ = { class: "fr-grid-row fr-grid-row--middle fr-grid-row--gutters" }, j_ = ["innerHTML"], N_ = { class: "fr-col" }, U_ = { class: "fr-text--bold fr-m-0" }, V_ = { class: "fr-text--sm fr-m-0 italic" }, $_ = { class: "fr-col-auto fr-my-0" }, Z_ = {
|
|
22684
22684
|
ref: "containerRef",
|
|
22685
22685
|
style: { height: "600px" }
|
|
22686
22686
|
}, G_ = { class: "fr-px-5v fr-pt-5v" }, ty = /* @__PURE__ */ ig({
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { C as M, a as b } from "./Control-BNCDn-8E.js";
|
|
2
|
+
import { g as E, M as T } from "./proj-CKwYjU38.js";
|
|
3
|
+
const S = "units", W = [1, 2, 5], f = 25.4 / 0.28;
|
|
4
|
+
class y extends M {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Options} [options] Scale line options.
|
|
7
|
+
*/
|
|
8
|
+
constructor(e) {
|
|
9
|
+
e = e || {};
|
|
10
|
+
const i = document.createElement("div");
|
|
11
|
+
i.style.pointerEvents = "none", super({
|
|
12
|
+
element: i,
|
|
13
|
+
render: e.render,
|
|
14
|
+
target: e.target
|
|
15
|
+
}), this.on, this.once, this.un;
|
|
16
|
+
const r = e.className !== void 0 ? e.className : e.bar ? "ol-scale-bar" : "ol-scale-line";
|
|
17
|
+
this.innerElement_ = document.createElement("div"), this.innerElement_.className = r + "-inner", this.element.className = r + " " + b, this.element.appendChild(this.innerElement_), this.viewState_ = null, this.minWidth_ = e.minWidth !== void 0 ? e.minWidth : 64, this.maxWidth_ = e.maxWidth, this.renderedVisible_ = !1, this.renderedWidth_ = void 0, this.renderedHTML_ = "", this.addChangeListener(S, this.handleUnitsChanged_), this.setUnits(e.units || "metric"), this.scaleBar_ = e.bar || !1, this.scaleBarSteps_ = e.steps || 4, this.scaleBarText_ = e.text || !1, this.dpi_ = e.dpi || void 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Return the units to use in the scale line.
|
|
21
|
+
* @return {Units} The units
|
|
22
|
+
* to use in the scale line.
|
|
23
|
+
* @observable
|
|
24
|
+
* @api
|
|
25
|
+
*/
|
|
26
|
+
getUnits() {
|
|
27
|
+
return this.get(S);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
handleUnitsChanged_() {
|
|
33
|
+
this.updateElement_();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set the units to use in the scale line.
|
|
37
|
+
* @param {Units} units The units to use in the scale line.
|
|
38
|
+
* @observable
|
|
39
|
+
* @api
|
|
40
|
+
*/
|
|
41
|
+
setUnits(e) {
|
|
42
|
+
this.set(S, e);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Specify the dpi of output device such as printer.
|
|
46
|
+
* @param {number|undefined} dpi The dpi of output device.
|
|
47
|
+
* @api
|
|
48
|
+
*/
|
|
49
|
+
setDpi(e) {
|
|
50
|
+
this.dpi_ = e;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
updateElement_() {
|
|
56
|
+
const e = this.viewState_;
|
|
57
|
+
if (!e) {
|
|
58
|
+
this.renderedVisible_ && (this.element.style.display = "none", this.renderedVisible_ = !1);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const i = e.center, r = e.projection, l = this.getUnits(), m = l == "degrees" ? "degrees" : "m";
|
|
62
|
+
let s = E(
|
|
63
|
+
r,
|
|
64
|
+
e.resolution,
|
|
65
|
+
i,
|
|
66
|
+
m
|
|
67
|
+
);
|
|
68
|
+
const h = this.minWidth_ * (this.dpi_ || f) / f, d = this.maxWidth_ !== void 0 ? this.maxWidth_ * (this.dpi_ || f) / f : void 0;
|
|
69
|
+
let n = h * s, t = "";
|
|
70
|
+
if (l == "degrees") {
|
|
71
|
+
const _ = T.degrees;
|
|
72
|
+
n *= _, n < _ / 60 ? (t = "″", s *= 3600) : n < _ ? (t = "′", s *= 60) : t = "°";
|
|
73
|
+
} else if (l == "imperial")
|
|
74
|
+
n < 0.9144 ? (t = "in", s /= 0.0254) : n < 1609.344 ? (t = "ft", s /= 0.3048) : (t = "mi", s /= 1609.344);
|
|
75
|
+
else if (l == "nautical")
|
|
76
|
+
s /= 1852, t = "NM";
|
|
77
|
+
else if (l == "metric")
|
|
78
|
+
n < 1e-6 ? (t = "nm", s *= 1e9) : n < 1e-3 ? (t = "μm", s *= 1e6) : n < 1 ? (t = "mm", s *= 1e3) : n < 1e3 ? t = "m" : (t = "km", s /= 1e3);
|
|
79
|
+
else if (l == "us")
|
|
80
|
+
n < 0.9144 ? (t = "in", s *= 39.37) : n < 1609.344 ? (t = "ft", s /= 0.30480061) : (t = "mi", s /= 1609.3472);
|
|
81
|
+
else
|
|
82
|
+
throw new Error("Invalid units");
|
|
83
|
+
let u = 3 * Math.floor(Math.log(h * s) / Math.log(10)), c, a, o, g = 0, v, x;
|
|
84
|
+
for (; ; ) {
|
|
85
|
+
o = Math.floor(u / 3);
|
|
86
|
+
const _ = Math.pow(10, o);
|
|
87
|
+
if (c = W[(u % 3 + 3) % 3] * _, a = Math.round(c / s), isNaN(a)) {
|
|
88
|
+
this.element.style.display = "none", this.renderedVisible_ = !1;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (d !== void 0 && a >= d) {
|
|
92
|
+
c = g, a = v, o = x;
|
|
93
|
+
break;
|
|
94
|
+
} else if (a >= h)
|
|
95
|
+
break;
|
|
96
|
+
g = c, v = a, x = o, ++u;
|
|
97
|
+
}
|
|
98
|
+
const p = this.scaleBar_ ? this.createScaleBar(a, c, t) : c.toFixed(o < 0 ? -o : 0) + " " + t;
|
|
99
|
+
this.renderedHTML_ != p && (this.innerElement_.innerHTML = p, this.renderedHTML_ = p), this.renderedWidth_ != a && (this.innerElement_.style.width = a + "px", this.renderedWidth_ = a), this.renderedVisible_ || (this.element.style.display = "", this.renderedVisible_ = !0);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @private
|
|
103
|
+
* @param {number} width The current width of the scalebar.
|
|
104
|
+
* @param {number} scale The current scale.
|
|
105
|
+
* @param {string} suffix The suffix to append to the scale text.
|
|
106
|
+
* @return {string} The stringified HTML of the scalebar.
|
|
107
|
+
*/
|
|
108
|
+
createScaleBar(e, i, r) {
|
|
109
|
+
const l = this.getScaleForResolution(), m = l < 1 ? Math.round(1 / l).toLocaleString() + " : 1" : "1 : " + Math.round(l).toLocaleString(), s = this.scaleBarSteps_, h = e / s, d = [this.createMarker("absolute")];
|
|
110
|
+
for (let t = 0; t < s; ++t) {
|
|
111
|
+
const u = t % 2 === 0 ? "ol-scale-singlebar-odd" : "ol-scale-singlebar-even";
|
|
112
|
+
d.push(
|
|
113
|
+
`<div><div class="ol-scale-singlebar ${u}" style="width: ${h}px;"></div>` + this.createMarker("relative") + // render text every second step, except when only 2 steps
|
|
114
|
+
(t % 2 === 0 || s === 2 ? this.createStepText(t, e, !1, i, r) : "") + "</div>"
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
return d.push(this.createStepText(s, e, !0, i, r)), (this.scaleBarText_ ? `<div class="ol-scale-text" style="width: ${e}px;">` + m + "</div>" : "") + d.join("");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Creates a marker at given position
|
|
121
|
+
* @param {'absolute'|'relative'} position The position, absolute or relative
|
|
122
|
+
* @return {string} The stringified div containing the marker
|
|
123
|
+
*/
|
|
124
|
+
createMarker(e) {
|
|
125
|
+
return `<div class="ol-scale-step-marker" style="position: ${e}; top: ${e === "absolute" ? 3 : -10}px;"></div>`;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Creates the label for a marker marker at given position
|
|
129
|
+
* @param {number} i The iterator
|
|
130
|
+
* @param {number} width The width the scalebar will currently use
|
|
131
|
+
* @param {boolean} isLast Flag indicating if we add the last step text
|
|
132
|
+
* @param {number} scale The current scale for the whole scalebar
|
|
133
|
+
* @param {string} suffix The suffix for the scale
|
|
134
|
+
* @return {string} The stringified div containing the step text
|
|
135
|
+
*/
|
|
136
|
+
createStepText(e, i, r, l, m) {
|
|
137
|
+
const h = (e === 0 ? 0 : Math.round(l / this.scaleBarSteps_ * e * 100) / 100) + (e === 0 ? "" : " " + m), d = e === 0 ? -3 : i / this.scaleBarSteps_ * -1, n = e === 0 ? 0 : i / this.scaleBarSteps_ * 2;
|
|
138
|
+
return `<div class="ol-scale-step-text" style="margin-left: ${d}px;text-align: ${e === 0 ? "left" : "center"};min-width: ${n}px;left: ${r ? i + "px" : "unset"};">` + h + "</div>";
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns the appropriate scale for the given resolution and units.
|
|
142
|
+
* @return {number} The appropriate scale.
|
|
143
|
+
*/
|
|
144
|
+
getScaleForResolution() {
|
|
145
|
+
const e = E(
|
|
146
|
+
this.viewState_.projection,
|
|
147
|
+
this.viewState_.resolution,
|
|
148
|
+
this.viewState_.center,
|
|
149
|
+
"m"
|
|
150
|
+
), i = this.dpi_ || f, r = 1e3 / 25.4;
|
|
151
|
+
return e * r * i;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Update the scale line element.
|
|
155
|
+
* @param {import("../MapEvent.js").default} mapEvent Map event.
|
|
156
|
+
* @override
|
|
157
|
+
*/
|
|
158
|
+
render(e) {
|
|
159
|
+
const i = e.frameState;
|
|
160
|
+
i ? this.viewState_ = i.viewState : this.viewState_ = null, this.updateElement_();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
y as default
|
|
165
|
+
};
|