don't implicitly cast to bool since this will make comparisons fails

This commit is contained in:
Konstantin Käfer
2015-05-06 12:17:16 +02:00
committed by John Firebaugh
parent 76b47e801e
commit 8dd6da5b5e
4 changed files with 6 additions and 6 deletions

View File

@@ -236,7 +236,7 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer,
}
// if either shaping or icon position is present, add the feature
if (shaping.size() || image) {
if (shaping.size() || image.hasArea()) {
for (const auto& line : feature.geometry) {
if (line.size()) {
addFeature(line, shaping, face, image);
@@ -265,7 +265,7 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
const float textBoxScale = collision.tilePixelRatio * fontScale;
const float iconBoxScale = collision.tilePixelRatio * layout.icon.max_size;
const bool iconWithoutText = layout.text.optional || !shaping.size();
const bool textWithoutIcon = layout.icon.optional || !image;
const bool textWithoutIcon = layout.icon.optional || !image.hasArea();
const bool avoidEdges = layout.avoid_edges && layout.placement != PlacementType::Line;
Anchors anchors;
@@ -322,7 +322,7 @@ void SymbolBucket::addFeature(const std::vector<Coordinate> &line, const Shaping
continue;
}
if (image) {
if (image.hasArea()) {
iconPlacement = Placement::getIcon(anchor, image, iconBoxScale, line, layout);
iconScale =
layout.icon.allow_overlap

View File

@@ -35,7 +35,7 @@ struct Glyph {
: rect(rect_), metrics(metrics_) {}
operator bool() const {
return metrics || rect;
return metrics || rect.hasArea();
}
const Rect<uint16_t> rect;

View File

@@ -224,7 +224,7 @@ Placement Placement::getGlyphs(Anchor &anchor, const vec2<float> &origin, const
if (!glyph)
continue;
if (!rect)
if (!rect.hasArea())
continue;
const float x = (origin.x + shape.x + glyph.metrics.left - buffer + rect.w / 2) * boxScale;

View File

@@ -16,7 +16,7 @@ struct Rect {
return Rect(x * value, y * value, w * value, h * value);
}
operator bool() const { return w != 0 && h != 0; }
inline bool hasArea() const { return w != 0 && h != 0; }
};
}