cjval -- CityJSON validator
A validator for CityJSON files, it validates a CityJSON against its schemas and additional functions have been implemented (because these can't be expressed with JSON Schema).
What is validated exactly?
Schema validation means: is the syntax of the file OK?
The following is performed by cjval
:
- JSON syntax: is the file a valid JSON file?
- CityJSON schemas: validation against the schemas (CityJSON v1.0 or v1.1)
- Extension schemas: validate against the extra schemas if there's an Extension in the input file
- parent_children_consistency: if a City Object references another in its
children
, this ensures that the child exists. And that the child has the parent in itsparents
- wrong_vertex_index: checks if all vertex indices exist in the list of vertices
- semantics_array: checks if the arrays for the semantics in the geometries have the same shape as that of the geometry and if the values are consistent
It also verifies the following, these are not errors since the file is still considered valid and usable, but they can make the file larger and some parsers might not understand all the properties:
- extra_root_properties: if CityJSON has extra root properties, these should be documented in an Extension. If not this warning is returned
- duplicate_vertices: duplicated vertices in
vertices
are allowed, but they take up spaces and decreases the topological relationships explicitly in the file. If there are any, cjio has the operatorclean
to fix this automatically. - unused_vertices: vertices that are not referenced in the file, they take extra space. If there are any, cjio has the operator
clean
to fix this automatically.
Usage
The CityJSON schemas are built-in the program, so it suffices to:
$ cjval myfile.city.json
(the latest schemas of a X.Y version will be automatically fetched)
If the file contains one or more Extensions, eg:
Then cjval
will fetch/download automatically the schema(s).
If instead you want to use your own schema(s), you can pass them instead with the argument -e
:
$ cjval myfile.city.json -e ./myextensions/generic.ext.json
Web application
The same code is use for https://validator.cityjson.org
The code is there: https://github.com/cityjson/cjval_wasm
Installation/compilation
- install the Rust compiler
cargo build --release --features build-binary
./target/release/cjval myfile.json
Contributors
- @hugoledoux
- @josfeenstra (started the project for a course at TU Delft, original code)