diff --git a/maplibre/src/render/view_state.rs b/maplibre/src/render/view_state.rs index 1f76e0e68..b3ea7aad4 100644 --- a/maplibre/src/render/view_state.rs +++ b/maplibre/src/render/view_state.rs @@ -1,9 +1,10 @@ -use cgmath::{prelude::*, *}; use std::{ f64, ops::{Deref, DerefMut}, }; +use cgmath::{prelude::*, *}; + use crate::{ coords::{ViewRegion, WorldCoords, Zoom, ZoomLevel}, render::camera::{ diff --git a/maplibre/src/schedule.rs b/maplibre/src/schedule.rs index 879fc434b..2fb77b3a3 100644 --- a/maplibre/src/schedule.rs +++ b/maplibre/src/schedule.rs @@ -300,10 +300,11 @@ impl Schedule { /// # use maplibre::context::MapContext; /// # use maplibre::tcs::system::stage::SystemStage; /// # use maplibre::schedule::{Schedule, NopStage}; + /// # use maplibre::tcs::system::SystemError; /// # /// # let mut schedule = Schedule::default(); /// # schedule.add_stage("my_stage", SystemStage::default()); - /// # fn my_system(context: &mut MapContext) {} + /// # fn my_system(context: &mut MapContext) -> Result<(), SystemError> { Ok(()) } /// # /// schedule.add_system_to_stage("my_stage", my_system); /// ``` diff --git a/maplibre/src/sdf/bidi.rs b/maplibre/src/sdf/bidi.rs index 539de8906..7e6f0e02b 100644 --- a/maplibre/src/sdf/bidi.rs +++ b/maplibre/src/sdf/bidi.rs @@ -1,4 +1,5 @@ use std::collections::BTreeSet; + use widestring::U16String; pub type Char16 = u16; // was char16_t diff --git a/maplibre/src/sdf/buckets/symbol_bucket.rs b/maplibre/src/sdf/buckets/symbol_bucket.rs index 0ee023d69..6573200b6 100644 --- a/maplibre/src/sdf/buckets/symbol_bucket.rs +++ b/maplibre/src/sdf/buckets/symbol_bucket.rs @@ -1,19 +1,29 @@ -use crate::euclid::Point2D; -use crate::render::view_state::ViewState; -use crate::sdf::geometry_tile_data::GeometryCoordinates; -use crate::sdf::glyph::WritingModeType; -use crate::sdf::image_atlas::ImagePositions; -use crate::sdf::layout::symbol_feature::SymbolGeometryTileFeature; -use crate::sdf::layout::symbol_instance::SymbolInstance; -use crate::sdf::layout::symbol_layout::{LayerProperties, SortKeyRange}; -use crate::sdf::style_types::{ - PropertyValue, SymbolLayoutProperties_PossiblyEvaluated, TextWritingModeType, +use std::{ + collections::{BTreeMap, BTreeSet, HashMap}, + marker::PhantomData, + ops::Range, }; -use crate::sdf::{CanonicalTileID, TileSpace}; + use geo_types::GeometryCollection; -use std::collections::{BTreeMap, BTreeSet, HashMap}; -use std::marker::PhantomData; -use std::ops::Range; + +use crate::{ + euclid::Point2D, + render::view_state::ViewState, + sdf::{ + geometry_tile_data::GeometryCoordinates, + glyph::WritingModeType, + image_atlas::ImagePositions, + layout::{ + symbol_feature::SymbolGeometryTileFeature, + symbol_instance::SymbolInstance, + symbol_layout::{LayerProperties, SortKeyRange}, + }, + style_types::{ + PropertyValue, SymbolLayoutProperties_PossiblyEvaluated, TextWritingModeType, + }, + CanonicalTileID, TileSpace, + }, +}; struct PatternDependency; diff --git a/maplibre/src/sdf/collision_feature.rs b/maplibre/src/sdf/collision_feature.rs index 727754ac9..25ff0b9fe 100644 --- a/maplibre/src/sdf/collision_feature.rs +++ b/maplibre/src/sdf/collision_feature.rs @@ -1,15 +1,20 @@ // This file was fully translated -use crate::euclid::{Box2D, Point2D, Vector2D}; -use crate::sdf::geometry::feature_index::IndexedSubfeature; -use crate::sdf::geometry::{convert_point_f64, convert_point_i16, Anchor}; -use crate::sdf::geometry_tile_data::{GeometryCoordinate, GeometryCoordinates}; -use crate::sdf::glyph::Shaping; -use crate::sdf::grid_index::Circle; -use crate::sdf::shaping::{Padding, PositionedIcon}; -use crate::sdf::style_types::SymbolPlacementType; -use crate::sdf::util::math::{deg2radf, rotate, MinMax}; -use crate::sdf::{ScreenSpace, TileSpace}; +use crate::{ + euclid::{Box2D, Point2D, Vector2D}, + sdf::{ + geometry::{ + convert_point_f64, convert_point_i16, feature_index::IndexedSubfeature, Anchor, + }, + geometry_tile_data::{GeometryCoordinate, GeometryCoordinates}, + glyph::Shaping, + grid_index::Circle, + shaping::{Padding, PositionedIcon}, + style_types::SymbolPlacementType, + util::math::{deg2radf, rotate, MinMax}, + ScreenSpace, TileSpace, + }, +}; #[derive(Clone)] pub struct CollisionFeature { diff --git a/maplibre/src/sdf/collision_index.rs b/maplibre/src/sdf/collision_index.rs index f1decd15c..ed3d8bb61 100644 --- a/maplibre/src/sdf/collision_index.rs +++ b/maplibre/src/sdf/collision_index.rs @@ -1,19 +1,24 @@ // File fully translated except for to-do comments -use crate::coords::EXTENT; -use crate::euclid::{Box2D, Point2D}; -use crate::render::camera::ModelViewProjection; -use crate::render::view_state::ViewState; -use crate::sdf::buckets::symbol_bucket::PlacedSymbol; -use crate::sdf::collision_feature::{CollisionBox, CollisionFeature, ProjectedCollisionBox}; -use crate::sdf::geometry::feature_index::IndexedSubfeature; -use crate::sdf::grid_index::{Circle, GridIndex}; -use crate::sdf::layout::symbol_projection::{placeFirstAndLastGlyph, project, TileDistance}; -use crate::sdf::util::geo::ScreenLineString; -use crate::sdf::{MapMode, ScreenSpace, TileSpace}; +use std::collections::HashMap; + use bitflags::bitflags; use cgmath::{Matrix4, Vector4}; -use std::collections::HashMap; + +use crate::{ + coords::EXTENT, + euclid::{Box2D, Point2D}, + render::{camera::ModelViewProjection, view_state::ViewState}, + sdf::{ + buckets::symbol_bucket::PlacedSymbol, + collision_feature::{CollisionBox, CollisionFeature, ProjectedCollisionBox}, + geometry::feature_index::IndexedSubfeature, + grid_index::{Circle, GridIndex}, + layout::symbol_projection::{placeFirstAndLastGlyph, project, TileDistance}, + util::geo::ScreenLineString, + MapMode, ScreenSpace, TileSpace, + }, +}; type TransformState = ViewState; diff --git a/maplibre/src/sdf/collision_system.rs b/maplibre/src/sdf/collision_system.rs index fb1bff9dc..a216ce55d 100644 --- a/maplibre/src/sdf/collision_system.rs +++ b/maplibre/src/sdf/collision_system.rs @@ -2,25 +2,25 @@ use std::borrow::Cow; use cgmath::{Matrix3, Vector3}; -use crate::coords::{EXTENT, TILE_SIZE}; -use crate::render::eventually::Eventually; -use crate::render::eventually::Eventually::Initialized; -use crate::render::shaders::SDFShaderFeatureMetadata; -use crate::render::tile_view_pattern::WgpuTileViewPattern; -use crate::render::Renderer; -use crate::sdf::collision_feature::{CollisionBox, CollisionFeature}; -use crate::sdf::geometry::feature_index::{IndexedSubfeature, RefIndexedSubfeature}; - -use crate::euclid::Point2D; -use crate::sdf::buckets::symbol_bucket::PlacedSymbol; -use crate::sdf::collision_index::CollisionIndex; -use crate::sdf::geometry_tile_data::GeometryCoordinates; -use crate::sdf::{MapMode, SymbolBufferPool}; -use crate::tcs::system::SystemError; use crate::{ context::MapContext, - sdf::SymbolLayersDataComponent, - tcs::system::{System, SystemResult}, + coords::{EXTENT, TILE_SIZE}, + euclid::Point2D, + render::{ + eventually::{Eventually, Eventually::Initialized}, + shaders::SDFShaderFeatureMetadata, + tile_view_pattern::WgpuTileViewPattern, + Renderer, + }, + sdf::{ + buckets::symbol_bucket::PlacedSymbol, + collision_feature::{CollisionBox, CollisionFeature}, + collision_index::CollisionIndex, + geometry::feature_index::{IndexedSubfeature, RefIndexedSubfeature}, + geometry_tile_data::GeometryCoordinates, + MapMode, SymbolBufferPool, SymbolLayersDataComponent, + }, + tcs::system::{System, SystemError, SystemResult}, }; pub struct CollisionSystem {} diff --git a/maplibre/src/sdf/font_stack.rs b/maplibre/src/sdf/font_stack.rs index 0a3766783..b70baab53 100644 --- a/maplibre/src/sdf/font_stack.rs +++ b/maplibre/src/sdf/font_stack.rs @@ -1,7 +1,7 @@ -use crate::sdf::util::hash_combine; -use crate::style::layer::StyleLayer; use std::collections::BTreeSet; +use crate::{sdf::util::hash_combine, style::layer::StyleLayer}; + // An array of font names pub type FontStack = Vec; pub type FontStackHash = u64; diff --git a/maplibre/src/sdf/geometry.rs b/maplibre/src/sdf/geometry.rs index f145400fe..9874edff4 100644 --- a/maplibre/src/sdf/geometry.rs +++ b/maplibre/src/sdf/geometry.rs @@ -1,5 +1,4 @@ -use crate::euclid::Point2D; -use crate::sdf::TileSpace; +use crate::{euclid::Point2D, sdf::TileSpace}; pub mod feature_index; diff --git a/maplibre/src/sdf/geometry_tile_data.rs b/maplibre/src/sdf/geometry_tile_data.rs index 936724ff7..24046c081 100644 --- a/maplibre/src/sdf/geometry_tile_data.rs +++ b/maplibre/src/sdf/geometry_tile_data.rs @@ -1,8 +1,9 @@ -use crate::euclid::Point2D; -use crate::sdf::layout::symbol_feature::SymbolGeometryTileFeature; use std::ops::Index; -use crate::sdf::TileSpace; +use crate::{ + euclid::Point2D, + sdf::{layout::symbol_feature::SymbolGeometryTileFeature, TileSpace}, +}; // In maplibre-native GeometryTileFeature are traits/classes and there are impls for symbol, fill, line features etc. // The same is true for the data objects which might be backed by geojson diff --git a/maplibre/src/sdf/glyph.rs b/maplibre/src/sdf/glyph.rs index f531bbd31..ee20bbf4a 100644 --- a/maplibre/src/sdf/glyph.rs +++ b/maplibre/src/sdf/glyph.rs @@ -1,13 +1,19 @@ // Except for to-do comments this file was fully translated -use crate::euclid::Rect; -use crate::sdf::bidi::Char16; -use crate::sdf::font_stack::{FontStack, FontStackHash}; -use crate::sdf::glyph_range::GlyphRange; -use crate::sdf::TileSpace; -use bitflags::bitflags; use std::collections::{BTreeMap, BTreeSet, HashSet}; +use bitflags::bitflags; + +use crate::{ + euclid::Rect, + sdf::{ + bidi::Char16, + font_stack::{FontStack, FontStackHash}, + glyph_range::GlyphRange, + TileSpace, + }, +}; + // TODO structs #[derive(Default)] struct AlphaImage; diff --git a/maplibre/src/sdf/glyph_atlas.rs b/maplibre/src/sdf/glyph_atlas.rs index 6996ec576..a21dac343 100644 --- a/maplibre/src/sdf/glyph_atlas.rs +++ b/maplibre/src/sdf/glyph_atlas.rs @@ -1,9 +1,14 @@ -use crate::euclid::Rect; -use crate::sdf::font_stack::FontStackHash; -use crate::sdf::glyph::{GlyphID, GlyphMap, GlyphMetrics}; -use crate::sdf::TileSpace; use std::collections::BTreeMap; +use crate::{ + euclid::Rect, + sdf::{ + font_stack::FontStackHash, + glyph::{GlyphID, GlyphMap, GlyphMetrics}, + TileSpace, + }, +}; + // TODO structs pub struct AlphaImage; diff --git a/maplibre/src/sdf/glyph_range.rs b/maplibre/src/sdf/glyph_range.rs index 5e89ee3dd..8b3a0ef91 100644 --- a/maplibre/src/sdf/glyph_range.rs +++ b/maplibre/src/sdf/glyph_range.rs @@ -1,6 +1,7 @@ -use crate::sdf::util::hash; use std::ops::Range; +use crate::sdf::util::hash; + pub type GlyphRange = Range; const GLYPHS_PER_GLYPH_RANGE: u32 = 256; diff --git a/maplibre/src/sdf/grid_index.rs b/maplibre/src/sdf/grid_index.rs index 99da1c1b2..82ac362f6 100644 --- a/maplibre/src/sdf/grid_index.rs +++ b/maplibre/src/sdf/grid_index.rs @@ -1,7 +1,10 @@ -use crate::euclid::{Box2D, Point2D}; -use crate::sdf::ScreenSpace; use std::{collections::HashSet, f64}; +use crate::{ + euclid::{Box2D, Point2D}, + sdf::ScreenSpace, +}; + #[derive(Default, Clone, Copy, Debug)] pub struct Circle { pub center: Point2D, diff --git a/maplibre/src/sdf/image.rs b/maplibre/src/sdf/image.rs index 72bc0e47c..ce6dae14b 100644 --- a/maplibre/src/sdf/image.rs +++ b/maplibre/src/sdf/image.rs @@ -1,5 +1,4 @@ -use std::cmp::Ordering; -use std::collections::HashMap; +use std::{cmp::Ordering, collections::HashMap}; // TODO pub struct ImageManager; diff --git a/maplibre/src/sdf/image_atlas.rs b/maplibre/src/sdf/image_atlas.rs index db2c77def..a9d482368 100644 --- a/maplibre/src/sdf/image_atlas.rs +++ b/maplibre/src/sdf/image_atlas.rs @@ -1,11 +1,16 @@ -use crate::euclid::Rect; -use crate::sdf::image::{ - Image, ImageContent, ImageManager, ImageMap, ImageStretches, ImageVersionMap, - PremultipliedImage, -}; -use crate::sdf::TileSpace; use std::collections::HashMap; +use crate::{ + euclid::Rect, + sdf::{ + image::{ + Image, ImageContent, ImageManager, ImageMap, ImageStretches, ImageVersionMap, + PremultipliedImage, + }, + TileSpace, + }, +}; + #[derive(Clone)] pub struct ImagePosition { pub pixelRatio: f64, diff --git a/maplibre/src/sdf/layout/layout.rs b/maplibre/src/sdf/layout/layout.rs index 3497e476c..92fc9fe0d 100644 --- a/maplibre/src/sdf/layout/layout.rs +++ b/maplibre/src/sdf/layout/layout.rs @@ -1,8 +1,7 @@ -use crate::sdf::glyph::GlyphDependencies; -use crate::sdf::image::ImageDependencies; -use crate::sdf::{MapMode, OverscaledTileID}; use std::collections::BTreeSet; +use crate::sdf::{glyph::GlyphDependencies, image::ImageDependencies, MapMode, OverscaledTileID}; + #[derive(Clone)] pub struct LayerTypeInfo; diff --git a/maplibre/src/sdf/layout/symbol_feature.rs b/maplibre/src/sdf/layout/symbol_feature.rs index 66b773bb3..a56684910 100644 --- a/maplibre/src/sdf/layout/symbol_feature.rs +++ b/maplibre/src/sdf/layout/symbol_feature.rs @@ -1,9 +1,11 @@ -use crate::sdf::geometry_tile_data::{FeatureType, GeometryCollection, Identifier, Value}; -use crate::sdf::style_types::expression; -use crate::sdf::tagged_string::TaggedString; - use std::cmp::Ordering; +use crate::sdf::{ + geometry_tile_data::{FeatureType, GeometryCollection, Identifier, Value}, + style_types::expression, + tagged_string::TaggedString, +}; + // TODO: Actual feature data with properties #[derive(Clone)] pub struct VectorGeometryTileFeature { diff --git a/maplibre/src/sdf/layout/symbol_instance.rs b/maplibre/src/sdf/layout/symbol_instance.rs index 225acd246..ffe625c9b 100644 --- a/maplibre/src/sdf/layout/symbol_instance.rs +++ b/maplibre/src/sdf/layout/symbol_instance.rs @@ -1,16 +1,19 @@ -use crate::sdf::collision_feature::CollisionFeature; -use crate::sdf::geometry::feature_index::IndexedSubfeature; -use crate::sdf::geometry::Anchor; -use crate::sdf::geometry_tile_data::GeometryCoordinates; -use crate::sdf::glyph::{Shaping, WritingModeType}; -use crate::sdf::image::ImageMap; -use crate::sdf::quads::{getGlyphQuads, getIconQuads, SymbolQuads}; -use crate::sdf::shaping::PositionedIcon; -use crate::sdf::style_types::{SymbolLayoutProperties_Evaluated, SymbolPlacementType}; -use bitflags::bitflags; use std::rc::Rc; + +use bitflags::bitflags; use widestring::U16String; +use crate::sdf::{ + collision_feature::CollisionFeature, + geometry::{feature_index::IndexedSubfeature, Anchor}, + geometry_tile_data::GeometryCoordinates, + glyph::{Shaping, WritingModeType}, + image::ImageMap, + quads::{getGlyphQuads, getIconQuads, SymbolQuads}, + shaping::PositionedIcon, + style_types::{SymbolLayoutProperties_Evaluated, SymbolPlacementType}, +}; + fn getAnyShaping(shapedTextOrientations: &ShapedTextOrientations) -> &Shaping { if shapedTextOrientations.right().isAnyLineNotEmpty() { return &shapedTextOrientations.right(); diff --git a/maplibre/src/sdf/layout/symbol_layout.rs b/maplibre/src/sdf/layout/symbol_layout.rs index c82dda9ed..cea53fbaa 100644 --- a/maplibre/src/sdf/layout/symbol_layout.rs +++ b/maplibre/src/sdf/layout/symbol_layout.rs @@ -1,36 +1,46 @@ -use crate::coords::{EXTENT, TILE_SIZE}; -use crate::sdf::bidi::{applyArabicShaping, BiDi, Char16}; -use crate::sdf::buckets::symbol_bucket::{ - DynamicVertex, OpacityVertex, PlacedSymbol, Segment, SymbolBucket, SymbolBucketBuffer, - SymbolVertex, +use std::{ + collections::{BTreeMap, BTreeSet, HashMap}, + f64::consts::PI, + ops::Range, + rc::Rc, }; -use crate::sdf::geometry::feature_index::{IndexedSubfeature, RefIndexedSubfeature}; -use crate::sdf::geometry::{Anchor, Anchors}; -use crate::sdf::geometry_tile_data::{FeatureType, GeometryCoordinates, SymbolGeometryTileLayer}; -use crate::sdf::glyph::{GlyphIDs, GlyphMap, Shaping, WritingModeType}; -use crate::sdf::glyph_atlas::GlyphPositions; -use crate::sdf::image::{ImageMap, ImageType}; -use crate::sdf::image_atlas::ImagePositions; -use crate::sdf::layout::layout::{BucketParameters, LayoutParameters}; -use crate::sdf::layout::symbol_feature::SymbolGeometryTileFeature; -use crate::sdf::layout::symbol_instance::{ - ShapedTextOrientations, SymbolContent, SymbolInstance, SymbolInstanceSharedData, -}; -use crate::sdf::quads::{SymbolQuad, SymbolQuads}; -use crate::sdf::shaping::{getAnchorJustification, getShaping, PositionedIcon}; -use crate::sdf::style_types::*; -use crate::sdf::tagged_string::{SectionOptions, TaggedString}; -use crate::sdf::util::constants::ONE_EM; -use crate::sdf::util::math::deg2radf; -use crate::sdf::util::{i18n, lower_bound}; -use crate::sdf::{CanonicalTileID, MapMode}; + use lyon::geom::euclid::Point2D; -use std::collections::{BTreeMap, BTreeSet, HashMap}; -use std::f64::consts::PI; -use std::ops::Range; -use std::rc::Rc; use widestring::U16String; +use crate::{ + coords::{EXTENT, TILE_SIZE}, + sdf::{ + bidi::{applyArabicShaping, BiDi, Char16}, + buckets::symbol_bucket::{ + DynamicVertex, OpacityVertex, PlacedSymbol, Segment, SymbolBucket, SymbolBucketBuffer, + SymbolVertex, + }, + geometry::{ + feature_index::{IndexedSubfeature, RefIndexedSubfeature}, + Anchor, Anchors, + }, + geometry_tile_data::{FeatureType, GeometryCoordinates, SymbolGeometryTileLayer}, + glyph::{GlyphIDs, GlyphMap, Shaping, WritingModeType}, + glyph_atlas::GlyphPositions, + image::{ImageMap, ImageType}, + image_atlas::ImagePositions, + layout::{ + layout::{BucketParameters, LayoutParameters}, + symbol_feature::SymbolGeometryTileFeature, + symbol_instance::{ + ShapedTextOrientations, SymbolContent, SymbolInstance, SymbolInstanceSharedData, + }, + }, + quads::{SymbolQuad, SymbolQuads}, + shaping::{getAnchorJustification, getShaping, PositionedIcon}, + style_types::*, + tagged_string::{SectionOptions, TaggedString}, + util::{constants::ONE_EM, i18n, lower_bound, math::deg2radf}, + CanonicalTileID, MapMode, + }, +}; + // TODO #[derive(Clone, Debug)] pub struct SymbolLayer { @@ -1707,26 +1717,29 @@ impl SymbolLayout { #[cfg(test)] mod tests { - use crate::euclid::{Point2D, Rect, Size2D}; - use crate::sdf::bidi::Char16; - use crate::sdf::font_stack::FontStackHasher; - use crate::sdf::geometry_tile_data::{GeometryCoordinates, SymbolGeometryTileLayer}; - use crate::sdf::glyph::{Glyph, GlyphDependencies, GlyphMap, GlyphMetrics, Glyphs}; - use crate::sdf::glyph_atlas::{GlyphPosition, GlyphPositionMap, GlyphPositions}; - use crate::sdf::image::ImageMap; - use crate::sdf::image_atlas::ImagePositions; - use crate::sdf::layout::layout::{BucketParameters, LayerTypeInfo, LayoutParameters}; - use crate::sdf::layout::symbol_feature::{ - SymbolGeometryTileFeature, VectorGeometryTileFeature, - }; - use crate::sdf::layout::symbol_layout::{ - FeatureIndex, LayerProperties, SymbolLayer, SymbolLayout, - }; - use crate::sdf::style_types::SymbolLayoutProperties_Unevaluated; - use crate::sdf::tagged_string::SectionOptions; - use crate::sdf::{CanonicalTileID, MapMode, OverscaledTileID}; use std::collections::HashMap; + use crate::{ + euclid::{Point2D, Rect, Size2D}, + sdf::{ + bidi::Char16, + font_stack::FontStackHasher, + geometry_tile_data::{GeometryCoordinates, SymbolGeometryTileLayer}, + glyph::{Glyph, GlyphDependencies, GlyphMap, GlyphMetrics, Glyphs}, + glyph_atlas::{GlyphPosition, GlyphPositionMap, GlyphPositions}, + image::ImageMap, + image_atlas::ImagePositions, + layout::{ + layout::{BucketParameters, LayerTypeInfo, LayoutParameters}, + symbol_feature::{SymbolGeometryTileFeature, VectorGeometryTileFeature}, + symbol_layout::{FeatureIndex, LayerProperties, SymbolLayer, SymbolLayout}, + }, + style_types::SymbolLayoutProperties_Unevaluated, + tagged_string::SectionOptions, + CanonicalTileID, MapMode, OverscaledTileID, + }, + }; + #[test] fn test() { let fontStack = vec![ diff --git a/maplibre/src/sdf/layout/symbol_projection.rs b/maplibre/src/sdf/layout/symbol_projection.rs index 0bf11d103..b92b77dda 100644 --- a/maplibre/src/sdf/layout/symbol_projection.rs +++ b/maplibre/src/sdf/layout/symbol_projection.rs @@ -1,12 +1,15 @@ -use crate::euclid::Point2D; -use crate::sdf::buckets::symbol_bucket::PlacedSymbol; -use crate::sdf::geometry::convert_point_f64; -use crate::sdf::geometry_tile_data::GeometryCoordinates; -use crate::sdf::util::math::perp; -use crate::sdf::TileSpace; -use cgmath::{Matrix4, Vector4}; use std::f64::consts::PI; +use cgmath::{Matrix4, Vector4}; + +use crate::{ + euclid::Point2D, + sdf::{ + buckets::symbol_bucket::PlacedSymbol, geometry::convert_point_f64, + geometry_tile_data::GeometryCoordinates, util::math::perp, TileSpace, + }, +}; + type PointAndCameraDistance = (Point2D, f64); // TODO is the Unit correct? pub struct TileDistance { diff --git a/maplibre/src/sdf/mod.rs b/maplibre/src/sdf/mod.rs index 5878c0e6e..761031993 100644 --- a/maplibre/src/sdf/mod.rs +++ b/maplibre/src/sdf/mod.rs @@ -4,10 +4,10 @@ use std::{ rc::Rc, }; -use crate::euclid::{Box2D, Point2D}; use crate::{ coords::WorldTileCoords, environment::Environment, + euclid::{Box2D, Point2D}, kernel::Kernel, plugin::Plugin, render::{ diff --git a/maplibre/src/sdf/quads.rs b/maplibre/src/sdf/quads.rs index 68d957bea..11e8fe9af 100644 --- a/maplibre/src/sdf/quads.rs +++ b/maplibre/src/sdf/quads.rs @@ -1,19 +1,25 @@ -use crate::euclid::Vector2D; -use crate::euclid::{Point2D, Rect, Size2D}; -use crate::sdf::glyph::{Shaping, WritingModeType}; -use crate::sdf::image::{ImageMap, ImageStretches}; -use crate::sdf::image_atlas::ImagePosition; -use crate::sdf::layout::symbol_instance::SymbolContent; -use crate::sdf::shaping::PositionedIcon; -use crate::sdf::style_types::{ - AlignmentType, SymbolLayoutProperties_Evaluated, SymbolPlacementType, TextRotate, - TextRotationAlignment, -}; -use crate::sdf::util::constants::ONE_EM; -use crate::sdf::util::math::{deg2radf, rotate}; -use crate::sdf::TileSpace; use std::f64::consts::PI; +use crate::{ + euclid::{Point2D, Rect, Size2D, Vector2D}, + sdf::{ + glyph::{Shaping, WritingModeType}, + image::{ImageMap, ImageStretches}, + image_atlas::ImagePosition, + layout::symbol_instance::SymbolContent, + shaping::PositionedIcon, + style_types::{ + AlignmentType, SymbolLayoutProperties_Evaluated, SymbolPlacementType, TextRotate, + TextRotationAlignment, + }, + util::{ + constants::ONE_EM, + math::{deg2radf, rotate}, + }, + TileSpace, + }, +}; + pub struct SymbolQuad { pub tl: Point2D, pub tr: Point2D, @@ -476,19 +482,22 @@ pub fn getGlyphQuads( } #[cfg(test)] mod tests { - use crate::euclid::{Point2D, Rect, Size2D}; - use crate::sdf::geometry::Anchor; - use crate::sdf::geometry_tile_data::GeometryCoordinates; - use crate::sdf::glyph::{PositionedGlyph, PositionedLine, Shaping, WritingModeType}; - use crate::sdf::image_atlas::ImagePosition; - use crate::sdf::layout::symbol_instance::SymbolContent; - use crate::sdf::quads::getIconQuads; - use crate::sdf::shaping::PositionedIcon; - use crate::sdf::style_types::{ - IconTextFitType, SymbolAnchorType, SymbolLayoutProperties_Evaluated, - }; use cgmath::ulps_eq; + use crate::{ + euclid::{Point2D, Rect, Size2D}, + sdf::{ + geometry::Anchor, + geometry_tile_data::GeometryCoordinates, + glyph::{PositionedGlyph, PositionedLine, Shaping, WritingModeType}, + image_atlas::ImagePosition, + layout::symbol_instance::SymbolContent, + quads::getIconQuads, + shaping::PositionedIcon, + style_types::{IconTextFitType, SymbolAnchorType, SymbolLayoutProperties_Evaluated}, + }, + }; + #[test] pub fn getIconQuads_normal() { let layout = SymbolLayoutProperties_Evaluated; diff --git a/maplibre/src/sdf/shaping.rs b/maplibre/src/sdf/shaping.rs index 84c18fdd2..b64b0439a 100644 --- a/maplibre/src/sdf/shaping.rs +++ b/maplibre/src/sdf/shaping.rs @@ -1,18 +1,24 @@ -use crate::euclid::Rect; -use crate::sdf::bidi::{BiDi, Char16}; -use crate::sdf::glyph::{ - Glyph, GlyphMap, GlyphMetrics, PositionedGlyph, PositionedLine, Shaping, WritingModeType, -}; -use crate::sdf::glyph_atlas::GlyphPositions; -use crate::sdf::image_atlas::{ImagePosition, ImagePositions}; -use crate::sdf::style_types::{IconTextFitType, SymbolAnchorType, TextJustifyType}; -use crate::sdf::tagged_string::{SectionOptions, TaggedString}; -use crate::sdf::util::constants::ONE_EM; -use crate::sdf::util::i18n; -use crate::sdf::TileSpace; -use cgmath::num_traits::Pow; use std::collections::BTreeSet; +use cgmath::num_traits::Pow; + +use crate::{ + euclid::Rect, + sdf::{ + bidi::{BiDi, Char16}, + glyph::{ + Glyph, GlyphMap, GlyphMetrics, PositionedGlyph, PositionedLine, Shaping, + WritingModeType, + }, + glyph_atlas::GlyphPositions, + image_atlas::{ImagePosition, ImagePositions}, + style_types::{IconTextFitType, SymbolAnchorType, TextJustifyType}, + tagged_string::{SectionOptions, TaggedString}, + util::{constants::ONE_EM, i18n}, + TileSpace, + }, +}; + #[derive(Clone, Copy, Default, PartialEq)] pub struct Padding { pub left: f64, @@ -763,15 +769,17 @@ fn shapeLines( #[cfg(test)] mod test { - use crate::sdf::bidi::{BiDi, Char16}; - use crate::sdf::font_stack::FontStackHasher; - use crate::sdf::glyph::{Glyph, GlyphMap, Glyphs, WritingModeType}; - use crate::sdf::glyph_atlas::{GlyphPosition, GlyphPositionMap, GlyphPositions}; - use crate::sdf::image_atlas::ImagePositions; - use crate::sdf::shaping::getShaping; - use crate::sdf::style_types::{SymbolAnchorType, TextJustifyType}; - use crate::sdf::tagged_string::{SectionOptions, TaggedString}; - use crate::sdf::util::constants::ONE_EM; + use crate::sdf::{ + bidi::{BiDi, Char16}, + font_stack::FontStackHasher, + glyph::{Glyph, GlyphMap, Glyphs, WritingModeType}, + glyph_atlas::{GlyphPosition, GlyphPositionMap, GlyphPositions}, + image_atlas::ImagePositions, + shaping::getShaping, + style_types::{SymbolAnchorType, TextJustifyType}, + tagged_string::{SectionOptions, TaggedString}, + util::constants::ONE_EM, + }; #[test] fn Shaping_ZWSP() { diff --git a/maplibre/src/sdf/style_types.rs b/maplibre/src/sdf/style_types.rs index 2067e9d94..de7b2ff15 100644 --- a/maplibre/src/sdf/style_types.rs +++ b/maplibre/src/sdf/style_types.rs @@ -1,8 +1,6 @@ -use crate::sdf::layout::symbol_feature::SymbolGeometryTileFeature; -use crate::sdf::CanonicalTileID; -use std::any::TypeId; -use std::collections::BTreeSet; -use std::marker::PhantomData; +use std::{any::TypeId, collections::BTreeSet, marker::PhantomData}; + +use crate::sdf::{layout::symbol_feature::SymbolGeometryTileFeature, CanonicalTileID}; /// Types belonging to style @@ -784,12 +782,16 @@ impl SymbolLayoutProperties_PossiblyEvaluated { pub struct SymbolLayoutProperties_Evaluated; pub mod expression { - use crate::sdf::font_stack::FontStack; - use crate::sdf::layout::symbol_feature::SymbolGeometryTileFeature; - use crate::sdf::CanonicalTileID; + use std::{ + collections::{BTreeSet, HashMap}, + rc::Rc, + }; + use csscolorparser::Color; - use std::collections::{BTreeSet, HashMap}; - use std::rc::Rc; + + use crate::sdf::{ + font_stack::FontStack, layout::symbol_feature::SymbolGeometryTileFeature, CanonicalTileID, + }; #[derive(Clone, PartialEq)] pub enum Value { diff --git a/maplibre/src/sdf/tagged_string.rs b/maplibre/src/sdf/tagged_string.rs index b0ee3194f..657201370 100644 --- a/maplibre/src/sdf/tagged_string.rs +++ b/maplibre/src/sdf/tagged_string.rs @@ -1,10 +1,15 @@ -use crate::sdf::bidi::{Char16, StyledText}; -use crate::sdf::font_stack::{FontStack, FontStackHash, FontStackHasher}; -use crate::sdf::util::i18n; -use crate::sdf::util::i18n::{BACKSLACK_F, BACKSLACK_V}; use csscolorparser::Color; use widestring::{U16Str, U16String}; +use crate::sdf::{ + bidi::{Char16, StyledText}, + font_stack::{FontStack, FontStackHash, FontStackHasher}, + util::{ + i18n, + i18n::{BACKSLACK_F, BACKSLACK_V}, + }, +}; + #[derive(Clone, Default)] pub struct SectionOptions { pub scale: f64, @@ -244,11 +249,14 @@ impl TaggedString { #[cfg(test)] mod tests { - use crate::sdf::bidi::Char16; - use crate::sdf::tagged_string::{SectionOptions, TaggedString}; - use crate::sdf::util::i18n::BACKSLACK_V; use widestring::U16String; + use crate::sdf::{ + bidi::Char16, + tagged_string::{SectionOptions, TaggedString}, + util::i18n::BACKSLACK_V, + }; + #[test] fn TaggedString_Trim() { let mut basic = TaggedString::new_from_raw( diff --git a/maplibre/src/sdf/tessellation.rs b/maplibre/src/sdf/tessellation.rs index 4f26fb5b5..81c5df327 100644 --- a/maplibre/src/sdf/tessellation.rs +++ b/maplibre/src/sdf/tessellation.rs @@ -1,20 +1,18 @@ //! Tessellation for lines and polygons is implemented here. use csscolorparser::Color; use geozero::{ColumnValue, FeatureProcessor, GeomProcessor, PropertyProcessor}; -use lyon::geom::euclid::Box2D; use lyon::{ - geom::euclid::Point2D, + geom::euclid::{Box2D, Point2D}, tessellation::{ geometry_builder::MaxIndex, BuffersBuilder, FillOptions, FillTessellator, VertexBuffers, }, }; -use crate::sdf::TileSpace; use crate::{ render::shaders::ShaderSymbolVertex, sdf::{ text::{Anchor, Glyph, GlyphSet, SymbolVertexBuilder}, - Feature, + Feature, TileSpace, }, }; diff --git a/maplibre/src/sdf/upload_system.rs b/maplibre/src/sdf/upload_system.rs index 76ac49b8b..6b6b894da 100644 --- a/maplibre/src/sdf/upload_system.rs +++ b/maplibre/src/sdf/upload_system.rs @@ -2,13 +2,12 @@ use std::iter; -use crate::render::shaders::SDFShaderFeatureMetadata; use crate::{ context::MapContext, coords::ViewRegion, render::{ eventually::{Eventually, Eventually::Initialized}, - shaders::ShaderLayerMetadata, + shaders::{SDFShaderFeatureMetadata, ShaderLayerMetadata}, tile_view_pattern::DEFAULT_TILE_SIZE, view_state::ViewStatePadding, Renderer, diff --git a/maplibre/src/sdf/util/i18n.rs b/maplibre/src/sdf/util/i18n.rs index bdfd5d7cc..4e9bd741e 100644 --- a/maplibre/src/sdf/util/i18n.rs +++ b/maplibre/src/sdf/util/i18n.rs @@ -1,6 +1,7 @@ -use crate::sdf::bidi::Char16; use widestring::U16String; +use crate::sdf::bidi::Char16; + pub fn allowsWordBreaking(chr: Char16) -> bool { return (chr == 0x0a /* newline */ || chr == 0x20 /* space */ diff --git a/maplibre/src/sdf/util/math.rs b/maplibre/src/sdf/util/math.rs index 580a15105..fe4d85699 100644 --- a/maplibre/src/sdf/util/math.rs +++ b/maplibre/src/sdf/util/math.rs @@ -1,6 +1,7 @@ -use crate::euclid::Vector2D; use std::f64::consts::PI; +use crate::euclid::Vector2D; + pub fn rotate(a: &Vector2D, angle: f64) -> Vector2D { let cos = angle.cos(); let sin = angle.sin(); diff --git a/maplibre/src/sdf/util/mod.rs b/maplibre/src/sdf/util/mod.rs index f25a91053..11d1d6a9a 100644 --- a/maplibre/src/sdf/util/mod.rs +++ b/maplibre/src/sdf/util/mod.rs @@ -1,5 +1,7 @@ -use std::hash::{DefaultHasher, Hash, Hasher}; -use std::ops::Range; +use std::{ + hash::{DefaultHasher, Hash, Hasher}, + ops::Range, +}; pub mod constants; pub mod geo;