diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-05-10 18:51:52 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-05-12 18:07:36 +0300 |
commit | 25b2250c32c1881990718c7de7b87f33ab703e79 (patch) | |
tree | 0d5b0a1daa8764489a351b8c757d196be315fc24 /src/mbgl | |
parent | fa36110dfbdc05b511a3f85461eaca4a29e446a1 (diff) | |
download | qtlocation-mapboxgl-25b2250c32c1881990718c7de7b87f33ab703e79.tar.gz |
[tidy] modernize-use-using
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/annotation/symbol_annotation_impl.hpp | 46 | ||||
-rw-r--r-- | src/mbgl/geometry/anchor.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/gl/debugging_extension.hpp | 14 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/collision_tile.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/glyph.hpp | 13 | ||||
-rw-r--r-- | src/mbgl/text/glyph_range.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/quads.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/mat2.hpp | 2 |
10 files changed, 63 insertions, 34 deletions
diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp index c9a99ffb8d..b5be4e9ed9 100644 --- a/src/mbgl/annotation/symbol_annotation_impl.hpp +++ b/src/mbgl/annotation/symbol_annotation_impl.hpp @@ -26,10 +26,6 @@ #include <boost/geometry/index/rtree.hpp> #pragma GCC diagnostic pop -// Make Boost Geometry aware of our LatLng type -BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(mbgl::LatLng, double, boost::geometry::cs::cartesian, longitude(), latitude()) -BOOST_GEOMETRY_REGISTER_BOX(mbgl::LatLngBounds, mbgl::LatLng, southwest(), northeast()) - namespace mbgl { class AnnotationTileLayer; @@ -47,9 +43,42 @@ public: } // namespace mbgl -// Tell Boost Geometry how to access a std::shared_ptr<mbgl::SymbolAnnotation> object. namespace boost { namespace geometry { + +// Make Boost Geometry aware of our LatLng type +namespace traits { + +template<> struct tag<mbgl::LatLng> { using type = point_tag; }; +template<> struct dimension<mbgl::LatLng> : boost::mpl::int_<2> {}; +template<> struct coordinate_type<mbgl::LatLng> { using type = double; }; +template<> struct coordinate_system<mbgl::LatLng> { using type = boost::geometry::cs::cartesian; }; + +template<> struct access<mbgl::LatLng, 0> { static inline double get(mbgl::LatLng const& p) { return p.longitude(); } }; +template<> struct access<mbgl::LatLng, 1> { static inline double get(mbgl::LatLng const& p) { return p.latitude(); } }; + +template<> struct tag<mbgl::LatLngBounds> { using type = box_tag; }; +template<> struct point_type<mbgl::LatLngBounds> { using type = mbgl::LatLng; }; + +template <size_t D> +struct indexed_access<mbgl::LatLngBounds, min_corner, D> +{ + using ct = coordinate_type<mbgl::LatLng>::type; + static inline ct get(mbgl::LatLngBounds const& b) { return geometry::get<D>(b.southwest()); } + static inline void set(mbgl::LatLngBounds& b, ct const& value) { geometry::set<D>(b.southwest(), value); } +}; + +template <size_t D> +struct indexed_access<mbgl::LatLngBounds, max_corner, D> +{ + using ct = coordinate_type<mbgl::LatLng>::type; + static inline ct get(mbgl::LatLngBounds const& b) { return geometry::get<D>(b.northeast()); } + static inline void set(mbgl::LatLngBounds& b, ct const& value) { geometry::set<D>(b.northeast(), value); } +}; + +} // namespace traits + +// Tell Boost Geometry how to access a std::shared_ptr<mbgl::SymbolAnnotation> object. namespace index { template <> @@ -61,6 +90,7 @@ struct indexable<std::shared_ptr<const mbgl::SymbolAnnotationImpl>> { } }; -} // end namespace index -} // end namespace geometry -} // end namespace boost +} // namespace index + +} // namespace geometry +} // namespace boost diff --git a/src/mbgl/geometry/anchor.hpp b/src/mbgl/geometry/anchor.hpp index 3ed2b23e1b..b24d8d04e0 100644 --- a/src/mbgl/geometry/anchor.hpp +++ b/src/mbgl/geometry/anchor.hpp @@ -17,6 +17,6 @@ public: : point(x_, y_), angle(angle_), scale(scale_), segment(segment_) {} }; -typedef std::vector<Anchor> Anchors; +using Anchors = std::vector<Anchor>; } // namespace mbgl diff --git a/src/mbgl/gl/debugging_extension.hpp b/src/mbgl/gl/debugging_extension.hpp index c1835cfcdd..5657bbde88 100644 --- a/src/mbgl/gl/debugging_extension.hpp +++ b/src/mbgl/gl/debugging_extension.hpp @@ -53,13 +53,13 @@ namespace extension { class Debugging { public: - typedef void (*Callback)(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar* message, - const void* userParam); + using Callback = void (*)(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar* message, + const void* userParam); static void DebugCallback(GLenum source, GLenum type, diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 5afddaebce..5d99677726 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -38,8 +38,8 @@ public: float height; }; -typedef std::map<std::string, SpriteAtlasElement> IconMap; -typedef std::set<std::string> IconDependencies; +using IconMap = std::map<std::string, SpriteAtlasElement>; +using IconDependencies = std::set<std::string>; class IconRequestor { public: diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp index ea4324edaf..653ea74489 100644 --- a/src/mbgl/text/collision_tile.hpp +++ b/src/mbgl/text/collision_tile.hpp @@ -28,10 +28,10 @@ namespace mbgl { namespace bg = boost::geometry; namespace bgm = bg::model; namespace bgi = bg::index; -typedef bgm::point<float, 2, bg::cs::cartesian> CollisionPoint; -typedef bgm::box<CollisionPoint> Box; -typedef std::tuple<Box, CollisionBox, IndexedSubfeature> CollisionTreeBox; -typedef bgi::rtree<CollisionTreeBox, bgi::linear<16, 4>> Tree; +using CollisionPoint = bgm::point<float, 2, bg::cs::cartesian>; +using Box = bgm::box<CollisionPoint>; +using CollisionTreeBox = std::tuple<Box, CollisionBox, IndexedSubfeature>; +using Tree = bgi::rtree<CollisionTreeBox, bgi::linear<16, 4>>; class IndexedSubfeature; diff --git a/src/mbgl/text/glyph.hpp b/src/mbgl/text/glyph.hpp index 9cf39de840..458cd688ad 100644 --- a/src/mbgl/text/glyph.hpp +++ b/src/mbgl/text/glyph.hpp @@ -13,8 +13,8 @@ namespace mbgl { -typedef char16_t GlyphID; -typedef std::set<GlyphID> GlyphIDs; +using GlyphID = char16_t; +using GlyphIDs = std::set<GlyphID>; // Note: this only works for the BMP GlyphRange getGlyphRange(GlyphID glyph); @@ -40,8 +40,8 @@ struct Glyph { GlyphMetrics metrics; }; -typedef std::map<GlyphID, optional<Glyph>> GlyphPositions; -typedef std::map<FontStack, GlyphPositions> GlyphPositionMap; +using GlyphPositions = std::map<GlyphID, optional<Glyph>>; +using GlyphPositionMap = std::map<FontStack, GlyphPositions>; class PositionedGlyph { public: @@ -97,8 +97,7 @@ constexpr WritingModeType operator~(WritingModeType value) { return WritingModeType(~mbgl::underlying_type(value)); } -typedef std::map<FontStack,GlyphIDs> GlyphDependencies; -typedef std::map<FontStack,GlyphRangeSet> GlyphRangeDependencies; - +using GlyphDependencies = std::map<FontStack,GlyphIDs>; +using GlyphRangeDependencies = std::map<FontStack,GlyphRangeSet>; } // end namespace mbgl diff --git a/src/mbgl/text/glyph_range.hpp b/src/mbgl/text/glyph_range.hpp index dd39e092b7..74afb73dfc 100644 --- a/src/mbgl/text/glyph_range.hpp +++ b/src/mbgl/text/glyph_range.hpp @@ -7,7 +7,7 @@ namespace mbgl { -typedef std::pair<uint16_t, uint16_t> GlyphRange; +using GlyphRange = std::pair<uint16_t, uint16_t>; struct GlyphRangeHash { std::size_t operator()(const GlyphRange& glyphRange) const { @@ -15,7 +15,7 @@ struct GlyphRangeHash { } }; -typedef std::unordered_set<GlyphRange, GlyphRangeHash> GlyphRangeSet; +using GlyphRangeSet = std::unordered_set<GlyphRange, GlyphRangeHash>; constexpr uint32_t GLYPHS_PER_GLYPH_RANGE = 256; constexpr uint32_t GLYPH_RANGES_PER_FONT_STACK = 256; diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 02236b1b89..6f13331d4c 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -108,7 +108,7 @@ struct GlyphInstance { const float angle = 0.0f; }; -typedef std::vector<GlyphInstance> GlyphInstances; +using GlyphInstances = std::vector<GlyphInstance>; struct VirtualSegment { Point<float> anchor; diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index 333000627b..38dad95243 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -49,7 +49,7 @@ public: WritingModeType writingMode; }; -typedef std::vector<SymbolQuad> SymbolQuads; +using SymbolQuads = std::vector<SymbolQuad>; SymbolQuad getIconQuad(const Anchor& anchor, const PositionedIcon& shapedIcon, diff --git a/src/mbgl/util/mat2.hpp b/src/mbgl/util/mat2.hpp index 6a25ef0f1e..c463202daa 100644 --- a/src/mbgl/util/mat2.hpp +++ b/src/mbgl/util/mat2.hpp @@ -26,7 +26,7 @@ namespace mbgl { -typedef std::array<double, 4> mat2; +using mat2 = std::array<double, 4>; namespace matrix { |