Skip to content

Commit

Permalink
Merge pull request #305 from CesiumGS/fix-external-tilesets-extension…
Browse files Browse the repository at this point in the history
…s-validation

Fix external tilesets extensions validation
  • Loading branch information
lilleyse committed Mar 25, 2024
2 parents 1cfbd4f + 03dee12 commit 8a3607b
Show file tree
Hide file tree
Showing 19 changed files with 472 additions and 3 deletions.
80 changes: 80 additions & 0 deletions specs/ExternalTilesetExtensionsValidationSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Validators } from "../src/validation/Validators";

// Note: These test cases use a dummy extension called
// VENDOR_example_extension
// So they will always create at least a WARNING about
// this not being supported

describe("External tileset extensions validation", function () {
it("detects no errors in declaredInBothContainedInExternal", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInBothContainedInExternal/tileset.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("EXTERNAL_TILESET_VALIDATION_WARNING");
expect(result.get(0).causes[0].type).toEqual("EXTENSION_NOT_SUPPORTED");
});

it("detects no errors (but one warning) in declaredInBothContainedInTileset", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInBothContainedInTileset/tileset.json"
);
expect(result.length).toEqual(2);
expect(result.get(0).type).toEqual("EXTENSION_NOT_SUPPORTED");
expect(result.get(1).type).toEqual("EXTERNAL_TILESET_VALIDATION_WARNING");
expect(result.get(1).causes[0].type).toEqual(
"EXTENSION_USED_BUT_NOT_FOUND"
);
});

it("detects an error in declaredInExternalContainedInExternal", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInExternalContainedInExternal/tileset.json"
);
expect(result.length).toEqual(2);
expect(result.get(0).type).toEqual("EXTERNAL_TILESET_VALIDATION_WARNING");
expect(result.get(0).causes[0].type).toEqual("EXTENSION_NOT_SUPPORTED");
expect(result.get(1).type).toEqual("EXTENSION_FOUND_BUT_NOT_USED");
});

it("detects an error and a warning in declaredInExternalContainedInTileset", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInExternalContainedInTileset/tileset.json"
);
expect(result.length).toEqual(3);
expect(result.get(0).type).toEqual("EXTENSION_NOT_SUPPORTED");
expect(result.get(1).type).toEqual("EXTERNAL_TILESET_VALIDATION_WARNING");
expect(result.get(1).causes[0].type).toEqual(
"EXTENSION_USED_BUT_NOT_FOUND"
);
expect(result.get(2).type).toEqual("EXTENSION_FOUND_BUT_NOT_USED");
});

it("detects two errors in declaredInNoneContainedInExternal", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInNoneContainedInExternal/tileset.json"
);
expect(result.length).toEqual(2);
expect(result.get(0).type).toEqual("EXTERNAL_TILESET_VALIDATION_ERROR");
expect(result.get(1).type).toEqual("EXTENSION_FOUND_BUT_NOT_USED");
});

it("detects one error in declaredInTilesetContainedInExternal", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInTilesetContainedInExternal/tileset.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("EXTERNAL_TILESET_VALIDATION_ERROR");
expect(result.get(0).causes[1].type).toEqual(
"EXTENSION_FOUND_BUT_NOT_USED"
);
});

it("detects no errors in declaredInTilesetContainedInTileset", async function () {
const result = await Validators.validateTilesetFile(
"specs/data/tilesets/externalTilesetExtensions/declaredInTilesetContainedInTileset/tileset.json"
);
expect(result.length).toEqual(1);
expect(result.get(0).type).toEqual("EXTENSION_NOT_SUPPORTED");
});
});
25 changes: 25 additions & 0 deletions specs/data/tilesets/externalTilesetExtensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Test data for the validation of extensions in the context of external tilesets.

(This is a special aspect of https://github.com/CesiumGS/3d-tiles-validator/issues/231 ).

Each of these data sets consists of a `tileset.json` that refers to an `external.json`.

They use a "dummy" extension called `VENDOR_example_extension` to check the validation
of the `extensionsUsed` propery of a tileset. (This means that the validation will
always at least create one warning, because the extension is not supported).

In the following, the term..

- 'declared' means that a tileset declares the extension in its `extesionsUsed`
- 'contained' means that the tileset actually contains such an extension object in its `extensions`

These cases are considered:

- `declaredInBothContainedInExternal`: This is valid. The external tileset contains it and declares it. The main tileset also declares it (because it refers to one that contains it).
- `declaredInBothContainedInTileset`: This valid, but causes a warning. The external tileset does not have to declare it if it does not contain it.
- `declaredInExternalContainedInExternal`: This is invalid. The main tileset also has to declare it when it refers to one that contains it.
- `declaredInExternalContainedInTileset`: This is invalid. The main tileset has to declare it if it contains it.
- `declaredInNoneContainedInExternal`: This is invalid. Both tilesets have to declare it when the external one contains it.
- `declaredInTilesetContainedInExternal`: This is invalid. The external one also has to declare it when it contains it
- `declaredInTilesetContainedInTileset`: This is valid. Only the main tileset has to declare it if only the main tileset contains it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0
},
"extensionsUsed": [
"VENDOR_example_extension"
],
"extensions": {
"VENDOR_example_extension": {
"exampleExtension": {
"description": "A dummy example extension"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0,
"children": [
{
"geometricError" : 1.0,
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"content": {
"uri": "external.json"
}
}
]
},
"extensionsUsed": [
"VENDOR_example_extension"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0
},
"extensionsUsed": [
"VENDOR_example_extension"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0,
"children": [
{
"geometricError" : 1.0,
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"content": {
"uri": "external.json"
}
}
]
},
"extensionsUsed": [
"VENDOR_example_extension"
],
"extensions": {
"VENDOR_example_extension": {
"exampleExtension": {
"description": "A dummy example extension"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0
},
"extensionsUsed": [
"VENDOR_example_extension"
],
"extensions": {
"VENDOR_example_extension": {
"exampleExtension": {
"description": "A dummy example extension"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0,
"children": [
{
"geometricError" : 1.0,
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"content": {
"uri": "external.json"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0
},
"extensionsUsed": [
"VENDOR_example_extension"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0,
"children": [
{
"geometricError" : 1.0,
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"content": {
"uri": "external.json"
}
}
]
},
"extensions": {
"VENDOR_example_extension": {
"exampleExtension": {
"description": "A dummy example extension"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0
},
"extensions": {
"VENDOR_example_extension": {
"exampleExtension": {
"description": "A dummy example extension"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0,
"children": [
{
"geometricError" : 1.0,
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"content": {
"uri": "external.json"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"asset" : {
"version" : "1.1"
},
"geometricError" : 4.0,
"root" : {
"refine": "REPLACE",
"boundingVolume" : {
"box" : [ 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5 ]
},
"geometricError" : 2.0
},
"extensions": {
"VENDOR_example_extension": {
"exampleExtension": {
"description": "A dummy example extension"
}
}
}
}
Loading

0 comments on commit 8a3607b

Please sign in to comment.