diff options
author | Juha Alanen <juha.alanen@mapbox.com> | 2019-09-17 15:40:01 +0300 |
---|---|---|
committer | Juha Alanen <19551460+jmalanen@users.noreply.github.com> | 2019-09-18 14:29:15 +0300 |
commit | 6b13c42314f28e3b27111367c4f3296c3c3c1248 (patch) | |
tree | 2f91aae637e2c49bb55cfc336f772ac772ab5a2d /platform | |
parent | 0042f0b9f5de7151f14300f02a559b6ecb48a507 (diff) | |
download | qtlocation-mapboxgl-6b13c42314f28e3b27111367c4f3296c3c3c1248.tar.gz |
[build] Fix clang format and tidy checks
Diffstat (limited to 'platform')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 61 | ||||
-rw-r--r-- | platform/glfw/glfw_view.hpp | 4 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 22 |
3 files changed, 45 insertions, 42 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 7d05bab43a..c39b2c904a 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -4,24 +4,24 @@ #include "ny_route.hpp" #include <mbgl/annotation/annotation.hpp> -#include <mbgl/style/style.hpp> -#include <mbgl/style/sources/custom_geometry_source.hpp> -#include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/gfx/backend.hpp> +#include <mbgl/gfx/backend_scope.hpp> +#include <mbgl/map/camera.hpp> +#include <mbgl/renderer/renderer.hpp> +#include <mbgl/style/expression/dsl.hpp> #include <mbgl/style/image.hpp> -#include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/fill_extrusion_layer.hpp> -#include <mbgl/style/layers/line_layer.hpp> #include <mbgl/style/layers/fill_layer.hpp> -#include <mbgl/style/expression/dsl.hpp> +#include <mbgl/style/layers/line_layer.hpp> +#include <mbgl/style/sources/custom_geometry_source.hpp> +#include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/style/transition_options.hpp> +#include <mbgl/util/chrono.hpp> +#include <mbgl/util/geo.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/util/platform.hpp> #include <mbgl/util/string.hpp> -#include <mbgl/util/chrono.hpp> -#include <mbgl/util/geo.hpp> -#include <mbgl/renderer/renderer.hpp> -#include <mbgl/gfx/backend.hpp> -#include <mbgl/gfx/backend_scope.hpp> -#include <mbgl/map/camera.hpp> #include <mapbox/cheap_ruler.hpp> #include <mapbox/geometry.hpp> @@ -330,7 +330,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, using namespace mbgl::style; using namespace mbgl::style::expression::dsl; - auto& style = view->map->getStyle(); + auto &style = view->map->getStyle(); if (!style.getSource("states")) { std::string url = "https://docs.mapbox.com/mapbox-gl-js/assets/us_states.geojson"; auto source = std::make_unique<GeoJSONSource>("states"); @@ -338,7 +338,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, style.addSource(std::move(source)); mbgl::CameraOptions cameraOptions; - cameraOptions.center = mbgl::LatLng { 42.619626, -103.523181 }; + cameraOptions.center = mbgl::LatLng{42.619626, -103.523181}; cameraOptions.zoom = 3; cameraOptions.pitch = 0; cameraOptions.bearing = 0; @@ -348,23 +348,27 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, auto layer = style.getLayer("state-fills"); if (!layer) { auto fillLayer = std::make_unique<FillLayer>("state-fills", "states"); - fillLayer->setFillColor(mbgl::Color{ 0.0, 0.0, 1.0, 0.5 }); - fillLayer->setFillOpacity(PropertyExpression<float>(createExpression(R"(["case", ["boolean", ["feature-state", "hover"], false], 1, 0.5])"))); + fillLayer->setFillColor(mbgl::Color{0.0, 0.0, 1.0, 0.5}); + fillLayer->setFillOpacity(PropertyExpression<float>( + createExpression(R"(["case", ["boolean", ["feature-state", "hover"], false], 1, 0.5])"))); style.addLayer(std::move(fillLayer)); } else { - layer->setVisibility(layer->getVisibility() == mbgl::style::VisibilityType::Visible ? - mbgl::style::VisibilityType::None : mbgl::style::VisibilityType::Visible); + layer->setVisibility(layer->getVisibility() == mbgl::style::VisibilityType::Visible + ? mbgl::style::VisibilityType::None + : mbgl::style::VisibilityType::Visible); } layer = style.getLayer("state-borders"); if (!layer) { auto borderLayer = std::make_unique<LineLayer>("state-borders", "states"); - borderLayer->setLineColor(mbgl::Color{ 0.0, 0.0, 1.0, 1.0 }); - borderLayer->setLineWidth(PropertyExpression<float>(createExpression(R"(["case", ["boolean", ["feature-state", "hover"], false], 2, 1])"))); + borderLayer->setLineColor(mbgl::Color{0.0, 0.0, 1.0, 1.0}); + borderLayer->setLineWidth(PropertyExpression<float>( + createExpression(R"(["case", ["boolean", ["feature-state", "hover"], false], 2, 1])"))); style.addLayer(std::move(borderLayer)); } else { - layer->setVisibility(layer->getVisibility() == mbgl::style::VisibilityType::Visible ? - mbgl::style::VisibilityType::None : mbgl::style::VisibilityType::Visible); + layer->setVisibility(layer->getVisibility() == mbgl::style::VisibilityType::Visible + ? mbgl::style::VisibilityType::None + : mbgl::style::VisibilityType::Visible); } } break; } @@ -581,7 +585,6 @@ void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modi } view->lastClick = now; } - } } @@ -604,10 +607,10 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { view->lastX = x; view->lastY = y; - auto& style = view->map->getStyle(); + auto &style = view->map->getStyle(); if (style.getLayer("state-fills")) { - auto screenCoordinate = mbgl::ScreenCoordinate { view->lastX, view->lastY }; - const mbgl::RenderedQueryOptions queryOptions({{{ "state-fills" }}, {}}); + auto screenCoordinate = mbgl::ScreenCoordinate{view->lastX, view->lastY}; + const mbgl::RenderedQueryOptions queryOptions({{{"state-fills"}}, {}}); auto result = view->rendererFrontend->getRenderer()->queryRenderedFeatures(screenCoordinate, queryOptions); using namespace mbgl; FeatureState newState; @@ -619,20 +622,20 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { if (idStr) { if (view->featureID && (*view->featureID != *idStr)) { newState["hover"] = false; - view->rendererFrontend->getRenderer()->setFeatureState("states", { }, *view->featureID, newState); + view->rendererFrontend->getRenderer()->setFeatureState("states", {}, *view->featureID, newState); view->featureID = nullopt; } if (!view->featureID) { newState["hover"] = true; view->featureID = featureIDtoString(id); - view->rendererFrontend->getRenderer()->setFeatureState("states", { }, *view->featureID, newState); + view->rendererFrontend->getRenderer()->setFeatureState("states", {}, *view->featureID, newState); } } } else { if (view->featureID) { newState["hover"] = false; - view->rendererFrontend->getRenderer()->setFeatureState("states", { }, *view->featureID, newState); + view->rendererFrontend->getRenderer()->setFeatureState("states", {}, *view->featureID, newState); view->featureID = nullopt; } } diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index cc7c821810..dbe6ceb046 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -1,10 +1,10 @@ #pragma once #include <mbgl/map/map.hpp> -#include <mbgl/util/run_loop.hpp> -#include <mbgl/util/timer.hpp> #include <mbgl/util/geometry.hpp> #include <mbgl/util/optional.hpp> +#include <mbgl/util/run_loop.hpp> +#include <mbgl/util/timer.hpp> struct GLFWwindow; class GLFWBackend; diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index d9bee1c840..7450f461f8 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -1135,7 +1135,7 @@ void NodeMap::SetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) if (!sourceLayerOption->IsString()) { return Nan::ThrowTypeError("SetFeatureState: Requires feature.sourceLayer property to be a string"); } - sourceLayerID = { *Nan::Utf8String(sourceLayerOption) }; + sourceLayerID = {*Nan::Utf8String(sourceLayerOption)}; } if (Nan::Has(feature, Nan::New("id").ToLocalChecked()).FromJust()) { @@ -1160,7 +1160,8 @@ void NodeMap::SetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) bool valueParsed = false; FeatureState newState; - const std::function<optional<Error> (const std::string&, const Convertible&)> convertFn = [&] (const std::string& k, const Convertible& v) -> optional<Error> { + const std::function<optional<Error>(const std::string&, const Convertible&)> convertFn = + [&](const std::string& k, const Convertible& v) -> optional<Error> { optional<Value> value = toValue(v); if (value) { stateValue = std::move(*value); @@ -1176,14 +1177,13 @@ void NodeMap::SetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) } } std::unordered_map<std::string, Value> result; - result[k]= std::move(array); + result[k] = std::move(array); stateValue = std::move(result); valueParsed = true; return {}; } else if (isObject(v)) { eachMember(v, convertFn); - } if (!valueParsed) { Nan::ThrowTypeError("Could not get feature state value"); @@ -1198,7 +1198,7 @@ void NodeMap::SetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) try { nodeMap->frontend->getRenderer()->setFeatureState(sourceID, sourceLayerID, featureID, newState); - } catch (const std::exception &ex) { + } catch (const std::exception& ex) { return Nan::ThrowError(ex.what()); } @@ -1235,7 +1235,7 @@ void NodeMap::GetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) if (!sourceLayerOption->IsString()) { return Nan::ThrowTypeError("GetFeatureState: Requires feature.sourceLayer property to be a string"); } - sourceLayerID = { *Nan::Utf8String(sourceLayerOption) }; + sourceLayerID = {*Nan::Utf8String(sourceLayerOption)}; } if (Nan::Has(feature, Nan::New("id").ToLocalChecked()).FromJust()) { @@ -1251,7 +1251,7 @@ void NodeMap::GetFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& info) mbgl::FeatureState state; try { nodeMap->frontend->getRenderer()->getFeatureState(state, sourceID, sourceLayerID, featureID); - } catch (const std::exception &ex) { + } catch (const std::exception& ex) { return Nan::ThrowError(ex.what()); } @@ -1292,7 +1292,7 @@ void NodeMap::RemoveFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& inf if (!sourceLayerOption->IsString()) { return Nan::ThrowTypeError("RemoveFeatureState: Requires feature.sourceLayer property to be a string"); } - sourceLayerID = { *Nan::Utf8String(sourceLayerOption) }; + sourceLayerID = {*Nan::Utf8String(sourceLayerOption)}; } if (Nan::Has(feature, Nan::New("id").ToLocalChecked()).FromJust()) { @@ -1300,7 +1300,7 @@ void NodeMap::RemoveFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& inf if (!idOption->IsString() && !(idOption->IsNumber() || idOption->IsString())) { return Nan::ThrowTypeError("Requires feature.id property to be a string or a number"); } - featureID = { *Nan::Utf8String(idOption) }; + featureID = {*Nan::Utf8String(idOption)}; } if (info.Length() == 2) { @@ -1308,12 +1308,12 @@ void NodeMap::RemoveFeatureState(const Nan::FunctionCallbackInfo<v8::Value>& inf if (!keyParam->IsString()) { return Nan::ThrowTypeError("RemoveFeatureState: Requires feature key property to be a string"); } - stateKey = { *Nan::Utf8String(keyParam) }; + stateKey = {*Nan::Utf8String(keyParam)}; } try { nodeMap->frontend->getRenderer()->removeFeatureState(sourceID, sourceLayerID, featureID, stateKey); - } catch (const std::exception &ex) { + } catch (const std::exception& ex) { return Nan::ThrowError(ex.what()); } |