mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-11 22:02:21 +00:00
Use a neutral compact switch codec and clarify provider size limits
This commit is contained in:
1 parent
fbe118aab9
commit
3ba8c6d61b
11 files changed
+127
-98
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { encodeProviderSwitches } from './providerSwitches.js';
|
||||
import { encodeIdSwitches } from '../../data/idSwitches.js';
|
||||
|
||||
/**
|
||||
* The contract an imagery provider registers with the Street Level layer.
|
||||
@@ -128,7 +128,18 @@ export function validateProviders(providers) {
|
||||
prefixes.push(provider.pickPrefix);
|
||||
}
|
||||
// Validate the complete bounded share field once, before any instance exists.
|
||||
encodeProviderSwitches(providers.map(({ id }) => [id, true]));
|
||||
try {
|
||||
encodeIdSwitches(
|
||||
providers
|
||||
.filter(({ id }) => id !== 'mapillary')
|
||||
.map(({ id }) => [id, true]),
|
||||
);
|
||||
} catch (error) {
|
||||
if (!(error instanceof RangeError)) throw error;
|
||||
throw new RangeError(
|
||||
'Street Level provider IDs cannot fit in the 256-character share-link field; use shorter IDs or fewer providers',
|
||||
);
|
||||
}
|
||||
return Object.freeze([...providers]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user