Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jun 28, 2016
1 parent b62979b commit b28cb78
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion include/mapbox/geojsonvt/tile.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <mapbox/geojsonvt/types.hpp>
#include <cmath>
#include <mapbox/geojsonvt/types.hpp>

namespace mapbox {
namespace geojsonvt {
Expand Down
14 changes: 6 additions & 8 deletions test/test.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "util.hpp"
#include <gtest/gtest.h>
#include <mapbox/geometry.hpp>
#include <mapbox/geojson.hpp>
#include <mapbox/geojsonvt.hpp>
#include <mapbox/geojsonvt/clip.hpp>
#include <mapbox/geojsonvt/convert.hpp>
#include <mapbox/geojsonvt/simplify.hpp>
#include <mapbox/geojsonvt/tile.hpp>
#include <mapbox/geometry.hpp>

#include <cmath>
#include <iostream>
Expand Down Expand Up @@ -187,7 +187,7 @@ TEST(GetTile, USStates) {
ASSERT_EQ(square == index.getTile(9, 148, 192).features, true); // clipped square
ASSERT_EQ(square == index.getTile(11, 592, 768).features, true); // clipped square

ASSERT_EQ(empty_tile == index.getTile(11, 800, 400), true); // non-existing tile
ASSERT_EQ(empty_tile == index.getTile(11, 800, 400), true); // non-existing tile
ASSERT_EQ(&empty_tile == &index.getTile(11, 800, 400), true); // non-existing tile

// This test does not make sense in C++, since the parameters are cast to integers anyway.
Expand All @@ -210,14 +210,14 @@ genTiles(const std::string& data, uint8_t maxZoom = 0, uint32_t maxPoints = 1000
} else if (geojson.is<mapbox::geojson::feature>()) {
features.emplace_back(geojson.get<mapbox::geojson::feature>());
} else if (geojson.is<mapbox::geojson::geometry>()) {
const auto &geom = geojson.get<mapbox::geojson::geometry>();
const auto& geom = geojson.get<mapbox::geojson::geometry>();
if (geom.is<mapbox::geojson::geometry_collection>()) {
for (const auto& item : geom.get<mapbox::geojson::geometry_collection>()) {
mapbox::geometry::feature<double> feat { item };
mapbox::geometry::feature<double> feat{ item };
features.emplace_back(feat);
}
} else {
mapbox::geometry::feature<double> feat { geom };
mapbox::geometry::feature<double> feat{ geom };
features.emplace_back(feat);
}
}
Expand Down Expand Up @@ -297,6 +297,4 @@ INSTANTIATE_TEST_CASE_P(
{ "test/fixtures/dateline.json", "test/fixtures/dateline-tiles.json", 7, 200 },
{ "test/fixtures/feature.json", "test/fixtures/feature-tiles.json" },
{ "test/fixtures/collection.json", "test/fixtures/collection-tiles.json" },
{ "test/fixtures/single-geom.json", "test/fixtures/single-geom-tiles.json" }
}));

{ "test/fixtures/single-geom.json", "test/fixtures/single-geom-tiles.json" } }));
34 changes: 18 additions & 16 deletions test/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#pragma GCC diagnostic pop

#include <fstream>
#include <sstream>
#include <map>
#include <sstream>

