Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ void table_t::task_wait()
// This is legacy code which will be removed anyway.

/* Escape data appropriate to the type */
void table_t::escape_type(std::string const &value, ColumnType flags)
void table_t::escape_type(std::string const &value, column_type_t flags)
{
switch (flags) {
case ColumnType::INT: {
case column_type_t::INT: {
// For integers we take the first number, or the average if it's a-b
long long from = 0;
long long to = 0;
Expand All @@ -387,7 +387,7 @@ void table_t::escape_type(std::string const &value, ColumnType flags)
}
break;
}
case ColumnType::REAL:
case column_type_t::REAL:
/* try to "repair" real values as follows:
* assume "," to be a decimal mark which need to be replaced by "."
* like int4 take the first number, or the average if it's a-b
Expand Down Expand Up @@ -421,7 +421,7 @@ void table_t::escape_type(std::string const &value, ColumnType flags)
}
break;
}
case ColumnType::TEXT:
case column_type_t::TEXT:
m_copy.add_column(value);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class table_t
std::vector<bool> const &used);
void write_hstore_columns(taglist_t const &tags);

void escape_type(std::string const &value, ColumnType flags);
void escape_type(std::string const &value, column_type_t flags);

void generate_copy_column_list();

Expand Down
8 changes: 4 additions & 4 deletions src/taginfo-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ enum column_flags : unsigned int // NOLINT(performance-enum-size)
/* Table columns, representing key= tags */
struct taginfo
{
ColumnType column_type() const
column_type_t column_type() const
{
if (flags & FLAG_INT_TYPE) {
return ColumnType::INT;
return column_type_t::INT;
}
if (flags & FLAG_REAL_TYPE) {
return ColumnType::REAL;
return column_type_t::REAL;
}
return ColumnType::TEXT;
return column_type_t::TEXT;
}

std::string name;
Expand Down
10 changes: 5 additions & 5 deletions src/taginfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
#include <string>
#include <vector>

enum class ColumnType : std::uint8_t
enum class column_type_t : std::uint8_t
{
INT,
REAL,
TEXT
};

struct Column
struct column_t
{
Column(std::string n, std::string tn, ColumnType t)
column_t(std::string n, std::string tn, column_type_t t)
: name(std::move(n)), type_name(std::move(tn)), type(t)
{}

std::string name;
std::string type_name;
ColumnType type;
column_type_t type;
};

using columns_t = std::vector<Column>;
using columns_t = std::vector<column_t>;

#endif // OSM2PGSQL_TAGINFO_HPP
28 changes: 14 additions & 14 deletions tests/test-output-pgsql-style-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ TEST_CASE("Parse style file with single node entry")
REQUIRE(ex.name == "access");
REQUIRE(ex.type == "text");
REQUIRE(ex.flags == column_flags::FLAG_LINEAR);
REQUIRE(ex.column_type() == ColumnType::TEXT);
REQUIRE(ex.column_type() == column_type_t::TEXT);
}

TEST_CASE("Parse style file with a few valid entries")
Expand All @@ -85,12 +85,12 @@ TEST_CASE("Parse style file with a few valid entries")

for (auto const &node : nodes) {
REQUIRE(node.type == "text");
REQUIRE(node.column_type() == ColumnType::TEXT);
REQUIRE(node.column_type() == column_type_t::TEXT);
}

for (auto const &way : ways) {
REQUIRE(way.type == "text");
REQUIRE(way.column_type() == ColumnType::TEXT);
REQUIRE(way.column_type() == column_type_t::TEXT);
}

REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR);
Expand Down Expand Up @@ -123,14 +123,14 @@ TEST_CASE("Parse style file with missing fields")

for (auto const &node : nodes) {
REQUIRE(node.type == "text");
REQUIRE(node.column_type() == ColumnType::TEXT);
REQUIRE(node.column_type() == column_type_t::TEXT);
}
REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR);
REQUIRE(nodes[1].flags == 0);

for (auto const &way : ways) {
REQUIRE(way.type == "text");
REQUIRE(way.column_type() == ColumnType::TEXT);
REQUIRE(way.column_type() == column_type_t::TEXT);
}
REQUIRE(ways[0].flags == column_flags::FLAG_POLYGON);
REQUIRE(ways[1].flags == 0);
Expand All @@ -153,17 +153,17 @@ TEST_CASE("Parse style file with way_area")
REQUIRE(nodes[0].type == "text");
REQUIRE(nodes[0].flags ==
(column_flags::FLAG_POLYGON | column_flags::FLAG_NOCOLUMN));
REQUIRE(nodes[0].column_type() == ColumnType::TEXT);
REQUIRE(nodes[0].column_type() == column_type_t::TEXT);

REQUIRE(ways[0].type == "text");
REQUIRE(ways[0].flags ==
(column_flags::FLAG_POLYGON | column_flags::FLAG_NOCOLUMN));
REQUIRE(ways[0].column_type() == ColumnType::TEXT);
REQUIRE(ways[0].column_type() == column_type_t::TEXT);

REQUIRE(ways[1].type == "real");
REQUIRE(ways[1].flags == 0);
REQUIRE(ways[1].column_type() ==
ColumnType::TEXT); // Special case for way_area!
column_type_t::TEXT); // Special case for way_area!
}

TEST_CASE("Parse style file with different data types")
Expand All @@ -183,30 +183,30 @@ TEST_CASE("Parse style file with different data types")
REQUIRE(nodes[0].name == "name");
REQUIRE(nodes[0].type == "text");
REQUIRE(nodes[0].flags == column_flags::FLAG_LINEAR);
REQUIRE(nodes[0].column_type() == ColumnType::TEXT);
REQUIRE(nodes[0].column_type() == column_type_t::TEXT);

REQUIRE(nodes[1].name == "population");
REQUIRE(nodes[1].type == "integer");
REQUIRE(nodes[1].flags ==
(column_flags::FLAG_POLYGON | column_flags::FLAG_INT_TYPE));
REQUIRE(nodes[1].column_type() == ColumnType::INT);
REQUIRE(nodes[1].column_type() == column_type_t::INT);

REQUIRE(ways[0].name == "name");
REQUIRE(ways[0].type == "text");
REQUIRE(ways[0].flags == column_flags::FLAG_LINEAR);
REQUIRE(ways[0].column_type() == ColumnType::TEXT);
REQUIRE(ways[0].column_type() == column_type_t::TEXT);

REQUIRE(ways[1].name == "width");
REQUIRE(ways[1].type == "real");
REQUIRE(ways[1].flags ==
(column_flags::FLAG_LINEAR | column_flags::FLAG_REAL_TYPE));
REQUIRE(ways[1].column_type() == ColumnType::REAL);
REQUIRE(ways[1].column_type() == column_type_t::REAL);

REQUIRE(ways[2].name == "population");
REQUIRE(ways[2].type == "integer");
REQUIRE(ways[2].flags ==
(column_flags::FLAG_POLYGON | column_flags::FLAG_INT_TYPE));
REQUIRE(ways[2].column_type() == ColumnType::INT);
REQUIRE(ways[2].column_type() == column_type_t::INT);
}

TEST_CASE("Parse style file with invalid data types")
Expand All @@ -225,5 +225,5 @@ TEST_CASE("Parse style file with invalid data types")
REQUIRE(ways[0].name == "highway");
REQUIRE(ways[0].type == "foo");
REQUIRE(ways[0].flags == column_flags::FLAG_LINEAR);
REQUIRE(ways[0].column_type() == ColumnType::TEXT);
REQUIRE(ways[0].column_type() == column_type_t::TEXT);
}