leaflet-city-mapper 0.0.7 → 0.0.9
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 +2 -2
- package/cucumber.mjs +1 -3
- package/dist/leaflet-city-mapper-src.js +403 -201
- package/dist/leaflet-city-mapper-src.js.map +4 -4
- package/dist/leaflet-city-mapper-worker-src.js +69 -59
- package/dist/leaflet-city-mapper-worker-src.js.map +3 -3
- package/dist/leaflet-city-mapper-worker.js +1 -1
- package/dist/leaflet-city-mapper-worker.js.map +4 -4
- package/dist/leaflet-city-mapper.js +5 -5
- package/dist/leaflet-city-mapper.js.map +4 -4
- package/libs/leaflet-lens.js +44 -27
- package/libs/leaflet.js +4 -4
- package/libs/openlayers-bindings.js +2 -1
- package/libs/openlayers-bindings.min.js +1 -1
- package/libs/openlayers-bindings.min.js.map +3 -3
- package/package.json +5 -3
- package/src/camera/mapCamera.js +7 -7
- package/src/camera/mapTryAnimatedPan.js +4 -4
- package/src/camera/updateMapCamera.js +8 -6
- package/src/controls/cameraControls.js +27 -22
- package/src/core/cameraCircleBounds.js +2 -1
- package/src/core/closestCameraLayerPoint.js +2 -1
- package/src/core/constructLayer.js +9 -0
- package/src/core/extendLeafletClass.js +5 -0
- package/src/core/extendTerrainPixelBounds.js +31 -0
- package/src/core/gridlayerGetTiledPixelBounds.js +2 -27
- package/src/core/layerAddInitHook.js +7 -0
- package/src/core/layerCallInitHooks.js +13 -13
- package/src/core/layerMergeOptions.js +7 -0
- package/src/core/projectNativePath.js +23 -0
- package/src/geometry/circleGeometry.js +4 -3
- package/src/globals/layerControlAddItem.js +3 -0
- package/src/globals/leafletLayer.js +3 -0
- package/src/globals/workerCogSource.js +1 -1
- package/src/gpu/initializeRendererResources.js +10 -12
- package/src/index.js +26 -11
- package/src/layer-controls/layerControlInputId.js +11 -0
- package/src/layer-controls/placeEntry.js +2 -0
- package/src/materials/createProgram.js +7 -6
- package/src/native/gridTerrainElevation.js +7 -11
- package/src/native/nativeTerrainElevation.js +16 -0
- package/src/native/prepareGridTerrainRequests.js +16 -0
- package/src/native/retainGridTerrain.js +10 -0
- package/src/native/syncGridLayer.js +12 -59
- package/src/native/syncGridTile.js +18 -0
- package/src/native/syncTerrainGridTile.js +28 -0
- package/src/rendering/drawGeometry.js +11 -11
- package/src/rendering/resizeRenderer.js +16 -15
- package/src/scene/initializerFor.js +2 -1
- package/src/scene/layerInitialize.js +1 -1
- package/src/shadows/drawShadowMeshes.js +6 -5
- package/src/sources/pumpSourceAreas.js +1 -1
- package/src/sunlight/initSunlight.js +19 -8
- package/src/textures/nativeTextureFor.js +2 -3
- package/src/textures/uploadCanvasTexture.js +11 -2
- package/src/vector-tiles/createVectorLabel.js +22 -0
- package/src/vector-tiles/prepareVectorLabel.js +17 -35
- package/src/vector-tiles/updateVectorLabelStyle.js +8 -0
- package/src/vector-tiles/vectorLabelCells.js +2 -5
- package/src/vector-tiles/vectorLabelIcon.js +1 -1
- package/src/vector-tiles/vectorLabelText.js +10 -0
- package/src/walk/initWalk.js +19 -6
- package/src/weakmaps/pathProjectionByMap.js +1 -0
- package/src/workers/cogWorker.js +4 -5
- package/src/globals/layerCallInitHooks.js +0 -1
|
@@ -1681,22 +1681,6 @@
|
|
|
1681
1681
|
return zoom;
|
|
1682
1682
|
}
|
|
1683
1683
|
|
|
1684
|
-
// src/vector-tiles/projectVectorPoint.js
|
|
1685
|
-
function projectVectorPoint(point, coords, extent) {
|
|
1686
|
-
const size = 2 ** coords.z;
|
|
1687
|
-
const x = (coords.x + point[0] / extent) / size;
|
|
1688
|
-
const y = (coords.y + point[1] / extent) / size;
|
|
1689
|
-
return (
|
|
1690
|
-
/* alloc */
|
|
1691
|
-
[Math.atan(Math.sinh(Math.PI * (1 - 2 * y))) * 180 / Math.PI, x * 360 - 180]
|
|
1692
|
-
);
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
// src/vector-tiles/vectorLabelProperty.js
|
|
1696
|
-
function vectorLabelProperty(properties, match, key) {
|
|
1697
|
-
return properties[key] ?? "";
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
1684
|
// src/vector-tiles/vectorStyleValue.js
|
|
1701
1685
|
function vectorStyleValue(object, key, fallback, properties, zoom) {
|
|
1702
1686
|
return object?.[key] === void 0 ? fallback : evaluateStyle(object[key], properties, zoom);
|
|
@@ -1754,16 +1738,74 @@
|
|
|
1754
1738
|
return anchors;
|
|
1755
1739
|
}
|
|
1756
1740
|
|
|
1757
|
-
// src/vector-tiles/
|
|
1758
|
-
function
|
|
1741
|
+
// src/vector-tiles/vectorLabelProperty.js
|
|
1742
|
+
function vectorLabelProperty(properties, match, key) {
|
|
1743
|
+
return properties[key] ?? "";
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
// src/vector-tiles/vectorLabelText.js
|
|
1747
|
+
function vectorLabelText(entry, properties, zoom) {
|
|
1759
1748
|
let text = entry.layout?.["text-field"];
|
|
1760
|
-
const { properties } = feature, { zoom } = job;
|
|
1761
|
-
const icon = entry.layout?.["symbol-placement"] === "line" ? null : evaluateStyle(entry.layout?.["icon-image"], properties, zoom);
|
|
1762
1749
|
if (Array.isArray(text)) text = evaluateStyle(text, properties, zoom);
|
|
1763
1750
|
if (typeof text !== "string") text = "";
|
|
1764
1751
|
text = text.replace(/\{([^}]+)\}/g, vectorLabelProperty.bind(null, properties));
|
|
1752
|
+
return entry.layout?.["text-transform"] === "uppercase" ? text.toUpperCase() : text;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// src/vector-tiles/projectVectorPoint.js
|
|
1756
|
+
function projectVectorPoint(point, coords, extent) {
|
|
1757
|
+
const size = 2 ** coords.z;
|
|
1758
|
+
const x = (coords.x + point[0] / extent) / size;
|
|
1759
|
+
const y = (coords.y + point[1] / extent) / size;
|
|
1760
|
+
return (
|
|
1761
|
+
/* alloc */
|
|
1762
|
+
[Math.atan(Math.sinh(Math.PI * (1 - 2 * y))) * 180 / Math.PI, x * 360 - 180]
|
|
1763
|
+
);
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
// src/vector-tiles/createVectorLabel.js
|
|
1767
|
+
function createVectorLabel(job, layer, entry, properties, order, text, icon, anchor, size) {
|
|
1768
|
+
return (
|
|
1769
|
+
/* alloc */
|
|
1770
|
+
{
|
|
1771
|
+
text,
|
|
1772
|
+
latlng: projectVectorPoint(anchor.point, job.coords, layer.extent),
|
|
1773
|
+
order,
|
|
1774
|
+
entry,
|
|
1775
|
+
properties,
|
|
1776
|
+
size,
|
|
1777
|
+
pixelBase: anchor.length * 256 / layer.extent / 2 ** job.coords.z,
|
|
1778
|
+
along: anchor.a ? (
|
|
1779
|
+
/* alloc */
|
|
1780
|
+
[
|
|
1781
|
+
projectVectorPoint(anchor.a, job.coords, layer.extent),
|
|
1782
|
+
projectVectorPoint(anchor.b, job.coords, layer.extent)
|
|
1783
|
+
]
|
|
1784
|
+
) : null,
|
|
1785
|
+
icon: text.trim() ? null : icon,
|
|
1786
|
+
iconOffset: evaluateStyle(entry.layout?.["icon-offset"], properties, job.zoom) || /* alloc */
|
|
1787
|
+
[0, 0],
|
|
1788
|
+
allowOverlap: entry.layout?.["icon-allow-overlap"] === true,
|
|
1789
|
+
color: vectorStyleValue(entry.paint, "text-color", "#000", properties, job.zoom),
|
|
1790
|
+
halo: vectorStyleValue(entry.paint, "text-halo-color", "#fff", properties, job.zoom),
|
|
1791
|
+
haloWidth: vectorStyleValue(entry.paint, "text-halo-width", 0, properties, job.zoom),
|
|
1792
|
+
priority: (
|
|
1793
|
+
/* alloc */
|
|
1794
|
+
["place_labels", "place"].includes(entry["source-layer"]) ? 0 : (
|
|
1795
|
+
/* alloc */
|
|
1796
|
+
["street_labels", "transportation_name"].includes(entry["source-layer"]) ? 1 : 2
|
|
1797
|
+
)
|
|
1798
|
+
)
|
|
1799
|
+
}
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
// src/vector-tiles/prepareVectorLabel.js
|
|
1804
|
+
function prepareVectorLabel(job, layer, entry, feature, order) {
|
|
1805
|
+
const { properties } = feature, { zoom } = job;
|
|
1806
|
+
const text = vectorLabelText(entry, properties, zoom);
|
|
1807
|
+
const icon = entry.layout?.["symbol-placement"] === "line" ? null : evaluateStyle(entry.layout?.["icon-image"], properties, zoom);
|
|
1765
1808
|
if (!text.trim() && typeof icon !== "string") return;
|
|
1766
|
-
if (entry.layout?.["text-transform"] === "uppercase") text = text.toUpperCase();
|
|
1767
1809
|
const size = vectorStyleValue(entry.layout, "text-size", 12, properties, zoom), line = feature.type === 2 && text.trim();
|
|
1768
1810
|
const spacing = layer.extent / 16, anchors = (
|
|
1769
1811
|
/* alloc */
|
|
@@ -1780,39 +1822,7 @@
|
|
|
1780
1822
|
}
|
|
1781
1823
|
for (anchor of anchors) {
|
|
1782
1824
|
if (anchor.point[0] < 0 || anchor.point[0] >= layer.extent || anchor.point[1] < 0 || anchor.point[1] >= layer.extent) continue;
|
|
1783
|
-
job.labels.push(
|
|
1784
|
-
/* alloc */
|
|
1785
|
-
{
|
|
1786
|
-
text,
|
|
1787
|
-
latlng: projectVectorPoint(anchor.point, job.coords, layer.extent),
|
|
1788
|
-
order,
|
|
1789
|
-
entry,
|
|
1790
|
-
properties,
|
|
1791
|
-
size,
|
|
1792
|
-
pixelBase: anchor.length * 256 / layer.extent / 2 ** job.coords.z,
|
|
1793
|
-
along: anchor.a ? (
|
|
1794
|
-
/* alloc */
|
|
1795
|
-
[
|
|
1796
|
-
projectVectorPoint(anchor.a, job.coords, layer.extent),
|
|
1797
|
-
projectVectorPoint(anchor.b, job.coords, layer.extent)
|
|
1798
|
-
]
|
|
1799
|
-
) : null,
|
|
1800
|
-
icon: text.trim() ? null : icon,
|
|
1801
|
-
iconOffset: evaluateStyle(entry.layout?.["icon-offset"], properties, zoom) || /* alloc */
|
|
1802
|
-
[0, 0],
|
|
1803
|
-
allowOverlap: entry.layout?.["icon-allow-overlap"] === true,
|
|
1804
|
-
color: vectorStyleValue(entry.paint, "text-color", "#000", properties, zoom),
|
|
1805
|
-
halo: vectorStyleValue(entry.paint, "text-halo-color", "#fff", properties, zoom),
|
|
1806
|
-
haloWidth: vectorStyleValue(entry.paint, "text-halo-width", 0, properties, zoom),
|
|
1807
|
-
priority: (
|
|
1808
|
-
/* alloc */
|
|
1809
|
-
["place_labels", "place"].includes(entry["source-layer"]) ? 0 : (
|
|
1810
|
-
/* alloc */
|
|
1811
|
-
["street_labels", "transportation_name"].includes(entry["source-layer"]) ? 1 : 2
|
|
1812
|
-
)
|
|
1813
|
-
)
|
|
1814
|
-
}
|
|
1815
|
-
);
|
|
1825
|
+
job.labels.push(createVectorLabel(job, layer, entry, properties, order, text, icon, anchor, size));
|
|
1816
1826
|
}
|
|
1817
1827
|
}
|
|
1818
1828
|
|
|
@@ -3165,7 +3175,7 @@
|
|
|
3165
3175
|
}
|
|
3166
3176
|
|
|
3167
3177
|
// src/globals/workerCogSource.js
|
|
3168
|
-
var workerCogSource =
|
|
3178
|
+
var workerCogSource = /* @__PURE__ */ new Map();
|
|
3169
3179
|
|
|
3170
3180
|
// src/workers/cogWorker.js
|
|
3171
3181
|
async function onCogMessage({ data }) {
|
|
@@ -3174,11 +3184,11 @@
|
|
|
3174
3184
|
/* alloc */
|
|
3175
3185
|
[data.url, data.asset]
|
|
3176
3186
|
);
|
|
3177
|
-
if (workerCogSource.key
|
|
3178
|
-
workerCogSource.key
|
|
3179
|
-
workerCogSource.
|
|
3187
|
+
if (!workerCogSource.has(key)) {
|
|
3188
|
+
workerCogSource.set(key, openCog(data.url, data.asset));
|
|
3189
|
+
if (workerCogSource.size > 4) workerCogSource.delete(workerCogSource.keys().next().value);
|
|
3180
3190
|
}
|
|
3181
|
-
const archive = await workerCogSource.
|
|
3191
|
+
const archive = await workerCogSource.get(key);
|
|
3182
3192
|
const result = data.z === void 0 ? await archive.getHeader() : await archive.getZxy(data.z, data.x, data.y);
|
|
3183
3193
|
const transfers = (
|
|
3184
3194
|
/* alloc */
|