namespace mapbox {
namespace geojsonvt {
Expand All @@ -35,14 +35,16 @@ std::string loadFile(const std::string& filename) {
throw std::runtime_error("Error opening file");
}

bool operator==(const mapbox::geometry::feature<short>& a, const mapbox::geometry::feature<short>& b) {
bool operator==(const mapbox::geometry::feature<short>& a,
const mapbox::geometry::feature<short>& b) {
// EXPECT_EQ(a.geometry, b.geometry);
EXPECT_EQ(typeid(a.geometry), typeid(b.geometry));
EXPECT_EQ(a.properties, b.properties);
return true;
}

bool operator==(const mapbox::geometry::feature_collection<short>& a, const mapbox::geometry::feature_collection<short>& b) {
bool operator==(const mapbox::geometry::feature_collection<short>& a,
const mapbox::geometry::feature_collection<short>& b) {
EXPECT_EQ(a.size(), b.size());
if (a.size() == b.size()) {
unsigned i = 0;
Expand All @@ -53,9 +55,11 @@ bool operator==(const mapbox::geometry::feature_collection<short>& a, const mapb
return true;
}

bool operator==(const std::map<std::string, mapbox::geometry::feature_collection<short>>& a, const std::map<std::string, mapbox::geometry::feature_collection<short>>& b) {
bool operator==(const std::map<std::string, mapbox::geometry::feature_collection<short>>& a,
const std::map<std::string, mapbox::geometry::feature_collection<short>>& b) {
EXPECT_EQ(a.size(), b.size());
typedef std::map<std::string, mapbox::geometry::feature_collection<short>>::const_iterator it_type;
typedef std::map<std::string, mapbox::geometry::feature_collection<short>>::const_iterator
it_type;
for (it_type it = a.begin(); it != a.end(); it++) {
if (b.find(it->first) != b.end()) {
EXPECT_TRUE(it->second == b.find(it->first)->second);
Expand Down Expand Up @@ -87,7 +91,7 @@ parseJSONTile(const rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAll
for (rapidjson::SizeType k = 0; k < tile.Size(); ++k) {
const auto& feature = tile[k];

mapbox::geometry::feature<short> feat { mapbox::geometry::point<short>() };
mapbox::geometry::feature<short> feat{ mapbox::geometry::point<short>() };

if (feature.HasMember("tags") && feature["tags"].IsObject()) {
const auto& tags = feature["tags"];
Expand All @@ -104,7 +108,8 @@ parseJSONTile(const rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAll
feat.properties.emplace(tagKey, true);
break;
case rapidjson::kStringType:
feat.properties.emplace(tagKey, std::string{ jt->value.GetString(), jt->value.GetStringLength() });
feat.properties.emplace(
tagKey, std::string{ jt->value.GetString(), jt->value.GetStringLength() });
break;
case rapidjson::kNumberType:
if (jt->value.IsUint64()) {
Expand Down Expand Up @@ -136,11 +141,9 @@ parseJSONTile(const rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAll
EXPECT_TRUE(pt[0].IsNumber());
EXPECT_TRUE(pt[1].IsNumber());
feat.geometry = mapbox::geometry::point<int16_t>(
static_cast<int16_t>(pt[0].GetInt()),
static_cast<int16_t>(pt[1].GetInt())
);
static_cast<int16_t>(pt[0].GetInt()), static_cast<int16_t>(pt[1].GetInt()));
}
// polygon geometry
// polygon geometry
} else if (geomType == 3) {
mapbox::geometry::polygon<int16_t> poly;
for (rapidjson::SizeType j = 0; j < geometry.Size(); ++j) {
Expand All @@ -153,10 +156,8 @@ parseJSONTile(const rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAll
EXPECT_TRUE(pt.Size() >= 2);
EXPECT_TRUE(pt[0].IsNumber());
EXPECT_TRUE(pt[1].IsNumber());
linear_ring.emplace_back(
static_cast<int16_t>(pt[0].GetInt()),
static_cast<int16_t>(pt[1].GetInt())
);
linear_ring.emplace_back(static_cast<int16_t>(pt[0].GetInt()),
static_cast<int16_t>(pt[1].GetInt()));
}
poly.emplace_back(linear_ring);
}
Expand All @@ -183,7 +184,8 @@ mapbox::geometry::feature_collection<int16_t> parseJSONTile(const std::string& d
return parseJSONTile(d);
}

std::map<std::string, mapbox::geometry::feature_collection<int16_t>> parseJSONTiles(const std::string& data) {
std::map<std::string, mapbox::geometry::feature_collection<int16_t>>
parseJSONTiles(const std::string& data) {
std::map<std::string, mapbox::geometry::feature_collection<int16_t>> result;
rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
d.Parse<0>(data.c_str());
Expand Down
16 changes: 10 additions & 6 deletions test/util.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#pragma once

#include <mapbox/geometry.hpp>
#include <map>
#include <mapbox/geojsonvt/tile.hpp>
#include <mapbox/geojsonvt/types.hpp>
#include <mapbox/geometry.hpp>
#include <sstream>
#include <map>

namespace mapbox {
namespace geojsonvt {

std::string loadFile(const std::string& filename);
mapbox::geometry::feature_collection<int16_t> parseJSONTile(const std::string& data);
std::map<std::string, mapbox::geometry::feature_collection<int16_t>> parseJSONTiles(const std::string& data);
bool operator==(const mapbox::geometry::feature<short>& a, const mapbox::geometry::feature<short>& b);
bool operator==(const mapbox::geometry::feature_collection<short>& a, const mapbox::geometry::feature_collection<short>& b);
bool operator==(const std::map<std::string, mapbox::geometry::feature_collection<short>>& a, const std::map<std::string, mapbox::geometry::feature_collection<short>>& b);
std::map<std::string, mapbox::geometry::feature_collection<int16_t>>
parseJSONTiles(const std::string& data);
bool operator==(const mapbox::geometry::feature<short>& a,
const mapbox::geometry::feature<short>& b);
bool operator==(const mapbox::geometry::feature_collection<short>& a,
const mapbox::geometry::feature_collection<short>& b);
bool operator==(const std::map<std::string, mapbox::geometry::feature_collection<short>>& a,
const std::map<std::string, mapbox::geometry::feature_collection<short>>& b);
bool operator==(const mapbox::geojsonvt::Tile& a, const mapbox::geojsonvt::Tile& b);

namespace detail {
Expand Down

0 comments on commit b28cb78

Please sign in to comment.