Skip to content

Commit

Permalink
fmt and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxammann committed Aug 29, 2024
1 parent 7b53163 commit 2c4d481
Show file tree
Hide file tree
Showing 31 changed files with 319 additions and 229 deletions.
3 changes: 2 additions & 1 deletion maplibre/src/render/view_state.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
3 changes: 2 additions & 1 deletion maplibre/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/// ```
Expand Down
1 change: 1 addition & 0 deletions maplibre/src/sdf/bidi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::BTreeSet;

use widestring::U16String;

pub type Char16 = u16; // was char16_t
Expand Down
38 changes: 24 additions & 14 deletions maplibre/src/sdf/buckets/symbol_bucket.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
25 changes: 15 additions & 10 deletions maplibre/src/sdf/collision_feature.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
29 changes: 17 additions & 12 deletions maplibre/src/sdf/collision_index.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
34 changes: 17 additions & 17 deletions maplibre/src/sdf/collision_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions maplibre/src/sdf/font_stack.rs
Original file line number Diff line number Diff line change
@@ -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<String>;
pub type FontStackHash = u64;
Expand Down
3 changes: 1 addition & 2 deletions maplibre/src/sdf/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::euclid::Point2D;
use crate::sdf::TileSpace;
use crate::{euclid::Point2D, sdf::TileSpace};

pub mod feature_index;

Expand Down
7 changes: 4 additions & 3 deletions maplibre/src/sdf/geometry_tile_data.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 12 additions & 6 deletions maplibre/src/sdf/glyph.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 9 additions & 4 deletions maplibre/src/sdf/glyph_atlas.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 2 additions & 1 deletion maplibre/src/sdf/glyph_range.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::sdf::util::hash;
use std::ops::Range;

use crate::sdf::util::hash;

pub type GlyphRange = Range<u16>;

const GLYPHS_PER_GLYPH_RANGE: u32 = 256;
Expand Down
7 changes: 5 additions & 2 deletions maplibre/src/sdf/grid_index.rs
Original file line number Diff line number Diff line change
@@ -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<T> {
pub center: Point2D<T, ScreenSpace>,
Expand Down
3 changes: 1 addition & 2 deletions maplibre/src/sdf/image.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::cmp::Ordering;
use std::collections::HashMap;
use std::{cmp::Ordering, collections::HashMap};

// TODO
pub struct ImageManager;
Expand Down
17 changes: 11 additions & 6 deletions maplibre/src/sdf/image_atlas.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 2 additions & 3 deletions maplibre/src/sdf/layout/layout.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
10 changes: 6 additions & 4 deletions maplibre/src/sdf/layout/symbol_feature.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
23 changes: 13 additions & 10 deletions maplibre/src/sdf/layout/symbol_instance.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Loading

0 comments on commit 2c4d481

Please sign in to comment.