-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
other than comments and finish testing, rust code is ready
- Loading branch information
Mr Martian
committed
Jul 25, 2024
1 parent
a4bcb33
commit c287244
Showing
7 changed files
with
102 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ tsconfig.tsbuildinfo | |
.DS_Store | ||
target/ | ||
coverage/ | ||
cobertura.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ tsconfig.tsbuildinfo | |
.DS_Store | ||
target/ | ||
coverage/ | ||
cobertura.xml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "s2-tilejson" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors = ["Craig O'Connor <[email protected]>"] | ||
description = "Backwards compatible JSON format for describing s2 map tilesets." | ||
|
@@ -23,21 +23,26 @@ exclude = [ | |
"/tools", | ||
"/src", | ||
".github", | ||
".helix" | ||
".helix", | ||
"bin/dummy.rs", | ||
] | ||
|
||
[[bin]] | ||
name = "dummy" | ||
path = "bin/dummy.rs" | ||
|
||
[lib] | ||
name = "rust" | ||
name = "s2_tilejson" | ||
path = "rust/lib.rs" | ||
bench = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } | ||
serde_json = { version = "1.0", default-features = false, features = ["alloc"] } | ||
|
||
[dev-dependencies] | ||
serde_json = { version = "1.0", default-features = false, features = ["alloc"] } | ||
|
||
[profile.bench] | ||
opt-level = "z" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use s2_tilejson::{DrawType, Face, LayerMetaData, LonLatBounds, Metadata, MetadataBuilder, Shape}; | ||
|
||
fn main() { | ||
let mut meta_builder = MetadataBuilder::default(); | ||
|
||
// on initial use be sure to update basic metadata: | ||
meta_builder.set_name("OSM".into()); | ||
meta_builder.set_description("A free editable map of the whole world.".into()); | ||
meta_builder.set_version("1.0.0".into()); | ||
meta_builder.set_scheme("fzxy".into()); // 'fzxy' | 'tfzxy' | 'xyz' | 'txyz' | 'tms' | ||
meta_builder.set_type("vector".into()); // 'vector' | 'json' | 'raster' | 'raster-dem' | 'sensor' | 'markers' | ||
meta_builder.set_encoding("none".into()); // 'gz' | 'br' | 'none' | ||
meta_builder.add_attribution("OpenStreetMap", "https://www.openstreetmap.org/copyright/"); | ||
|
||
// Vector Specific: add layers based on how you want to parse data from a source: | ||
let shape_str = r#" | ||
{ | ||
"class": "string", | ||
"offset": "f64", | ||
"info": { | ||
"name": "string", | ||
"value": "i64" | ||
} | ||
} | ||
"#; | ||
let shape: Shape = serde_json::from_str(shape_str).unwrap_or_else(|e| panic!("ERROR: {}", e)); | ||
let layer = LayerMetaData { | ||
minzoom: 0, | ||
maxzoom: 13, | ||
description: Some("water_lines".into()), | ||
draw_types: Vec::from(&[DrawType::Lines]), | ||
shape: shape.clone(), | ||
m_shape: None, | ||
}; | ||
meta_builder.add_layer("water_lines", &layer); | ||
|
||
// as you build tiles, add the tiles metadata: | ||
// WM: | ||
meta_builder.add_tile_wm(0, 0, 0, &LonLatBounds{ left: -60.0, bottom: -20.0, right: 5.0, top: 60.0 }); | ||
// S2: | ||
meta_builder.add_tile_s2(Face::Face1, 5, 22, 37, &LonLatBounds { left: -120.0, bottom: -7.0, right: 44.0, top: 72.0 }); | ||
|
||
// finally to get the resulting metadata: | ||
let _resulting_metadata: Metadata = meta_builder.commit(); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters