[tidy] modernize-use-auto
This commit is contained in:
@@ -21,7 +21,7 @@ using PaintPropertySetter = optional<Error> (*) (Layer&, const V&, const optiona
|
||||
|
||||
template <class V, class L, class PropertyValue, void (L::*setter)(PropertyValue)>
|
||||
optional<Error> setLayoutProperty(Layer& layer, const V& value) {
|
||||
L* typedLayer = layer.as<L>();
|
||||
auto* typedLayer = layer.as<L>();
|
||||
if (!typedLayer) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
@@ -38,7 +38,7 @@ optional<Error> setLayoutProperty(Layer& layer, const V& value) {
|
||||
|
||||
template <class V, class L, class PropertyValue, void (L::*setter)(PropertyValue, const optional<std::string>&)>
|
||||
optional<Error> setPaintProperty(Layer& layer, const V& value, const optional<std::string>& klass) {
|
||||
L* typedLayer = layer.as<L>();
|
||||
auto* typedLayer = layer.as<L>();
|
||||
if (!typedLayer) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
@@ -55,7 +55,7 @@ optional<Error> setPaintProperty(Layer& layer, const V& value, const optional<st
|
||||
|
||||
template <class V, class L, void (L::*setter)(const TransitionOptions&, const optional<std::string>&)>
|
||||
optional<Error> setTransition(Layer& layer, const V& value, const optional<std::string>& klass) {
|
||||
L* typedLayer = layer.as<L>();
|
||||
auto* typedLayer = layer.as<L>();
|
||||
if (!typedLayer) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
: async(new uv_async_t),
|
||||
task(std::move(fn)) {
|
||||
|
||||
uv_loop_t* loop = reinterpret_cast<uv_loop_t*>(RunLoop::getLoopHandle());
|
||||
auto* loop = reinterpret_cast<uv_loop_t*>(RunLoop::getLoopHandle());
|
||||
if (uv_async_init(loop, async, asyncCallback) != 0) {
|
||||
throw std::runtime_error("Failed to initialize async.");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ PremultipliedImage decodePNG(const uint8_t*, size_t);
|
||||
PremultipliedImage decodeJPEG(const uint8_t*, size_t);
|
||||
|
||||
PremultipliedImage decodeImage(const std::string& string) {
|
||||
const uint8_t* data = reinterpret_cast<const uint8_t*>(string.data());
|
||||
const auto* data = reinterpret_cast<const uint8_t*>(string.data());
|
||||
const size_t size = string.size();
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
|
||||
@@ -21,12 +21,12 @@ struct jpeg_stream_wrapper {
|
||||
};
|
||||
|
||||
static void init_source(j_decompress_ptr cinfo) {
|
||||
jpeg_stream_wrapper* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
||||
auto* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
||||
wrap->stream->seekg(0, std::ios_base::beg);
|
||||
}
|
||||
|
||||
static boolean fill_input_buffer(j_decompress_ptr cinfo) {
|
||||
jpeg_stream_wrapper* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
||||
auto* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
||||
wrap->stream->read(reinterpret_cast<char*>(&wrap->buffer[0]), BUF_SIZE);
|
||||
std::streamsize size = wrap->stream->gcount();
|
||||
wrap->manager.next_input_byte = wrap->buffer.data();
|
||||
@@ -36,7 +36,7 @@ static boolean fill_input_buffer(j_decompress_ptr cinfo) {
|
||||
|
||||
static void skip(j_decompress_ptr cinfo, long count) {
|
||||
if (count <= 0) return; // A zero or negative skip count should be treated as a no-op.
|
||||
jpeg_stream_wrapper* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
||||
auto* wrap = reinterpret_cast<jpeg_stream_wrapper*>(cinfo->src);
|
||||
|
||||
if (wrap->manager.bytes_in_buffer > 0 && count < static_cast<long>(wrap->manager.bytes_in_buffer))
|
||||
{
|
||||
@@ -59,7 +59,7 @@ static void attach_stream(j_decompress_ptr cinfo, std::istream* in) {
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(jpeg_stream_wrapper));
|
||||
}
|
||||
jpeg_stream_wrapper * src = reinterpret_cast<jpeg_stream_wrapper*> (cinfo->src);
|
||||
auto * src = reinterpret_cast<jpeg_stream_wrapper*> (cinfo->src);
|
||||
src->manager.init_source = init_source;
|
||||
src->manager.fill_input_buffer = fill_input_buffer;
|
||||
src->manager.skip_input_data = skip;
|
||||
|
||||
@@ -76,8 +76,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const {
|
||||
switch (type) {
|
||||
case SourceType::Vector:
|
||||
case SourceType::Raster: {
|
||||
style::TileSourceImpl* tileSource =
|
||||
static_cast<style::TileSourceImpl*>(source->baseImpl.get());
|
||||
auto* tileSource = static_cast<style::TileSourceImpl*>(source->baseImpl.get());
|
||||
const variant<std::string, Tileset>& urlOrTileset = tileSource->getURLOrTileset();
|
||||
const uint16_t tileSize = tileSource->getTileSize();
|
||||
|
||||
@@ -86,7 +85,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const {
|
||||
definition.tileCover(type, tileSize, urlOrTileset.get<Tileset>().zoomRange).size();
|
||||
} else {
|
||||
result.requiredResourceCount += 1;
|
||||
const std::string& url = urlOrTileset.get<std::string>();
|
||||
const auto& url = urlOrTileset.get<std::string>();
|
||||
optional<Response> sourceResponse = offlineDatabase.get(Resource::source(url));
|
||||
if (sourceResponse) {
|
||||
style::conversion::Error error;
|
||||
@@ -103,7 +102,7 @@ OfflineRegionStatus OfflineDownload::getStatus() const {
|
||||
}
|
||||
|
||||
case SourceType::GeoJSON: {
|
||||
style::GeoJSONSource* geojsonSource = source->as<style::GeoJSONSource>();
|
||||
auto* geojsonSource = source->as<style::GeoJSONSource>();
|
||||
if (geojsonSource->getURL()) {
|
||||
result.requiredResourceCount += 1;
|
||||
}
|
||||
@@ -151,7 +150,7 @@ void OfflineDownload::activateDownload() {
|
||||
if (urlOrTileset.is<Tileset>()) {
|
||||
queueTiles(type, tileSize, urlOrTileset.get<Tileset>());
|
||||
} else {
|
||||
const std::string& url = urlOrTileset.get<std::string>();
|
||||
const auto& url = urlOrTileset.get<std::string>();
|
||||
status.requiredResourceCountIsPrecise = false;
|
||||
status.requiredResourceCount++;
|
||||
requiredSourceURLs.insert(url);
|
||||
@@ -174,7 +173,7 @@ void OfflineDownload::activateDownload() {
|
||||
}
|
||||
|
||||
case SourceType::GeoJSON: {
|
||||
style::GeoJSONSource::Impl* geojsonSource =
|
||||
auto* geojsonSource =
|
||||
static_cast<style::GeoJSONSource::Impl*>(source->baseImpl.get());
|
||||
|
||||
if (geojsonSource->getURL()) {
|
||||
|
||||
@@ -40,7 +40,7 @@ static void user_warning_fn(png_structp, png_const_charp warning_msg) {
|
||||
}
|
||||
|
||||
static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
|
||||
std::istream* fin = reinterpret_cast<std::istream*>(png_get_io_ptr(png_ptr));
|
||||
auto* fin = reinterpret_cast<std::istream*>(png_get_io_ptr(png_ptr));
|
||||
fin->read(reinterpret_cast<char*>(data), length);
|
||||
std::streamsize read_count = fin->gcount();
|
||||
if (read_count < 0 || static_cast<png_size_t>(read_count) != length)
|
||||
|
||||
@@ -314,7 +314,7 @@ template <> std::string Statement::get(int offset) {
|
||||
|
||||
template <> std::vector<uint8_t> Statement::get(int offset) {
|
||||
assert(impl);
|
||||
const uint8_t* begin = reinterpret_cast<const uint8_t*>(sqlite3_column_blob(impl->stmt, offset));
|
||||
const auto* begin = reinterpret_cast<const uint8_t*>(sqlite3_column_blob(impl->stmt, offset));
|
||||
const uint8_t* end = begin + sqlite3_column_bytes(impl->stmt, offset);
|
||||
return { begin, end };
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace util {
|
||||
class Timer::Impl {
|
||||
public:
|
||||
Impl() : timer(new uv_timer_t) {
|
||||
uv_loop_t* loop = reinterpret_cast<uv_loop_t*>(RunLoop::getLoopHandle());
|
||||
auto* loop = reinterpret_cast<uv_loop_t*>(RunLoop::getLoopHandle());
|
||||
if (uv_timer_init(loop, timer) != 0) {
|
||||
throw std::runtime_error("Failed to initialize timer.");
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void GLFWView::bind() {
|
||||
}
|
||||
|
||||
void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
|
||||
if (action == GLFW_RELEASE) {
|
||||
switch (key) {
|
||||
@@ -356,7 +356,7 @@ void GLFWView::popAnnotation() {
|
||||
}
|
||||
|
||||
void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
double delta = yOffset * 40;
|
||||
|
||||
bool isWheel = delta != 0 && std::fmod(delta, 4.000244140625) == 0;
|
||||
@@ -378,14 +378,14 @@ void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset)
|
||||
}
|
||||
|
||||
void GLFWView::onWindowResize(GLFWwindow *window, int width, int height) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
view->width = width;
|
||||
view->height = height;
|
||||
view->map->setSize({ static_cast<uint32_t>(view->width), static_cast<uint32_t>(view->height) });
|
||||
}
|
||||
|
||||
void GLFWView::onFramebufferResize(GLFWwindow *window, int width, int height) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
view->fbWidth = width;
|
||||
view->fbHeight = height;
|
||||
view->bind();
|
||||
@@ -398,7 +398,7 @@ void GLFWView::onFramebufferResize(GLFWwindow *window, int width, int height) {
|
||||
}
|
||||
|
||||
void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modifiers) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
|
||||
if (button == GLFW_MOUSE_BUTTON_RIGHT ||
|
||||
(button == GLFW_MOUSE_BUTTON_LEFT && modifiers & GLFW_MOD_CONTROL)) {
|
||||
@@ -426,7 +426,7 @@ void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modi
|
||||
}
|
||||
|
||||
void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) {
|
||||
GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
auto *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window));
|
||||
if (view->tracking) {
|
||||
double dx = x - view->lastX;
|
||||
double dy = y - view->lastY;
|
||||
|
||||
@@ -58,8 +58,8 @@ bool HeadlessBackend::hasDisplay() {
|
||||
void HeadlessBackend::createContext() {
|
||||
assert(!hasContext());
|
||||
|
||||
Display* xDisplay = display->attribute<Display*>();
|
||||
GLXFBConfig* fbConfigs = display->attribute<GLXFBConfig*>();
|
||||
auto* xDisplay = display->attribute<Display*>();
|
||||
auto* fbConfigs = display->attribute<GLXFBConfig*>();
|
||||
|
||||
// Try to create a legacy context.
|
||||
GLXContext glContext = glXCreateNewContext(xDisplay, fbConfigs[0], GLX_RGBA_TYPE, None, True);
|
||||
|
||||
@@ -27,7 +27,7 @@ HeadlessDisplay::Impl::Impl() {
|
||||
throw std::runtime_error("Failed to open X display.");
|
||||
}
|
||||
|
||||
const char *extensions = reinterpret_cast<const char *>(glXQueryServerString(xDisplay, DefaultScreen(xDisplay), GLX_EXTENSIONS));
|
||||
const auto *extensions = reinterpret_cast<const char *>(glXQueryServerString(xDisplay, DefaultScreen(xDisplay), GLX_EXTENSIONS));
|
||||
if (!extensions) {
|
||||
throw std::runtime_error("Cannot read GLX extensions.");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void FillAnnotationImpl::updateStyle(Style& style) const {
|
||||
layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
|
||||
}
|
||||
|
||||
FillLayer* fillLayer = layer->as<FillLayer>();
|
||||
auto* fillLayer = layer->as<FillLayer>();
|
||||
fillLayer->setFillOpacity(annotation.opacity);
|
||||
fillLayer->setFillColor(annotation.color);
|
||||
fillLayer->setFillOutlineColor(annotation.outlineColor);
|
||||
|
||||
@@ -22,7 +22,7 @@ void LineAnnotationImpl::updateStyle(Style& style) const {
|
||||
layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
|
||||
}
|
||||
|
||||
LineLayer* lineLayer = layer->as<LineLayer>();
|
||||
auto* lineLayer = layer->as<LineLayer>();
|
||||
lineLayer->setLineOpacity(annotation.opacity);
|
||||
lineLayer->setLineWidth(annotation.width);
|
||||
lineLayer->setLineColor(annotation.color);
|
||||
|
||||
@@ -45,7 +45,7 @@ Context::~Context() {
|
||||
}
|
||||
|
||||
void Context::initializeExtensions(const std::function<gl::ProcAddress(const char*)>& getProcAddress) {
|
||||
if (const char* extensions =
|
||||
if (const auto* extensions =
|
||||
reinterpret_cast<const char*>(MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS)))) {
|
||||
|
||||
auto fn = [&](
|
||||
@@ -94,7 +94,7 @@ UniqueShader Context::createShader(ShaderType type, const std::string& source) {
|
||||
UniqueShader result { MBGL_CHECK_ERROR(glCreateShader(static_cast<GLenum>(type))), { this } };
|
||||
|
||||
const GLchar* sources = source.data();
|
||||
const GLsizei lengths = static_cast<GLsizei>(source.length());
|
||||
const auto lengths = static_cast<GLsizei>(source.length());
|
||||
MBGL_CHECK_ERROR(glShaderSource(result, 1, &sources, &lengths));
|
||||
MBGL_CHECK_ERROR(glCompileShader(result));
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType
|
||||
const bool isSharpCorner = cosHalfAngle < COS_HALF_SHARP_CORNER && prevCoordinate && nextCoordinate;
|
||||
|
||||
if (isSharpCorner && i > first) {
|
||||
const double prevSegmentLength = util::dist<double>(*currentCoordinate, *prevCoordinate);
|
||||
const auto prevSegmentLength = util::dist<double>(*currentCoordinate, *prevCoordinate);
|
||||
if (prevSegmentLength > 2.0 * sharpCornerOffset) {
|
||||
GeometryCoordinate newPrevVertex = *currentCoordinate - convertPoint<int16_t>(util::round(convertPoint<double>(*currentCoordinate - *prevCoordinate) * (sharpCornerOffset / prevSegmentLength)));
|
||||
distance += util::dist<double>(newPrevVertex, *prevCoordinate);
|
||||
@@ -356,7 +356,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates, FeatureType
|
||||
}
|
||||
|
||||
if (isSharpCorner && i < len - 1) {
|
||||
const double nextSegmentLength = util::dist<double>(*currentCoordinate, *nextCoordinate);
|
||||
const auto nextSegmentLength = util::dist<double>(*currentCoordinate, *nextCoordinate);
|
||||
if (nextSegmentLength > 2 * sharpCornerOffset) {
|
||||
GeometryCoordinate newCurrentVertex = *currentCoordinate + convertPoint<int16_t>(util::round(convertPoint<double>(*nextCoordinate - *currentCoordinate) * (sharpCornerOffset / nextSegmentLength)));
|
||||
distance += util::dist<double>(newCurrentVertex, *currentCoordinate);
|
||||
|
||||
@@ -18,7 +18,7 @@ ClassDictionary &ClassDictionary::Get() {
|
||||
});
|
||||
});
|
||||
|
||||
ClassDictionary *ptr = reinterpret_cast<ClassDictionary *>(pthread_getspecific(store_key));
|
||||
auto *ptr = reinterpret_cast<ClassDictionary *>(pthread_getspecific(store_key));
|
||||
if (ptr == nullptr) {
|
||||
ptr = new ClassDictionary();
|
||||
pthread_setspecific(store_key, ptr);
|
||||
@@ -31,7 +31,7 @@ ClassID ClassDictionary::lookup(const std::string &class_name) {
|
||||
auto it = store.find(class_name);
|
||||
if (it == store.end()) {
|
||||
// Insert the class name into the store.
|
||||
ClassID id = ClassID(uint32_t(ClassID::Named) + offset++);
|
||||
auto id = ClassID(uint32_t(ClassID::Named) + offset++);
|
||||
store.emplace(class_name, id);
|
||||
return id;
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,7 @@ optional<std::array<float, 2>> IdentityStops<std::array<float, 2>>::evaluate(con
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::vector<Value>& vector = value.get<std::vector<Value>>();
|
||||
const auto& vector = value.get<std::vector<Value>>();
|
||||
if (vector.size() != 2 || !numericValue<float>(vector[0]) || !numericValue<float>(vector[1])) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ Style::~Style() {
|
||||
}
|
||||
|
||||
for (const auto& layer : layers) {
|
||||
if (CustomLayer* customLayer = layer->as<CustomLayer>()) {
|
||||
if (auto* customLayer = layer->as<CustomLayer>()) {
|
||||
customLayer->impl->deinitialize();
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ Layer* Style::addLayer(std::unique_ptr<Layer> layer, optional<std::string> befor
|
||||
throw std::runtime_error(std::string{"Layer "} + layer->getID() + " already exists");
|
||||
}
|
||||
|
||||
if (CustomLayer* customLayer = layer->as<CustomLayer>()) {
|
||||
if (auto* customLayer = layer->as<CustomLayer>()) {
|
||||
customLayer->impl->initialize();
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ std::unique_ptr<Layer> Style::removeLayer(const std::string& id) {
|
||||
|
||||
auto layer = std::move(*it);
|
||||
|
||||
if (CustomLayer* customLayer = layer->as<CustomLayer>()) {
|
||||
if (auto* customLayer = layer->as<CustomLayer>()) {
|
||||
customLayer->impl->deinitialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ void TileSourceImpl::loadDescription(FileSource& fileSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string& url = urlOrTileset.get<std::string>();
|
||||
const auto& url = urlOrTileset.get<std::string>();
|
||||
req = fileSource.request(Resource::source(url), [this, url](Response res) {
|
||||
if (res.error) {
|
||||
observer->onSourceError(base, std::make_exception_ptr(std::runtime_error(res.error->message)));
|
||||
|
||||
@@ -71,7 +71,7 @@ void CollisionFeature::bboxifyLabel(const GeometryCoordinates& line, GeometryCoo
|
||||
p = line[index];
|
||||
} while (anchorDistance > -labelLength / 2);
|
||||
|
||||
float segmentLength = util::dist<float>(line[index], line[index + 1]);
|
||||
auto segmentLength = util::dist<float>(line[index], line[index + 1]);
|
||||
|
||||
for (unsigned int i = 0; i < nBoxes; i++) {
|
||||
// the distance the box will be from the anchor
|
||||
|
||||
@@ -34,7 +34,7 @@ static Anchors resample(const GeometryCoordinates& line,
|
||||
const GeometryCoordinate& a = *(it);
|
||||
const GeometryCoordinate& b = *(it + 1);
|
||||
|
||||
const float segmentDist = util::dist<float>(a, b);
|
||||
const auto segmentDist = util::dist<float>(a, b);
|
||||
const float angle = util::angle_to(b, a);
|
||||
|
||||
while (markedDistance + spacing < distance + segmentDist) {
|
||||
|
||||
@@ -177,7 +177,7 @@ inline Point<float> getVirtualSegmentAnchor(const Point<float>& segmentBegin, co
|
||||
inline float getMinScaleForSegment(const float glyphDistanceFromAnchor,
|
||||
const Point<float>& segmentAnchor,
|
||||
const Point<float>& segmentEnd) {
|
||||
const float distanceFromAnchorToEnd = util::dist<float>(segmentAnchor, segmentEnd);
|
||||
const auto distanceFromAnchorToEnd = util::dist<float>(segmentAnchor, segmentEnd);
|
||||
return glyphDistanceFromAnchor / distanceFromAnchorToEnd;
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ optional<Value> VectorTileFeature::getValue(const std::string& key) const {
|
||||
auto start_itr = tags_iter.begin();
|
||||
const auto & end_itr = tags_iter.end();
|
||||
while (start_itr != end_itr) {
|
||||
uint32_t tag_key = static_cast<uint32_t>(*start_itr++);
|
||||
auto tag_key = static_cast<uint32_t>(*start_itr++);
|
||||
|
||||
if (layerData->keysMap.size() <= tag_key) {
|
||||
throw std::runtime_error("feature referenced out of range key");
|
||||
@@ -172,7 +172,7 @@ optional<Value> VectorTileFeature::getValue(const std::string& key) const {
|
||||
throw std::runtime_error("uneven number of feature tag ids");
|
||||
}
|
||||
|
||||
uint32_t tag_val = static_cast<uint32_t>(*start_itr++);;
|
||||
auto tag_val = static_cast<uint32_t>(*start_itr++);;
|
||||
if (layerData->values.size() <= tag_val) {
|
||||
throw std::runtime_error("feature referenced out of range value");
|
||||
}
|
||||
@@ -190,11 +190,11 @@ std::unordered_map<std::string,Value> VectorTileFeature::getProperties() const {
|
||||
auto start_itr = tags_iter.begin();
|
||||
const auto & end_itr = tags_iter.end();
|
||||
while (start_itr != end_itr) {
|
||||
uint32_t tag_key = static_cast<uint32_t>(*start_itr++);
|
||||
auto tag_key = static_cast<uint32_t>(*start_itr++);
|
||||
if (start_itr == end_itr) {
|
||||
throw std::runtime_error("uneven number of feature tag ids");
|
||||
}
|
||||
uint32_t tag_val = static_cast<uint32_t>(*start_itr++);
|
||||
auto tag_val = static_cast<uint32_t>(*start_itr++);
|
||||
properties[layerData->keys.at(tag_key)] = layerData->values.at(tag_val);
|
||||
}
|
||||
return properties;
|
||||
@@ -219,7 +219,7 @@ GeometryCollection VectorTileFeature::getGeometries() const {
|
||||
auto g_itr = geometry_iter.begin();
|
||||
while (g_itr != geometry_iter.end()) {
|
||||
if (length == 0) {
|
||||
uint32_t cmd_length = static_cast<uint32_t>(*g_itr++);
|
||||
auto cmd_length = static_cast<uint32_t>(*g_itr++);
|
||||
cmd = cmd_length & 0x7;
|
||||
length = cmd_length >> 3;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ bool polygonContainsPoint(const GeometryCoordinates& ring, const GeometryCoordin
|
||||
// Code from http://stackoverflow.com/a/1501725/331379.
|
||||
float distToSegmentSquared(const GeometryCoordinate& p, const GeometryCoordinate& v, const GeometryCoordinate& w) {
|
||||
if (v == w) return util::distSqr<float>(p, v);
|
||||
const float l2 = util::distSqr<float>(v, w);
|
||||
const auto l2 = util::distSqr<float>(v, w);
|
||||
const float t = float((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
||||
if (t < 0) return util::distSqr<float>(p, v);
|
||||
if (t > 1) return util::distSqr<float>(p, w);
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
}
|
||||
|
||||
T* get() {
|
||||
T* ret = reinterpret_cast<T*>(pthread_getspecific(key));
|
||||
auto* ret = reinterpret_cast<T*>(pthread_getspecific(key));
|
||||
if (!ret) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user