96 lines
2.6 KiB
Rust
96 lines
2.6 KiB
Rust
//! Data types for map features and tile data
|
|
|
|
use serde::Deserialize;
|
|
use std::collections::HashMap;
|
|
|
|
/// A map node (point feature with tags)
|
|
#[allow(dead_code)]
|
|
#[derive(Deserialize, Debug, Clone)]
|
|
pub struct MapNode {
|
|
pub id: i64,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
pub tags: HashMap<String, String>,
|
|
}
|
|
|
|
///A map way (line/polygon feature with tags and geometry)
|
|
#[allow(dead_code)]
|
|
#[derive(Deserialize, Debug, Clone)]
|
|
pub struct MapWay {
|
|
pub id: i64,
|
|
pub tags: HashMap<String, String>,
|
|
pub points: Vec<u8>,
|
|
pub vertex_buffer: Vec<u8>, // Precomputed GPU-ready vertex data
|
|
}
|
|
|
|
/// Combined tile data from the backend
|
|
#[allow(dead_code)]
|
|
#[derive(Deserialize, Debug, Clone)]
|
|
pub struct TileData {
|
|
pub nodes: Vec<MapNode>,
|
|
pub ways: Vec<MapWay>,
|
|
pub buildings: Vec<MapWay>,
|
|
pub landuse: Vec<MapWay>,
|
|
pub water: Vec<MapWay>,
|
|
pub railways: Vec<MapWay>,
|
|
}
|
|
|
|
/// GPU buffers for a single tile's geometry
|
|
#[allow(dead_code)]
|
|
pub struct TileBuffers {
|
|
// Road Buffers
|
|
pub road_motorway_vertex_buffer: wgpu::Buffer,
|
|
pub road_motorway_vertex_count: u32,
|
|
pub road_primary_vertex_buffer: wgpu::Buffer,
|
|
pub road_primary_vertex_count: u32,
|
|
pub road_secondary_vertex_buffer: wgpu::Buffer,
|
|
pub road_secondary_vertex_count: u32,
|
|
pub road_residential_vertex_buffer: wgpu::Buffer,
|
|
pub road_residential_vertex_count: u32,
|
|
|
|
pub building_vertex_buffer: wgpu::Buffer,
|
|
pub building_index_count: u32,
|
|
|
|
// Landuse Buffers
|
|
pub landuse_green_vertex_buffer: wgpu::Buffer,
|
|
pub landuse_green_index_count: u32,
|
|
pub landuse_residential_vertex_buffer: wgpu::Buffer,
|
|
pub landuse_residential_index_count: u32,
|
|
pub landuse_sand_vertex_buffer: wgpu::Buffer,
|
|
pub landuse_sand_index_count: u32,
|
|
|
|
pub water_vertex_buffer: wgpu::Buffer,
|
|
pub water_index_count: u32,
|
|
pub railway_vertex_buffer: wgpu::Buffer,
|
|
pub railway_vertex_count: u32,
|
|
|
|
pub water_line_vertex_buffer: wgpu::Buffer,
|
|
pub water_line_vertex_count: u32,
|
|
|
|
// Tile-specific uniform bind group for relative coordinates
|
|
pub tile_bind_group: wgpu::BindGroup,
|
|
}
|
|
|
|
/// Type of label for styling
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub enum LabelType {
|
|
Country,
|
|
City,
|
|
Street,
|
|
Poi,
|
|
Transit, // S-Bahn/U-Bahn line labels (S1, U3, etc.)
|
|
}
|
|
|
|
/// Pre-computed label data to avoid processing tags every frame
|
|
#[derive(Clone, Debug)]
|
|
pub struct CachedLabel {
|
|
pub name: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
pub label_type: LabelType,
|
|
pub rotation: f64,
|
|
pub priority: i32,
|
|
pub min_zoom: f64,
|
|
pub category: String, // CSS class suffix
|
|
}
|