@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,884 @@
|
|
|
1
|
+
import { T as g, l as Et, c as N, b as et } from "./Image-BN-4XkIn.js";
|
|
2
|
+
import { y as xt, g as Tt } from "./common-C4rDcQpp.js";
|
|
3
|
+
import { aC as pt, E as lt, ak as It, S as ft, g as nt, W as Xt, v as Mt, D as K, m as dt, K as L, an as _t, aS as vt, w as Wt, q as Yt, aT as Lt, aj as yt, aI as Ft, az as wt, aJ as Dt, aU as st, ac as ot, i as Pt, U as z, a0 as J, d as V, l as Ct, u as at, a6 as rt, H as Ot } from "./proj-CKwYjU38.js";
|
|
4
|
+
class gt extends pt {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
7
|
+
* @param {import("./TileState.js").default} state State.
|
|
8
|
+
* @param {Options} [options] Tile options.
|
|
9
|
+
*/
|
|
10
|
+
constructor(t, e, s) {
|
|
11
|
+
super(), s = s || {}, this.tileCoord = t, this.state = e, this.key = "", this.transition_ = s.transition === void 0 ? 250 : s.transition, this.transitionStarts_ = {}, this.interpolate = !!s.interpolate;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
changed() {
|
|
17
|
+
this.dispatchEvent(lt.CHANGE);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Called by the tile cache when the tile is removed from the cache due to expiry
|
|
21
|
+
*/
|
|
22
|
+
release() {
|
|
23
|
+
this.setState(g.EMPTY);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @return {string} Key.
|
|
27
|
+
*/
|
|
28
|
+
getKey() {
|
|
29
|
+
return this.key + "/" + this.tileCoord;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the tile coordinate for this tile.
|
|
33
|
+
* @return {import("./tilecoord.js").TileCoord} The tile coordinate.
|
|
34
|
+
* @api
|
|
35
|
+
*/
|
|
36
|
+
getTileCoord() {
|
|
37
|
+
return this.tileCoord;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @return {import("./TileState.js").default} State.
|
|
41
|
+
*/
|
|
42
|
+
getState() {
|
|
43
|
+
return this.state;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets the state of this tile. If you write your own {@link module:ol/Tile~LoadFunction tileLoadFunction} ,
|
|
47
|
+
* it is important to set the state correctly to {@link module:ol/TileState~ERROR}
|
|
48
|
+
* when the tile cannot be loaded. Otherwise the tile cannot be removed from
|
|
49
|
+
* the tile queue and will block other requests.
|
|
50
|
+
* @param {import("./TileState.js").default} state State.
|
|
51
|
+
* @api
|
|
52
|
+
*/
|
|
53
|
+
setState(t) {
|
|
54
|
+
if (this.state !== g.EMPTY) {
|
|
55
|
+
if (this.state !== g.ERROR && this.state > t)
|
|
56
|
+
throw new Error("Tile load sequence violation");
|
|
57
|
+
this.state = t, this.changed();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Load the image or retry if loading previously failed.
|
|
62
|
+
* Loading is taken care of by the tile queue, and calling this method is
|
|
63
|
+
* only needed for preloading or for reloading in case of an error.
|
|
64
|
+
* @abstract
|
|
65
|
+
* @api
|
|
66
|
+
*/
|
|
67
|
+
load() {
|
|
68
|
+
It();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the alpha value for rendering.
|
|
72
|
+
* @param {string} id An id for the renderer.
|
|
73
|
+
* @param {number} time The render frame time.
|
|
74
|
+
* @return {number} A number between 0 and 1.
|
|
75
|
+
*/
|
|
76
|
+
getAlpha(t, e) {
|
|
77
|
+
if (!this.transition_)
|
|
78
|
+
return 1;
|
|
79
|
+
let s = this.transitionStarts_[t];
|
|
80
|
+
if (!s)
|
|
81
|
+
s = e, this.transitionStarts_[t] = s;
|
|
82
|
+
else if (s === -1)
|
|
83
|
+
return 1;
|
|
84
|
+
const n = e - s + 1e3 / 60;
|
|
85
|
+
return n >= this.transition_ ? 1 : xt(n / this.transition_);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Determine if a tile is in an alpha transition. A tile is considered in
|
|
89
|
+
* transition if tile.getAlpha() has not yet been called or has been called
|
|
90
|
+
* and returned 1.
|
|
91
|
+
* @param {string} id An id for the renderer.
|
|
92
|
+
* @return {boolean} The tile is in transition.
|
|
93
|
+
*/
|
|
94
|
+
inTransition(t) {
|
|
95
|
+
return this.transition_ ? this.transitionStarts_[t] !== -1 : !1;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Mark a transition as complete.
|
|
99
|
+
* @param {string} id An id for the renderer.
|
|
100
|
+
*/
|
|
101
|
+
endTransition(t) {
|
|
102
|
+
this.transition_ && (this.transitionStarts_[t] = -1);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @override
|
|
106
|
+
*/
|
|
107
|
+
disposeInternal() {
|
|
108
|
+
this.release(), super.disposeInternal();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
class Qt extends gt {
|
|
112
|
+
/**
|
|
113
|
+
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
114
|
+
* @param {import("./TileState.js").default} state State.
|
|
115
|
+
* @param {string} src Image source URI.
|
|
116
|
+
* @param {?string} crossOrigin Cross origin.
|
|
117
|
+
* @param {import("./Tile.js").LoadFunction} tileLoadFunction Tile load function.
|
|
118
|
+
* @param {import("./Tile.js").Options} [options] Tile options.
|
|
119
|
+
*/
|
|
120
|
+
constructor(t, e, s, n, i, c) {
|
|
121
|
+
super(t, e, c), this.crossOrigin_ = n, this.src_ = s, this.key = s, this.image_ = new Image(), n !== null && (this.image_.crossOrigin = n), this.unlisten_ = null, this.tileLoadFunction_ = i;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the HTML image element for this tile (may be a Canvas, Image, or Video).
|
|
125
|
+
* @return {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} Image.
|
|
126
|
+
* @api
|
|
127
|
+
*/
|
|
128
|
+
getImage() {
|
|
129
|
+
return this.image_;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Sets an HTML image element for this tile (may be a Canvas or preloaded Image).
|
|
133
|
+
* @param {HTMLCanvasElement|HTMLImageElement} element Element.
|
|
134
|
+
*/
|
|
135
|
+
setImage(t) {
|
|
136
|
+
this.image_ = t, this.state = g.LOADED, this.unlistenImage_(), this.changed();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Tracks loading or read errors.
|
|
140
|
+
*
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
handleImageError_() {
|
|
144
|
+
this.state = g.ERROR, this.unlistenImage_(), this.image_ = At(), this.changed();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Tracks successful image load.
|
|
148
|
+
*
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
handleImageLoad_() {
|
|
152
|
+
const t = (
|
|
153
|
+
/** @type {HTMLImageElement} */
|
|
154
|
+
this.image_
|
|
155
|
+
);
|
|
156
|
+
t.naturalWidth && t.naturalHeight ? this.state = g.LOADED : this.state = g.EMPTY, this.unlistenImage_(), this.changed();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Load the image or retry if loading previously failed.
|
|
160
|
+
* Loading is taken care of by the tile queue, and calling this method is
|
|
161
|
+
* only needed for preloading or for reloading in case of an error.
|
|
162
|
+
*
|
|
163
|
+
* To retry loading tiles on failed requests, use a custom `tileLoadFunction`
|
|
164
|
+
* that checks for error status codes and reloads only when the status code is
|
|
165
|
+
* 408, 429, 500, 502, 503 and 504, and only when not too many retries have been
|
|
166
|
+
* made already:
|
|
167
|
+
*
|
|
168
|
+
* ```js
|
|
169
|
+
* const retryCodes = [408, 429, 500, 502, 503, 504];
|
|
170
|
+
* const retries = {};
|
|
171
|
+
* source.setTileLoadFunction((tile, src) => {
|
|
172
|
+
* const image = tile.getImage();
|
|
173
|
+
* fetch(src)
|
|
174
|
+
* .then((response) => {
|
|
175
|
+
* if (retryCodes.includes(response.status)) {
|
|
176
|
+
* retries[src] = (retries[src] || 0) + 1;
|
|
177
|
+
* if (retries[src] <= 3) {
|
|
178
|
+
* setTimeout(() => tile.load(), retries[src] * 1000);
|
|
179
|
+
* }
|
|
180
|
+
* return Promise.reject();
|
|
181
|
+
* }
|
|
182
|
+
* return response.blob();
|
|
183
|
+
* })
|
|
184
|
+
* .then((blob) => {
|
|
185
|
+
* const imageUrl = URL.createObjectURL(blob);
|
|
186
|
+
* image.src = imageUrl;
|
|
187
|
+
* setTimeout(() => URL.revokeObjectURL(imageUrl), 5000);
|
|
188
|
+
* })
|
|
189
|
+
* .catch(() => tile.setState(3)); // error
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
* @api
|
|
193
|
+
* @override
|
|
194
|
+
*/
|
|
195
|
+
load() {
|
|
196
|
+
this.state == g.ERROR && (this.state = g.IDLE, this.image_ = new Image(), this.crossOrigin_ !== null && (this.image_.crossOrigin = this.crossOrigin_)), this.state == g.IDLE && (this.state = g.LOADING, this.changed(), this.tileLoadFunction_(this, this.src_), this.unlisten_ = Et(
|
|
197
|
+
this.image_,
|
|
198
|
+
this.handleImageLoad_.bind(this),
|
|
199
|
+
this.handleImageError_.bind(this)
|
|
200
|
+
));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Discards event handlers which listen for load completion or errors.
|
|
204
|
+
*
|
|
205
|
+
* @private
|
|
206
|
+
*/
|
|
207
|
+
unlistenImage_() {
|
|
208
|
+
this.unlisten_ && (this.unlisten_(), this.unlisten_ = null);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @override
|
|
212
|
+
*/
|
|
213
|
+
disposeInternal() {
|
|
214
|
+
this.unlistenImage_(), this.image_ = null, super.disposeInternal();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function At() {
|
|
218
|
+
const o = N(1, 1);
|
|
219
|
+
return o.fillStyle = "rgba(0,0,0,0)", o.fillRect(0, 0, 1, 1), o.canvas;
|
|
220
|
+
}
|
|
221
|
+
class Rt {
|
|
222
|
+
/**
|
|
223
|
+
* @param {number} minX Minimum X.
|
|
224
|
+
* @param {number} maxX Maximum X.
|
|
225
|
+
* @param {number} minY Minimum Y.
|
|
226
|
+
* @param {number} maxY Maximum Y.
|
|
227
|
+
*/
|
|
228
|
+
constructor(t, e, s, n) {
|
|
229
|
+
this.minX = t, this.maxX = e, this.minY = s, this.maxY = n;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @param {import("./tilecoord.js").TileCoord} tileCoord Tile coordinate.
|
|
233
|
+
* @return {boolean} Contains tile coordinate.
|
|
234
|
+
*/
|
|
235
|
+
contains(t) {
|
|
236
|
+
return this.containsXY(t[1], t[2]);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @param {TileRange} tileRange Tile range.
|
|
240
|
+
* @return {boolean} Contains.
|
|
241
|
+
*/
|
|
242
|
+
containsTileRange(t) {
|
|
243
|
+
return this.minX <= t.minX && t.maxX <= this.maxX && this.minY <= t.minY && t.maxY <= this.maxY;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @param {number} x Tile coordinate x.
|
|
247
|
+
* @param {number} y Tile coordinate y.
|
|
248
|
+
* @return {boolean} Contains coordinate.
|
|
249
|
+
*/
|
|
250
|
+
containsXY(t, e) {
|
|
251
|
+
return this.minX <= t && t <= this.maxX && this.minY <= e && e <= this.maxY;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @param {TileRange} tileRange Tile range.
|
|
255
|
+
* @return {boolean} Equals.
|
|
256
|
+
*/
|
|
257
|
+
equals(t) {
|
|
258
|
+
return this.minX == t.minX && this.minY == t.minY && this.maxX == t.maxX && this.maxY == t.maxY;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @param {TileRange} tileRange Tile range.
|
|
262
|
+
*/
|
|
263
|
+
extend(t) {
|
|
264
|
+
t.minX < this.minX && (this.minX = t.minX), t.maxX > this.maxX && (this.maxX = t.maxX), t.minY < this.minY && (this.minY = t.minY), t.maxY > this.maxY && (this.maxY = t.maxY);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* @return {number} Height.
|
|
268
|
+
*/
|
|
269
|
+
getHeight() {
|
|
270
|
+
return this.maxY - this.minY + 1;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* @return {import("./size.js").Size} Size.
|
|
274
|
+
*/
|
|
275
|
+
getSize() {
|
|
276
|
+
return [this.getWidth(), this.getHeight()];
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* @return {number} Width.
|
|
280
|
+
*/
|
|
281
|
+
getWidth() {
|
|
282
|
+
return this.maxX - this.minX + 1;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @param {TileRange} tileRange Tile range.
|
|
286
|
+
* @return {boolean} Intersects.
|
|
287
|
+
*/
|
|
288
|
+
intersects(t) {
|
|
289
|
+
return this.minX <= t.maxX && this.maxX >= t.minX && this.minY <= t.maxY && this.maxY >= t.minY;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function jt(o, t, e, s, n) {
|
|
293
|
+
return n !== void 0 ? (n.minX = o, n.maxX = t, n.minY = e, n.maxY = s, n) : new Rt(o, t, e, s);
|
|
294
|
+
}
|
|
295
|
+
let $;
|
|
296
|
+
const B = [];
|
|
297
|
+
function ht(o, t, e, s, n) {
|
|
298
|
+
o.beginPath(), o.moveTo(0, 0), o.lineTo(t, e), o.lineTo(s, n), o.closePath(), o.save(), o.clip(), o.fillRect(0, 0, Math.max(t, s) + 1, Math.max(e, n)), o.restore();
|
|
299
|
+
}
|
|
300
|
+
function tt(o, t) {
|
|
301
|
+
return Math.abs(o[t * 4] - 210) > 2 || Math.abs(o[t * 4 + 3] - 0.75 * 255) > 2;
|
|
302
|
+
}
|
|
303
|
+
function kt() {
|
|
304
|
+
if ($ === void 0) {
|
|
305
|
+
const o = N(6, 6, B);
|
|
306
|
+
o.globalCompositeOperation = "lighter", o.fillStyle = "rgba(210, 0, 0, 0.75)", ht(o, 4, 5, 4, 0), ht(o, 4, 5, 0, 5);
|
|
307
|
+
const t = o.getImageData(0, 0, 3, 3).data;
|
|
308
|
+
$ = tt(t, 0) || tt(t, 4) || tt(t, 8), et(o), B.push(o.canvas);
|
|
309
|
+
}
|
|
310
|
+
return $;
|
|
311
|
+
}
|
|
312
|
+
function ct(o, t, e, s) {
|
|
313
|
+
const n = ft(e, t, o);
|
|
314
|
+
let i = nt(
|
|
315
|
+
t,
|
|
316
|
+
s,
|
|
317
|
+
e
|
|
318
|
+
);
|
|
319
|
+
const c = t.getMetersPerUnit();
|
|
320
|
+
c !== void 0 && (i *= c);
|
|
321
|
+
const m = o.getMetersPerUnit();
|
|
322
|
+
m !== void 0 && (i /= m);
|
|
323
|
+
const _ = o.getExtent();
|
|
324
|
+
if (!_ || Xt(_, n)) {
|
|
325
|
+
const T = nt(o, i, n) / i;
|
|
326
|
+
isFinite(T) && T > 0 && (i /= T);
|
|
327
|
+
}
|
|
328
|
+
return i;
|
|
329
|
+
}
|
|
330
|
+
function Bt(o, t, e, s) {
|
|
331
|
+
const n = Wt(e);
|
|
332
|
+
let i = ct(
|
|
333
|
+
o,
|
|
334
|
+
t,
|
|
335
|
+
n,
|
|
336
|
+
s
|
|
337
|
+
);
|
|
338
|
+
return (!isFinite(i) || i <= 0) && Yt(e, function(c) {
|
|
339
|
+
return i = ct(
|
|
340
|
+
o,
|
|
341
|
+
t,
|
|
342
|
+
c,
|
|
343
|
+
s
|
|
344
|
+
), isFinite(i) && i > 0;
|
|
345
|
+
}), i;
|
|
346
|
+
}
|
|
347
|
+
function Gt(o, t, e, s, n, i, c, m, _, T, X, x, y, F) {
|
|
348
|
+
const r = N(
|
|
349
|
+
Math.round(e * o),
|
|
350
|
+
Math.round(e * t),
|
|
351
|
+
B
|
|
352
|
+
);
|
|
353
|
+
if (x || (r.imageSmoothingEnabled = !1), _.length === 0)
|
|
354
|
+
return r.canvas;
|
|
355
|
+
r.scale(e, e);
|
|
356
|
+
function h(a) {
|
|
357
|
+
return Math.round(a * e) / e;
|
|
358
|
+
}
|
|
359
|
+
r.globalCompositeOperation = "lighter";
|
|
360
|
+
const E = dt();
|
|
361
|
+
_.forEach(function(a, w, C) {
|
|
362
|
+
Mt(E, a.extent);
|
|
363
|
+
});
|
|
364
|
+
let l;
|
|
365
|
+
const f = e / s, d = (x ? 1 : 1 + Math.pow(2, -24)) / f;
|
|
366
|
+
(!y || _.length !== 1 || T !== 0) && (l = N(
|
|
367
|
+
Math.round(L(E) * f),
|
|
368
|
+
Math.round(K(E) * f),
|
|
369
|
+
B
|
|
370
|
+
), x || (l.imageSmoothingEnabled = !1), _.forEach(function(a, w, C) {
|
|
371
|
+
if (a.image.width > 0 && a.image.height > 0) {
|
|
372
|
+
if (a.clipExtent) {
|
|
373
|
+
l.save();
|
|
374
|
+
const M = (a.clipExtent[0] - E[0]) * f, v = -(a.clipExtent[3] - E[3]) * f, D = L(a.clipExtent) * f, A = K(a.clipExtent) * f;
|
|
375
|
+
l.rect(
|
|
376
|
+
x ? M : Math.round(M),
|
|
377
|
+
x ? v : Math.round(v),
|
|
378
|
+
x ? D : Math.round(M + D) - Math.round(M),
|
|
379
|
+
x ? A : Math.round(v + A) - Math.round(v)
|
|
380
|
+
), l.clip();
|
|
381
|
+
}
|
|
382
|
+
const p = (a.extent[0] - E[0]) * f, I = -(a.extent[3] - E[3]) * f, W = L(a.extent) * f, Y = K(a.extent) * f;
|
|
383
|
+
l.drawImage(
|
|
384
|
+
a.image,
|
|
385
|
+
T,
|
|
386
|
+
T,
|
|
387
|
+
a.image.width - 2 * T,
|
|
388
|
+
a.image.height - 2 * T,
|
|
389
|
+
x ? p : Math.round(p),
|
|
390
|
+
x ? I : Math.round(I),
|
|
391
|
+
x ? W : Math.round(p + W) - Math.round(p),
|
|
392
|
+
x ? Y : Math.round(I + Y) - Math.round(I)
|
|
393
|
+
), a.clipExtent && l.restore();
|
|
394
|
+
}
|
|
395
|
+
}));
|
|
396
|
+
const u = _t(c);
|
|
397
|
+
return m.getTriangles().forEach(function(a, w, C) {
|
|
398
|
+
const p = a.source, I = a.target;
|
|
399
|
+
let W = p[0][0], Y = p[0][1], M = p[1][0], v = p[1][1], D = p[2][0], A = p[2][1];
|
|
400
|
+
const G = h((I[0][0] - u[0]) / i), Z = h(
|
|
401
|
+
-(I[0][1] - u[1]) / i
|
|
402
|
+
), R = h((I[1][0] - u[0]) / i), k = h(
|
|
403
|
+
-(I[1][1] - u[1]) / i
|
|
404
|
+
), U = h((I[2][0] - u[0]) / i), Q = h(
|
|
405
|
+
-(I[2][1] - u[1]) / i
|
|
406
|
+
), j = W, q = Y;
|
|
407
|
+
W = 0, Y = 0, M -= j, v -= q, D -= j, A -= q;
|
|
408
|
+
const mt = [
|
|
409
|
+
[M, v, 0, 0, R - G],
|
|
410
|
+
[D, A, 0, 0, U - G],
|
|
411
|
+
[0, 0, M, v, k - Z],
|
|
412
|
+
[0, 0, D, A, Q - Z]
|
|
413
|
+
], H = vt(mt);
|
|
414
|
+
if (!H)
|
|
415
|
+
return;
|
|
416
|
+
if (r.save(), r.beginPath(), kt() || !x) {
|
|
417
|
+
r.moveTo(R, k);
|
|
418
|
+
const P = 4, b = G - R, it = Z - k;
|
|
419
|
+
for (let O = 0; O < P; O++)
|
|
420
|
+
r.lineTo(
|
|
421
|
+
R + h((O + 1) * b / P),
|
|
422
|
+
k + h(O * it / (P - 1))
|
|
423
|
+
), O != P - 1 && r.lineTo(
|
|
424
|
+
R + h((O + 1) * b / P),
|
|
425
|
+
k + h((O + 1) * it / (P - 1))
|
|
426
|
+
);
|
|
427
|
+
r.lineTo(U, Q);
|
|
428
|
+
} else
|
|
429
|
+
r.moveTo(R, k), r.lineTo(G, Z), r.lineTo(U, Q);
|
|
430
|
+
r.clip(), r.transform(
|
|
431
|
+
H[0],
|
|
432
|
+
H[2],
|
|
433
|
+
H[1],
|
|
434
|
+
H[3],
|
|
435
|
+
G,
|
|
436
|
+
Z
|
|
437
|
+
), r.translate(
|
|
438
|
+
E[0] - j,
|
|
439
|
+
E[3] - q
|
|
440
|
+
);
|
|
441
|
+
let S;
|
|
442
|
+
if (l)
|
|
443
|
+
S = l.canvas, r.scale(d, -d);
|
|
444
|
+
else {
|
|
445
|
+
const P = _[0], b = P.extent;
|
|
446
|
+
S = P.image, r.scale(
|
|
447
|
+
L(b) / S.width,
|
|
448
|
+
-K(b) / S.height
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
r.drawImage(S, 0, 0), r.restore();
|
|
452
|
+
}), l && (et(l), B.push(l.canvas)), X && (r.save(), r.globalCompositeOperation = "source-over", r.strokeStyle = "black", r.lineWidth = 1, m.getTriangles().forEach(function(a, w, C) {
|
|
453
|
+
const p = a.target, I = (p[0][0] - u[0]) / i, W = -(p[0][1] - u[1]) / i, Y = (p[1][0] - u[0]) / i, M = -(p[1][1] - u[1]) / i, v = (p[2][0] - u[0]) / i, D = -(p[2][1] - u[1]) / i;
|
|
454
|
+
r.beginPath(), r.moveTo(Y, M), r.lineTo(I, W), r.lineTo(v, D), r.closePath(), r.stroke();
|
|
455
|
+
}), r.restore()), r.canvas;
|
|
456
|
+
}
|
|
457
|
+
const Zt = 10, ut = 0.25;
|
|
458
|
+
class Ht {
|
|
459
|
+
/**
|
|
460
|
+
* @param {import("../proj/Projection.js").default} sourceProj Source projection.
|
|
461
|
+
* @param {import("../proj/Projection.js").default} targetProj Target projection.
|
|
462
|
+
* @param {import("../extent.js").Extent} targetExtent Target extent to triangulate.
|
|
463
|
+
* @param {import("../extent.js").Extent} maxSourceExtent Maximal source extent that can be used.
|
|
464
|
+
* @param {number} errorThreshold Acceptable error (in source units).
|
|
465
|
+
* @param {?number} destinationResolution The (optional) resolution of the destination.
|
|
466
|
+
* @param {import("../transform.js").Transform} [sourceMatrix] Source transform matrix.
|
|
467
|
+
*/
|
|
468
|
+
constructor(t, e, s, n, i, c, m) {
|
|
469
|
+
this.sourceProj_ = t, this.targetProj_ = e;
|
|
470
|
+
let _ = {};
|
|
471
|
+
const T = m ? Lt(
|
|
472
|
+
(d) => Tt(
|
|
473
|
+
m,
|
|
474
|
+
ft(d, this.targetProj_, this.sourceProj_)
|
|
475
|
+
)
|
|
476
|
+
) : yt(this.targetProj_, this.sourceProj_);
|
|
477
|
+
this.transformInv_ = function(d) {
|
|
478
|
+
const u = d[0] + "/" + d[1];
|
|
479
|
+
return _[u] || (_[u] = T(d)), _[u];
|
|
480
|
+
}, this.maxSourceExtent_ = n, this.errorThresholdSquared_ = i * i, this.triangles_ = [], this.wrapsXInSource_ = !1, this.canWrapXInSource_ = this.sourceProj_.canWrapX() && !!n && !!this.sourceProj_.getExtent() && L(n) >= L(this.sourceProj_.getExtent()), this.sourceWorldWidth_ = this.sourceProj_.getExtent() ? L(this.sourceProj_.getExtent()) : null, this.targetWorldWidth_ = this.targetProj_.getExtent() ? L(this.targetProj_.getExtent()) : null;
|
|
481
|
+
const X = _t(s), x = Ft(s), y = wt(s), F = Dt(s), r = this.transformInv_(X), h = this.transformInv_(x), E = this.transformInv_(y), l = this.transformInv_(F), f = Zt + (c ? Math.max(
|
|
482
|
+
0,
|
|
483
|
+
Math.ceil(
|
|
484
|
+
Math.log2(
|
|
485
|
+
st(s) / (c * c * 256 * 256)
|
|
486
|
+
)
|
|
487
|
+
)
|
|
488
|
+
) : 0);
|
|
489
|
+
if (this.addQuad_(
|
|
490
|
+
X,
|
|
491
|
+
x,
|
|
492
|
+
y,
|
|
493
|
+
F,
|
|
494
|
+
r,
|
|
495
|
+
h,
|
|
496
|
+
E,
|
|
497
|
+
l,
|
|
498
|
+
f
|
|
499
|
+
), this.wrapsXInSource_) {
|
|
500
|
+
let d = 1 / 0;
|
|
501
|
+
this.triangles_.forEach(function(u, a, w) {
|
|
502
|
+
d = Math.min(
|
|
503
|
+
d,
|
|
504
|
+
u.source[0][0],
|
|
505
|
+
u.source[1][0],
|
|
506
|
+
u.source[2][0]
|
|
507
|
+
);
|
|
508
|
+
}), this.triangles_.forEach((u) => {
|
|
509
|
+
if (Math.max(
|
|
510
|
+
u.source[0][0],
|
|
511
|
+
u.source[1][0],
|
|
512
|
+
u.source[2][0]
|
|
513
|
+
) - d > this.sourceWorldWidth_ / 2) {
|
|
514
|
+
const a = [
|
|
515
|
+
[u.source[0][0], u.source[0][1]],
|
|
516
|
+
[u.source[1][0], u.source[1][1]],
|
|
517
|
+
[u.source[2][0], u.source[2][1]]
|
|
518
|
+
];
|
|
519
|
+
a[0][0] - d > this.sourceWorldWidth_ / 2 && (a[0][0] -= this.sourceWorldWidth_), a[1][0] - d > this.sourceWorldWidth_ / 2 && (a[1][0] -= this.sourceWorldWidth_), a[2][0] - d > this.sourceWorldWidth_ / 2 && (a[2][0] -= this.sourceWorldWidth_);
|
|
520
|
+
const w = Math.min(
|
|
521
|
+
a[0][0],
|
|
522
|
+
a[1][0],
|
|
523
|
+
a[2][0]
|
|
524
|
+
);
|
|
525
|
+
Math.max(
|
|
526
|
+
a[0][0],
|
|
527
|
+
a[1][0],
|
|
528
|
+
a[2][0]
|
|
529
|
+
) - w < this.sourceWorldWidth_ / 2 && (u.source = a);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
_ = {};
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Adds triangle to the triangulation.
|
|
537
|
+
* @param {import("../coordinate.js").Coordinate} a The target a coordinate.
|
|
538
|
+
* @param {import("../coordinate.js").Coordinate} b The target b coordinate.
|
|
539
|
+
* @param {import("../coordinate.js").Coordinate} c The target c coordinate.
|
|
540
|
+
* @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
|
|
541
|
+
* @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
|
|
542
|
+
* @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
|
|
543
|
+
* @private
|
|
544
|
+
*/
|
|
545
|
+
addTriangle_(t, e, s, n, i, c) {
|
|
546
|
+
this.triangles_.push({
|
|
547
|
+
source: [n, i, c],
|
|
548
|
+
target: [t, e, s]
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Adds quad (points in clock-wise order) to the triangulation
|
|
553
|
+
* (and reprojects the vertices) if valid.
|
|
554
|
+
* Performs quad subdivision if needed to increase precision.
|
|
555
|
+
*
|
|
556
|
+
* @param {import("../coordinate.js").Coordinate} a The target a coordinate.
|
|
557
|
+
* @param {import("../coordinate.js").Coordinate} b The target b coordinate.
|
|
558
|
+
* @param {import("../coordinate.js").Coordinate} c The target c coordinate.
|
|
559
|
+
* @param {import("../coordinate.js").Coordinate} d The target d coordinate.
|
|
560
|
+
* @param {import("../coordinate.js").Coordinate} aSrc The source a coordinate.
|
|
561
|
+
* @param {import("../coordinate.js").Coordinate} bSrc The source b coordinate.
|
|
562
|
+
* @param {import("../coordinate.js").Coordinate} cSrc The source c coordinate.
|
|
563
|
+
* @param {import("../coordinate.js").Coordinate} dSrc The source d coordinate.
|
|
564
|
+
* @param {number} maxSubdivision Maximal allowed subdivision of the quad.
|
|
565
|
+
* @private
|
|
566
|
+
*/
|
|
567
|
+
addQuad_(t, e, s, n, i, c, m, _, T) {
|
|
568
|
+
const X = ot([i, c, m, _]), x = this.sourceWorldWidth_ ? L(X) / this.sourceWorldWidth_ : null, y = (
|
|
569
|
+
/** @type {number} */
|
|
570
|
+
this.sourceWorldWidth_
|
|
571
|
+
), F = this.sourceProj_.canWrapX() && x > 0.5 && x < 1;
|
|
572
|
+
let r = !1;
|
|
573
|
+
if (T > 0) {
|
|
574
|
+
if (this.targetProj_.isGlobal() && this.targetWorldWidth_) {
|
|
575
|
+
const E = ot([t, e, s, n]);
|
|
576
|
+
r = L(E) / this.targetWorldWidth_ > ut || r;
|
|
577
|
+
}
|
|
578
|
+
!F && this.sourceProj_.isGlobal() && x && (r = x > ut || r);
|
|
579
|
+
}
|
|
580
|
+
if (!r && this.maxSourceExtent_ && isFinite(X[0]) && isFinite(X[1]) && isFinite(X[2]) && isFinite(X[3]) && !Pt(X, this.maxSourceExtent_))
|
|
581
|
+
return;
|
|
582
|
+
let h = 0;
|
|
583
|
+
if (!r && (!isFinite(i[0]) || !isFinite(i[1]) || !isFinite(c[0]) || !isFinite(c[1]) || !isFinite(m[0]) || !isFinite(m[1]) || !isFinite(_[0]) || !isFinite(_[1]))) {
|
|
584
|
+
if (T > 0)
|
|
585
|
+
r = !0;
|
|
586
|
+
else if (h = (!isFinite(i[0]) || !isFinite(i[1]) ? 8 : 0) + (!isFinite(c[0]) || !isFinite(c[1]) ? 4 : 0) + (!isFinite(m[0]) || !isFinite(m[1]) ? 2 : 0) + (!isFinite(_[0]) || !isFinite(_[1]) ? 1 : 0), h != 1 && h != 2 && h != 4 && h != 8)
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (T > 0) {
|
|
590
|
+
if (!r) {
|
|
591
|
+
const E = [(t[0] + s[0]) / 2, (t[1] + s[1]) / 2], l = this.transformInv_(E);
|
|
592
|
+
let f;
|
|
593
|
+
F ? f = (z(i[0], y) + z(m[0], y)) / 2 - z(l[0], y) : f = (i[0] + m[0]) / 2 - l[0];
|
|
594
|
+
const d = (i[1] + m[1]) / 2 - l[1];
|
|
595
|
+
r = f * f + d * d > this.errorThresholdSquared_;
|
|
596
|
+
}
|
|
597
|
+
if (r) {
|
|
598
|
+
if (Math.abs(t[0] - s[0]) <= Math.abs(t[1] - s[1])) {
|
|
599
|
+
const E = [(e[0] + s[0]) / 2, (e[1] + s[1]) / 2], l = this.transformInv_(E), f = [(n[0] + t[0]) / 2, (n[1] + t[1]) / 2], d = this.transformInv_(f);
|
|
600
|
+
this.addQuad_(
|
|
601
|
+
t,
|
|
602
|
+
e,
|
|
603
|
+
E,
|
|
604
|
+
f,
|
|
605
|
+
i,
|
|
606
|
+
c,
|
|
607
|
+
l,
|
|
608
|
+
d,
|
|
609
|
+
T - 1
|
|
610
|
+
), this.addQuad_(
|
|
611
|
+
f,
|
|
612
|
+
E,
|
|
613
|
+
s,
|
|
614
|
+
n,
|
|
615
|
+
d,
|
|
616
|
+
l,
|
|
617
|
+
m,
|
|
618
|
+
_,
|
|
619
|
+
T - 1
|
|
620
|
+
);
|
|
621
|
+
} else {
|
|
622
|
+
const E = [(t[0] + e[0]) / 2, (t[1] + e[1]) / 2], l = this.transformInv_(E), f = [(s[0] + n[0]) / 2, (s[1] + n[1]) / 2], d = this.transformInv_(f);
|
|
623
|
+
this.addQuad_(
|
|
624
|
+
t,
|
|
625
|
+
E,
|
|
626
|
+
f,
|
|
627
|
+
n,
|
|
628
|
+
i,
|
|
629
|
+
l,
|
|
630
|
+
d,
|
|
631
|
+
_,
|
|
632
|
+
T - 1
|
|
633
|
+
), this.addQuad_(
|
|
634
|
+
E,
|
|
635
|
+
e,
|
|
636
|
+
s,
|
|
637
|
+
f,
|
|
638
|
+
l,
|
|
639
|
+
c,
|
|
640
|
+
m,
|
|
641
|
+
d,
|
|
642
|
+
T - 1
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (F) {
|
|
649
|
+
if (!this.canWrapXInSource_)
|
|
650
|
+
return;
|
|
651
|
+
this.wrapsXInSource_ = !0;
|
|
652
|
+
}
|
|
653
|
+
(h & 11) == 0 && this.addTriangle_(t, s, n, i, m, _), (h & 14) == 0 && this.addTriangle_(t, s, e, i, m, c), h && ((h & 13) == 0 && this.addTriangle_(e, n, t, c, _, i), (h & 7) == 0 && this.addTriangle_(e, n, s, c, _, m));
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Calculates extent of the `source` coordinates from all the triangles.
|
|
657
|
+
*
|
|
658
|
+
* @return {import("../extent.js").Extent} Calculated extent.
|
|
659
|
+
*/
|
|
660
|
+
calculateSourceExtent() {
|
|
661
|
+
const t = dt();
|
|
662
|
+
return this.triangles_.forEach(function(e, s, n) {
|
|
663
|
+
const i = e.source;
|
|
664
|
+
J(t, i[0]), J(t, i[1]), J(t, i[2]);
|
|
665
|
+
}), t;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* @return {Array<Triangle>} Array of the calculated triangles.
|
|
669
|
+
*/
|
|
670
|
+
getTriangles() {
|
|
671
|
+
return this.triangles_;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
const St = 0.5;
|
|
675
|
+
class qt extends gt {
|
|
676
|
+
/**
|
|
677
|
+
* @param {import("../proj/Projection.js").default} sourceProj Source projection.
|
|
678
|
+
* @param {import("../tilegrid/TileGrid.js").default} sourceTileGrid Source tile grid.
|
|
679
|
+
* @param {import("../proj/Projection.js").default} targetProj Target projection.
|
|
680
|
+
* @param {import("../tilegrid/TileGrid.js").default} targetTileGrid Target tile grid.
|
|
681
|
+
* @param {import("../tilecoord.js").TileCoord} tileCoord Coordinate of the tile.
|
|
682
|
+
* @param {import("../tilecoord.js").TileCoord} wrappedTileCoord Coordinate of the tile wrapped in X.
|
|
683
|
+
* @param {number} pixelRatio Pixel ratio.
|
|
684
|
+
* @param {number} gutter Gutter of the source tiles.
|
|
685
|
+
* @param {FunctionType} getTileFunction
|
|
686
|
+
* Function returning source tiles (z, x, y, pixelRatio).
|
|
687
|
+
* @param {number} [errorThreshold] Acceptable reprojection error (in px).
|
|
688
|
+
* @param {boolean} [renderEdges] Render reprojection edges.
|
|
689
|
+
* @param {import("../Tile.js").Options} [options] Tile options.
|
|
690
|
+
*/
|
|
691
|
+
constructor(t, e, s, n, i, c, m, _, T, X, x, y) {
|
|
692
|
+
super(i, g.IDLE, y), this.renderEdges_ = x !== void 0 ? x : !1, this.pixelRatio_ = m, this.gutter_ = _, this.canvas_ = null, this.sourceTileGrid_ = e, this.targetTileGrid_ = n, this.wrappedTileCoord_ = c || i, this.sourceTiles_ = [], this.sourcesListenerKeys_ = null, this.sourceZ_ = 0, this.clipExtent_ = t.canWrapX() ? t.getExtent() : void 0;
|
|
693
|
+
const F = n.getTileCoordExtent(
|
|
694
|
+
this.wrappedTileCoord_
|
|
695
|
+
), r = this.targetTileGrid_.getExtent();
|
|
696
|
+
let h = this.sourceTileGrid_.getExtent();
|
|
697
|
+
const E = r ? V(F, r) : F;
|
|
698
|
+
if (st(E) === 0) {
|
|
699
|
+
this.state = g.EMPTY;
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
const l = t.getExtent();
|
|
703
|
+
l && (h ? h = V(h, l) : h = l);
|
|
704
|
+
const f = n.getResolution(
|
|
705
|
+
this.wrappedTileCoord_[0]
|
|
706
|
+
), d = Bt(
|
|
707
|
+
t,
|
|
708
|
+
s,
|
|
709
|
+
E,
|
|
710
|
+
f
|
|
711
|
+
);
|
|
712
|
+
if (!isFinite(d) || d <= 0) {
|
|
713
|
+
this.state = g.EMPTY;
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const u = X !== void 0 ? X : St;
|
|
717
|
+
if (this.triangulation_ = new Ht(
|
|
718
|
+
t,
|
|
719
|
+
s,
|
|
720
|
+
E,
|
|
721
|
+
h,
|
|
722
|
+
d * u,
|
|
723
|
+
f
|
|
724
|
+
), this.triangulation_.getTriangles().length === 0) {
|
|
725
|
+
this.state = g.EMPTY;
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
this.sourceZ_ = e.getZForResolution(d);
|
|
729
|
+
let a = this.triangulation_.calculateSourceExtent();
|
|
730
|
+
if (h && (t.canWrapX() ? (a[1] = rt(
|
|
731
|
+
a[1],
|
|
732
|
+
h[1],
|
|
733
|
+
h[3]
|
|
734
|
+
), a[3] = rt(
|
|
735
|
+
a[3],
|
|
736
|
+
h[1],
|
|
737
|
+
h[3]
|
|
738
|
+
)) : a = V(a, h)), !st(a))
|
|
739
|
+
this.state = g.EMPTY;
|
|
740
|
+
else {
|
|
741
|
+
let w = 0, C = 0;
|
|
742
|
+
t.canWrapX() && (w = L(l), C = Math.floor(
|
|
743
|
+
(a[0] - l[0]) / w
|
|
744
|
+
)), Ot(
|
|
745
|
+
a.slice(),
|
|
746
|
+
t,
|
|
747
|
+
!0
|
|
748
|
+
).forEach((I) => {
|
|
749
|
+
const W = e.getTileRangeForExtentAndZ(
|
|
750
|
+
I,
|
|
751
|
+
this.sourceZ_
|
|
752
|
+
);
|
|
753
|
+
for (let Y = W.minX; Y <= W.maxX; Y++)
|
|
754
|
+
for (let M = W.minY; M <= W.maxY; M++) {
|
|
755
|
+
const v = T(this.sourceZ_, Y, M, m);
|
|
756
|
+
if (v) {
|
|
757
|
+
const D = C * w;
|
|
758
|
+
this.sourceTiles_.push({ tile: v, offset: D });
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
++C;
|
|
762
|
+
}), this.sourceTiles_.length === 0 && (this.state = g.EMPTY);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Get the HTML Canvas element for this tile.
|
|
767
|
+
* @return {HTMLCanvasElement} Canvas.
|
|
768
|
+
*/
|
|
769
|
+
getImage() {
|
|
770
|
+
return this.canvas_;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* @private
|
|
774
|
+
*/
|
|
775
|
+
reproject_() {
|
|
776
|
+
const t = [];
|
|
777
|
+
if (this.sourceTiles_.forEach((e) => {
|
|
778
|
+
const s = e.tile;
|
|
779
|
+
if (s && s.getState() == g.LOADED) {
|
|
780
|
+
const n = this.sourceTileGrid_.getTileCoordExtent(s.tileCoord);
|
|
781
|
+
n[0] += e.offset, n[2] += e.offset;
|
|
782
|
+
const i = this.clipExtent_?.slice();
|
|
783
|
+
i && (i[0] += e.offset, i[2] += e.offset), t.push({
|
|
784
|
+
extent: n,
|
|
785
|
+
clipExtent: i,
|
|
786
|
+
image: s.getImage()
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
}), this.sourceTiles_.length = 0, t.length === 0)
|
|
790
|
+
this.state = g.ERROR;
|
|
791
|
+
else {
|
|
792
|
+
const e = this.wrappedTileCoord_[0], s = this.targetTileGrid_.getTileSize(e), n = typeof s == "number" ? s : s[0], i = typeof s == "number" ? s : s[1], c = this.targetTileGrid_.getResolution(e), m = this.sourceTileGrid_.getResolution(
|
|
793
|
+
this.sourceZ_
|
|
794
|
+
), _ = this.targetTileGrid_.getTileCoordExtent(
|
|
795
|
+
this.wrappedTileCoord_
|
|
796
|
+
);
|
|
797
|
+
this.canvas_ = Gt(
|
|
798
|
+
n,
|
|
799
|
+
i,
|
|
800
|
+
this.pixelRatio_,
|
|
801
|
+
m,
|
|
802
|
+
this.sourceTileGrid_.getExtent(),
|
|
803
|
+
c,
|
|
804
|
+
_,
|
|
805
|
+
this.triangulation_,
|
|
806
|
+
t,
|
|
807
|
+
this.gutter_,
|
|
808
|
+
this.renderEdges_,
|
|
809
|
+
this.interpolate
|
|
810
|
+
), this.state = g.LOADED;
|
|
811
|
+
}
|
|
812
|
+
this.changed();
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Load not yet loaded URI.
|
|
816
|
+
* @override
|
|
817
|
+
*/
|
|
818
|
+
load() {
|
|
819
|
+
if (this.state == g.IDLE) {
|
|
820
|
+
this.state = g.LOADING, this.changed();
|
|
821
|
+
let t = 0;
|
|
822
|
+
this.sourcesListenerKeys_ = [], this.sourceTiles_.forEach(({ tile: e }) => {
|
|
823
|
+
const s = e.getState();
|
|
824
|
+
if (s == g.IDLE || s == g.LOADING) {
|
|
825
|
+
t++;
|
|
826
|
+
const n = Ct(e, lt.CHANGE, (i) => {
|
|
827
|
+
const c = e.getState();
|
|
828
|
+
(c == g.LOADED || c == g.ERROR || c == g.EMPTY) && (at(n), t--, t === 0 && (this.unlistenSources_(), this.reproject_()));
|
|
829
|
+
});
|
|
830
|
+
this.sourcesListenerKeys_.push(n);
|
|
831
|
+
}
|
|
832
|
+
}), t === 0 ? setTimeout(this.reproject_.bind(this), 0) : this.sourceTiles_.forEach(function({ tile: e }, s, n) {
|
|
833
|
+
e.getState() == g.IDLE && e.load();
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* @private
|
|
839
|
+
*/
|
|
840
|
+
unlistenSources_() {
|
|
841
|
+
this.sourcesListenerKeys_.forEach(at), this.sourcesListenerKeys_ = null;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Remove from the cache due to expiry
|
|
845
|
+
* @override
|
|
846
|
+
*/
|
|
847
|
+
release() {
|
|
848
|
+
this.canvas_ && (et(this.canvas_.getContext("2d")), B.push(this.canvas_), this.canvas_ = null), super.release();
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function zt(o, t, e, s) {
|
|
852
|
+
return s !== void 0 ? (s[0] = o, s[1] = t, s[2] = e, s) : [o, t, e];
|
|
853
|
+
}
|
|
854
|
+
function Jt(o, t, e) {
|
|
855
|
+
return o + "/" + t + "/" + e;
|
|
856
|
+
}
|
|
857
|
+
function Vt(o) {
|
|
858
|
+
return bt(o[0], o[1], o[2]);
|
|
859
|
+
}
|
|
860
|
+
function bt(o, t, e) {
|
|
861
|
+
return (t << o) + e;
|
|
862
|
+
}
|
|
863
|
+
function $t(o, t) {
|
|
864
|
+
const e = o[0], s = o[1], n = o[2];
|
|
865
|
+
if (t.getMinZoom() > e || e > t.getMaxZoom())
|
|
866
|
+
return !1;
|
|
867
|
+
const i = t.getFullTileRange(e);
|
|
868
|
+
return i ? i.containsXY(s, n) : !0;
|
|
869
|
+
}
|
|
870
|
+
export {
|
|
871
|
+
St as E,
|
|
872
|
+
Qt as I,
|
|
873
|
+
qt as R,
|
|
874
|
+
gt as T,
|
|
875
|
+
Ht as a,
|
|
876
|
+
Rt as b,
|
|
877
|
+
ct as c,
|
|
878
|
+
zt as d,
|
|
879
|
+
jt as e,
|
|
880
|
+
Jt as g,
|
|
881
|
+
Vt as h,
|
|
882
|
+
Gt as r,
|
|
883
|
+
$t as w
|
|
884
|
+
};
|