• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iTowns / itowns / 10902507646

17 Sep 2024 11:56AM UTC coverage: 86.931% (-0.03%) from 86.964%
10902507646

push

github

Desplandis
release v2.44.2

2791 of 3694 branches covered (75.55%)

Branch coverage included in aggregate %.

24241 of 27402 relevant lines covered (88.46%)

1027.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

59.68
/src/Source/C3DTilesIonSource.js
1
import Fetcher from 'Provider/Fetcher';
1✔
2
import C3DTilesSource from './C3DTilesSource';
1✔
3

1✔
4
/**
1✔
5
 * An object defining the source connection to a 3DTiles asset of a [Cesium ion server](https://cesium.com/learn/ion/).
1✔
6
 *
1✔
7
 * @extends Source
1✔
8
 *
1✔
9
 * @property {boolean} isC3DTilesIonSource - Used to checkout whether this source is a C3DTilesIonSource. Default is
1✔
10
 * true. You should not change this, as it is used internally for optimisation.
1✔
11
 * @property {string} url - The URL of the tileset json.
1✔
12
 * @property {string} baseUrl - The base URL to access tiles.
1✔
13
 * @property {string} accessToken - The Cesium ion access token used to retrieve the resource.
1✔
14
 * @property {string} assetId - The id of the asset on Cesium ion.
1✔
15
 */
1✔
16
class C3DTilesIonSource extends C3DTilesSource {
1✔
17
    /**
1✔
18
     * Create a new Source for 3D Tiles data from Cesium ion.
1✔
19
     *
1✔
20
     * @extends Source
1✔
21
     *
1✔
22
     * @param {Object} source An object that can contain all properties of a C3DTilesIonSource and {@link Source}.
1✔
23
     * Only `accessToken` and `assetId` are mandatory.
1✔
24
     */
1✔
25
    constructor(source) {
1✔
26
        if (!source.accessToken) {
3✔
27
            throw new Error('New 3D Tiles Ion Source: access token is required');
2✔
28
        }
2✔
29
        if (!source.assetId) {
1✔
30
            throw new Error('New 3D Tiles Ion Source: asset id is required');
1✔
31
        }
1!
32

×
33
        // Url to query cesium ion the first time to retrieve metadata of the asset with assetId
×
34
        source.url = `https://api.cesium.com/v1/assets/${source.assetId}/endpoint?access_token=${source.accessToken}`;
×
35
        super(source);
×
36

×
37
        this.isC3DTilesIonSource = true;
×
38
        this.accessToken = source.accessToken;
×
39
        this.assetId = source.assetId;
×
40

×
41
        // get asset metadata
×
42
        this.whenReady = Fetcher.json(source.url, this.networkOptions)
×
43
            .then((json) => {
×
44
                if (json.type !== '3DTILES') {
×
45
                    throw new Error(`${json.type} datasets from Cesium ion are not supported with C3DTilesIonSource. ` +
×
46
                    'Only 3D Tiles datasets are supported.');
×
47
                }
×
48
                this.url = json.url; // Store url to the tileset.json
×
49
                this.baseUrl = json.url.slice(0, json.url.lastIndexOf('/') + 1); // baseUrl for tiles queries
×
50
                this.networkOptions.headers = {};
×
51
                this.networkOptions.headers.Authorization = `Bearer ${json.accessToken}`;
×
52
                this.attribution = json.attributions;
×
53
                return Fetcher.json(this.url, this.networkOptions);
×
54
            });
×
55
    }
×
56
}
1✔
57

1✔
58
export default C3DTilesIonSource;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc