Move download to own crate

This commit is contained in:
Maximilian Ammann 2021-12-03 21:38:00 +01:00
parent 5f859c9d13
commit 9e3d24692a
8 changed files with 30 additions and 18 deletions

2
.idea/mapr.iml generated
View File

@ -4,7 +4,9 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/libs/mapr_utils/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/libs/mapr_utils/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View File

@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run downloader" type="CargoCommandRunConfiguration" factoryName="Cargo Command"> <configuration default="false" name="Run downloader" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
<option name="command" value="run --bin download_tiles" /> <option name="command" value="run --bin download_tiles" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" /> <option name="workingDirectory" value="file://$PROJECT_DIR$/libs/mapr_utils" />
<option name="channel" value="DEFAULT" /> <option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" /> <option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" /> <option name="allFeatures" value="false" />

View File

@ -19,7 +19,6 @@ wasm-bindgen-futures = "0.4"
console_log = { version = "0.2", features = ["color"] } console_log = { version = "0.2", features = ["color"] }
[dependencies] [dependencies]
# Futures # Futures
futures = "0.3.5" futures = "0.3.5"
pollster = "0.2" pollster = "0.2"
@ -46,9 +45,6 @@ env_logger = "0.9"
hexdump = "0.1" hexdump = "0.1"
bytemuck = "1.2.0" bytemuck = "1.2.0"
# Network
# reqwest = { version = "0.11", features = ["gzip"] } FIXME: Incompatible with wasm
# Serialization # Serialization
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
@ -62,7 +58,3 @@ env_logger = "0.8" # Used for test-env-log
[[bin]] [[bin]]
name = "mapr" name = "mapr"
path = "src/main.rs" path = "src/main.rs"
[[bin]]
name = "download_tiles"
path = "src/utils/tile_downloader.rs"

View File

@ -0,0 +1,16 @@
[package]
name = "mapr-utils"
version = "0.1.0"
description = ""
edition = "2021"
[dependencies]
log = "0.4"
# Network
reqwest = { version = "0.11", features = ["gzip"] }
vector-tile = { path = "../vector_tile" }
tokio = { version = "1.14", features = ["full"] }
[[bin]]
name = "download_tiles"
path = "src/tile_downloader.rs"

View File

@ -1,6 +1,7 @@
use std::fs::File; use std::fs::File;
use std::io::copy; use std::io::copy;
use std::path::Path; use std::path::Path;
use reqwest::Client;
use vector_tile::grid::*; use vector_tile::grid::*;
@ -13,7 +14,7 @@ pub async fn download_tiles() {
y = y, y = y,
); );
println!("{}", target); println!("{}", target);
let client = reqwest::Client::builder() let client = Client::builder()
.gzip(true) .gzip(true)
.build().unwrap(); .build().unwrap();
@ -29,6 +30,7 @@ pub async fn download_tiles() {
} }
} }
fn main() { #[tokio::main]
pollster::block_on(download_tiles()); async fn main() {
download_tiles().await
} }

View File

@ -1,5 +1,5 @@
use wgpu::{FragmentState, PipelineLayout, RenderPipelineDescriptor, VertexState}; use wgpu::{FragmentState, PipelineLayout, RenderPipelineDescriptor, VertexState};
use crate::texture::Texture;
pub fn create_map_render_pipeline_description<'a>( pub fn create_map_render_pipeline_description<'a>(
pipeline_layout: &'a PipelineLayout, pipeline_layout: &'a PipelineLayout,

View File

@ -4,11 +4,11 @@ use std::ops::Range;
use lyon::math::Vector; use lyon::math::Vector;
use lyon::tessellation::VertexBuffers; use lyon::tessellation::VertexBuffers;
use vector_tile::{parse_tile, parse_tile_reader}; use vector_tile::{parse_tile_reader};
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use winit::dpi::PhysicalSize;
use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent}; use winit::event::{ElementState, KeyboardInput, VirtualKeyCode, WindowEvent};
use winit::event_loop::ControlFlow;
use winit::window::Window; use winit::window::Window;
use crate::fps_meter::FPSMeter; use crate::fps_meter::FPSMeter;

View File

@ -9,7 +9,7 @@ impl Texture {
pub fn create_depth_texture( pub fn create_depth_texture(
device: &wgpu::Device, device: &wgpu::Device,
config: &wgpu::SurfaceConfiguration, config: &wgpu::SurfaceConfiguration,
label: &str, _label: &str,
sample_count: u32, sample_count: u32,
) -> Self { ) -> Self {