mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
Merge pull request #911 from bilawalsidhu/fix/lazy-bundled-asset-urls
fix: resolve bundled data URLs when used, not at import
This commit is contained in:
3 files changed
+29
-22
No files matched your search
@@ -1,15 +1,14 @@
|
|||||||
import { createLocalGeoJsonLayer } from './localGeojsonCore.js';
|
import { createLocalGeoJsonLayer } from './localGeojsonCore.js';
|
||||||
import { INFRASTRUCTURE_DATA_URLS } from '../sources/infrastructureData.js';
|
import { INFRASTRUCTURE_DATA_URLS } from '../sources/infrastructureData.js';
|
||||||
|
|
||||||
const datacentersUrl = INFRASTRUCTURE_DATA_URLS['local-datacenters'];
|
|
||||||
const damsUrl = INFRASTRUCTURE_DATA_URLS['local-dams'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create fresh datacenter and dam layers without starting or loading them.
|
* Create fresh datacenter and dam layers without starting or loading them.
|
||||||
* @param {object} services Caller-owned context, overlay and render operations.
|
* @param {object} services Caller-owned context, overlay and render operations.
|
||||||
* @returns {object[]} Datacenters then dams, with stable standalone identities.
|
* @returns {object[]} Datacenters then dams, with stable standalone identities.
|
||||||
*/
|
*/
|
||||||
export function createInfrastructureLayers(services) {
|
export function createInfrastructureLayers(services) {
|
||||||
|
const datacentersUrl = INFRASTRUCTURE_DATA_URLS['local-datacenters'];
|
||||||
|
const damsUrl = INFRASTRUCTURE_DATA_URLS['local-dams'];
|
||||||
const datacenters = createLocalGeoJsonLayer(
|
const datacenters = createLocalGeoJsonLayer(
|
||||||
{
|
{
|
||||||
id: 'local-datacenters',
|
id: 'local-datacenters',
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
// This dataset is CC BY-NC-SA 3.0, not the project's MIT license.
|
// This dataset is CC BY-NC-SA 3.0, not the project's MIT license.
|
||||||
// Commercial users must remove it or obtain a TeleGeography license.
|
// Commercial users must remove it or obtain a TeleGeography license.
|
||||||
// See DATA_SOURCES.md and the bundled dataset's source.json.
|
// See DATA_SOURCES.md and the bundled dataset's source.json.
|
||||||
const cableUrl = new URL(
|
// Resolved when read, so importing this module never needs a module URL.
|
||||||
'../../data/local_data/telegeography_submarine_cables/cable-geo.json',
|
function cableUrl() {
|
||||||
import.meta.url,
|
return new URL(
|
||||||
).href;
|
'../../data/local_data/telegeography_submarine_cables/cable-geo.json',
|
||||||
const landingPointUrl = new URL(
|
import.meta.url,
|
||||||
'../../data/local_data/telegeography_submarine_cables/landing-point-geo.json',
|
).href;
|
||||||
import.meta.url,
|
}
|
||||||
).href;
|
function landingPointUrl() {
|
||||||
|
return new URL(
|
||||||
|
'../../data/local_data/telegeography_submarine_cables/landing-point-geo.json',
|
||||||
|
import.meta.url,
|
||||||
|
).href;
|
||||||
|
}
|
||||||
|
|
||||||
/** Supply GeoJSON collections without coupling the renderer to asset URLs. */
|
/** Supply GeoJSON collections without coupling the renderer to asset URLs. */
|
||||||
export function createBundledCableSource({
|
export function createBundledCableSource({
|
||||||
@@ -33,8 +38,8 @@ export function createBundledCableSource({
|
|||||||
label: 'TeleGeography',
|
label: 'TeleGeography',
|
||||||
async fetch(signal) {
|
async fetch(signal) {
|
||||||
const [cables, landingPoints] = await Promise.all([
|
const [cables, landingPoints] = await Promise.all([
|
||||||
read(cableUrl, signal),
|
read(cableUrl(), signal),
|
||||||
read(landingPointUrl, signal),
|
read(landingPointUrl(), signal),
|
||||||
]);
|
]);
|
||||||
return { cables, landingPoints };
|
return { cables, landingPoints };
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,16 +3,19 @@
|
|||||||
* data files, line-delimited GeoJSON parsing and analyst records.
|
* data files, line-delimited GeoJSON parsing and analyst records.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Resolved by Vite in builds and relative to this module in other consumers.
|
// Resolved by Vite in builds and relative to this module in other consumers,
|
||||||
|
// when read, so importing this module never needs a module URL.
|
||||||
export const INFRASTRUCTURE_DATA_URLS = Object.freeze({
|
export const INFRASTRUCTURE_DATA_URLS = Object.freeze({
|
||||||
'local-datacenters': new URL(
|
get 'local-datacenters'() {
|
||||||
'../data/local_data/datacenters/datacenters.geojsonl',
|
return new URL(
|
||||||
import.meta.url,
|
'../data/local_data/datacenters/datacenters.geojsonl',
|
||||||
).href,
|
import.meta.url,
|
||||||
'local-dams': new URL(
|
).href;
|
||||||
'../data/local_data/dams/dams.geojsonl',
|
},
|
||||||
import.meta.url,
|
get 'local-dams'() {
|
||||||
).href,
|
return new URL('../data/local_data/dams/dams.geojsonl', import.meta.url)
|
||||||
|
.href;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Parse GeoJSON Lines: one Feature per non-empty line. */
|
/** Parse GeoJSON Lines: one Feature per non-empty line. */
|
||||||
|
|||||||
Reference in new issue
Block a user