Expand description
§CityJSONSeq
Create, process, modify, and convert CityJSONSeq files.
§Cross-platform Support
This crate supports both native platforms and WebAssembly (WASM):
- Native platforms: Uses
reqwest
for HTTP requests. - WASM targets: Uses
gloo-net
for HTTP requests.
When compiling for WASM, note that some functionality works differently:
- The synchronous
fetch_from_url
method returns a placeholder in WASM environments. - Use the
fetch_from_url_async
method when working with WASM targets.
§Example
use cjseq2::{CityJSON, CityJSONFeature, Extension, ExtensionFile};
use std::collections::HashMap;
// To process a CityJSON file:
let json_str = std::fs::read_to_string("path/to/file.json").unwrap();
let city_json = CityJSON::from_str(&json_str).unwrap();
// To fetch extension data (native platforms):
#[cfg(not(target_arch = "wasm32"))]
{
// Make sure to create a long-lived reference to the extension
let extensions = &city_json.extensions.unwrap();
let extension = extensions.get("my_extension").unwrap();
let extension_file = extension.fetch_extension_file("MyExt".to_string()).unwrap();
}
// To fetch extension data (WASM):
#[cfg(target_arch = "wasm32")]
async {
if let Some(extensions) = &city_json.extensions {
if let Some(extension) = extensions.get("my_extension") {
let extension_file = ExtensionFile::fetch_from_url_async(
"MyExt".to_string(),
extension.url.clone(),
extension.version.clone()
).await.unwrap();
}
}
}
Re-exports§
pub use error::*;
Modules§
Structs§
- Address
- Appearance
- CityJSON
- CityJSON
Feature - City
Object - Extension
- Extension
File - Geometry
- Geometry
Templates - Material
Object - Material
Reference - Metadata
- Point
OfContact - Reference
System - A reference system following the OGC Name Type Specification.
- Semantics
- Semantics
Surface - Texture
Object - Texture
Reference - Transform
Enums§
- Geometry
Type - Nested
Array - Our nested structure, generic over
T
. - Sorting
Strategy - Text
Format - Text
Type - Wrap
Mode
Traits§
Type Aliases§
- Boundaries
- For convenience, define
Boundaries
asNestedArray<u32>
(no null allowed). - Geographical
Extent - Material
Values - Semantics
Values - For Semantics, define
SemanticsValues
asNestedArray<Option<u32>>
(null allowed). - Texture
Values