Expand description
§cjval: a validator for CityJSON
A Rust library and binaries to validate the syntax of CityJSON objects (CityJSON + CityJSONSeq).
It validates against the CityJSON schemas and additional functions have been implemented (because these checks cannot be expressed with JSON Schemas).
The following error checks are performed:
- JSON syntax: is it a valid JSON object?
- CityJSON schemas: validation against the schemas (CityJSON v1.0 + v1.1 + v2.0)
- Extension schemas: validate against the extra schemas if there’s an Extension (those are automatically fetched from a URL)
- parents_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 its"parents"
- 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
- textures: checks if the arrays for the textures are coherent (if the vertices exist + if the texture exists)
- materials: checks if the arrays for the materials are coherent with the geometry objects and if the material exists
It also verifies the following, these are not errors but warnings 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 space and decrease 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.
§A library + 2 binaries
cjval
is a library and has 2 different binaries:
cjval
to validate a CityJSON file or a CityJSONSeq stream (it downloads Extensions automatically if the file contains some)cjvalext
to validate a CityJSON Extension file
§Example use
extern crate cjval;
fn main() {
let s1 = std::fs::read_to_string("/Users/hugo/projects/cjval/data/cube.city.json")
.expect("Couldn't read CityJSON file");
let v = cjval::CJValidator::from_str(&s1);
let re = v.validate();
for (criterion, sum) in re.iter() {
println!("=== {} ===", criterion);
println!("{}", sum);
}
}
§Installation/compilation
§To install the binaries on your system easily
- install the Rust compiler
cargo install cjval --features build-binary
Structs§
- CJValidator
- A validator for CityJSON and CityJSONFeature
- ValSummary
- Summary of a validation. It is possible that a validation check has not been performed because other checks returned errors (we do not want to have cascading errors).