qualia_geospatial/
manifest.rs1use super::geotiff::CompressionCodec;
7
8#[derive(Debug, Clone, PartialEq)]
10pub struct SpatialAssetManifest {
11 pub asset_id: String,
12 pub source_title: String,
13 pub authoritative_provider: String,
14 pub license_iri: String,
15 pub srid: u32,
16 pub vertical_datum: u16,
17 pub bbox_lat_lon: [f64; 4], pub hilbert_range: (u64, u64),
19 pub compression_codec: CompressionCodec,
20 pub multiresolution_levels: u8,
21 pub dggs_cell_id: String,
22 pub wfs_feature_ref: String,
23 pub provenance_did_hash: u64,
24 pub retrieval_epoch_seconds: u64,
25}
26
27impl SpatialAssetManifest {
28 pub fn new_snowy_ga_dem(provenance_did_hash: u64) -> Self {
30 Self {
31 asset_id: "eco:SpatialAsset/AU-GA-DEM-Talbingo".to_string(),
32 source_title: "Geoscience Australia 1-arc-second SRTM DEM-S".to_string(),
33 authoritative_provider: "https://www.ga.gov.au/".to_string(),
34 license_iri: "https://creativecommons.org/licenses/by/4.0/".to_string(),
35 srid: 7844, vertical_datum: 5711, bbox_lat_lon: [-35.85, 148.20, -35.70, 148.40],
38 hilbert_range: (0, 4096),
39 compression_codec: CompressionCodec::Htj2kWavelet,
40 multiresolution_levels: 5,
41 dggs_cell_id: "R84400123".to_string(),
42 wfs_feature_ref: "urn:gsnsw:geology:TalbingoSheet".to_string(),
43 provenance_did_hash,
44 retrieval_epoch_seconds: 1780000000,
45 }
46 }
47
48 pub fn to_ntriples(&self) -> String {
50 let codec_str = match self.compression_codec {
51 CompressionCodec::UncompressedMmap => "UncompressedMmap",
52 CompressionCodec::Lz4 => "Lz4",
53 CompressionCodec::BaoTree => "BaoTree",
54 CompressionCodec::Htj2kWavelet => "Htj2kWavelet",
55 CompressionCodec::TerrainRgbPng => "TerrainRgbPng",
56 CompressionCodec::TerrariumPng => "TerrariumPng",
57 CompressionCodec::Av1IntraDrape => "Av1IntraDrape",
58 };
59
60 let min_lat = self.bbox_lat_lon[0];
61 let min_lon = self.bbox_lat_lon[1];
62 let max_lat = self.bbox_lat_lon[2];
63 let max_lon = self.bbox_lat_lon[3];
64
65 format!(
66 "<{asset_id}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ecopunk.earth/ontology#SpatialAsset> .\n\
67 <{asset_id}> <http://purl.org/dc/terms/title> \"{title}\" .\n\
68 <{asset_id}> <http://purl.org/dc/terms/publisher> <{provider}> .\n\
69 <{asset_id}> <http://purl.org/dc/terms/license> <{license}> .\n\
70 <{asset_id}> <https://ecopunk.earth/ontology#srid> \"{srid}\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n\
71 <{asset_id}> <https://ecopunk.earth/ontology#verticalDatum> \"{vdatum}\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n\
72 <{asset_id}> <https://ecopunk.earth/ontology#compressionCodec> <https://ecopunk.earth/ontology#{codec_str}> .\n\
73 <{asset_id}> <https://ecopunk.earth/ontology#multiresolutionLevels> \"{mips}\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n\
74 <{asset_id}> <https://ecopunk.earth/ontology#inDggsCell> \"{dggs}\" .\n\
75 <{asset_id}> <https://ecopunk.earth/ontology#wfsGeologyRef> <{wfs}>\n\
76 <{asset_id}> <http://www.opengis.net/ont/geosparql#asWKT> \"POLYGON(({min_lon:.4} {min_lat:.4}, {max_lon:.4} {min_lat:.4}, {max_lon:.4} {max_lat:.4}, {min_lon:.4} {max_lat:.4}, {min_lon:.4} {min_lat:.4}))\"^^<http://www.opengis.net/ont/geosparql#wktLiteral> .\n\
77 <{asset_id}> <https://ecopunk.earth/ontology#provenanceDidHash> \"{did_hash}\"^^<http://www.w3.org/2001/XMLSchema#unsignedLong> .\n",
78 asset_id = self.asset_id,
79 title = self.source_title,
80 provider = self.authoritative_provider,
81 license = self.license_iri,
82 srid = self.srid,
83 vdatum = self.vertical_datum,
84 codec_str = codec_str,
85 mips = self.multiresolution_levels,
86 dggs = self.dggs_cell_id,
87 wfs = self.wfs_feature_ref,
88 min_lat = min_lat,
89 min_lon = min_lon,
90 max_lat = max_lat,
91 max_lon = max_lon,
92 did_hash = self.provenance_did_hash,
93 )
94 }
95}