mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-25 15:23:52 +00:00
@@ -1,6 +1,7 @@
|
||||
#include "editor/feature_type_to_osm.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/assert.hpp"
|
||||
#include "coding/reader_streambuf.hpp"
|
||||
#include "indexer/classificator.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
@@ -8,9 +9,16 @@
|
||||
|
||||
namespace editor
|
||||
{
|
||||
void FeatureTypeToOSM::loadConfigFile() {
|
||||
FeatureTypeToOSM::FeatureTypeToOSM()
|
||||
{
|
||||
loadConfigFile();
|
||||
}
|
||||
|
||||
void FeatureTypeToOSM::loadConfigFile() {
|
||||
LOG(LINFO, ("Hello from loadConfigFile"));
|
||||
|
||||
m_storage.clear();
|
||||
|
||||
Platform & p = GetPlatform();
|
||||
|
||||
std::unique_ptr<ModelReader> reader = p.GetReader("mapcss-mapping.csv");
|
||||
@@ -37,14 +45,47 @@ void FeatureTypeToOSM::loadConfigFile() {
|
||||
|
||||
std::vector<std::string_view> tokens = strings::Tokenize(line, ";");
|
||||
|
||||
ASSERT(tokens.size() >= 2, ("TODO1"));
|
||||
|
||||
LOG(LINFO, ("simple type: ", tokens[0]));
|
||||
|
||||
std::string type_name(tokens[0]);
|
||||
replace(type_name.begin(), type_name.end(), '|', '-');
|
||||
|
||||
uint32_t type = classif().GetTypeByReadableObjectName(type_name);
|
||||
|
||||
if (tokens.size() == 2)
|
||||
{
|
||||
// OSM tags can be derived from type name
|
||||
LOG(LINFO, ("simple type: ", tokens[0]));
|
||||
std::vector<std::string_view> typeTokens = strings::Tokenize(type_name, "-");
|
||||
|
||||
ASSERT(typeTokens.size() <= 2, ("OSM tags can not be derived from 3-arity/complex types"));
|
||||
ASSERT(!typeTokens.empty(), ("No type name found"));
|
||||
|
||||
OSMTag osmTag;
|
||||
|
||||
if (typeTokens.size() >= 2) {
|
||||
osmTag.key = typeTokens[0];
|
||||
osmTag.value = typeTokens[1];
|
||||
}
|
||||
else if (typeTokens.size() == 1) {
|
||||
osmTag.key = typeTokens[0];
|
||||
osmTag.value = "yes";
|
||||
}
|
||||
|
||||
m_storage.insert({type, {osmTag}});
|
||||
|
||||
LOG(LINFO, ("Added type ", type, " with key", osmTag.key, " and value ", osmTag.value));
|
||||
|
||||
}
|
||||
else if (tokens.size() > 2)
|
||||
{
|
||||
// OSM tags are listed in the entry
|
||||
LOG(LINFO, ("token size:", tokens.size(), " | osmTags: ", tokens[1]));
|
||||
|
||||
std::vector<std::string_view> osmTagTokens = strings::Tokenize(tokens[1], ",");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,4 +107,10 @@ std::vector<OSMTag> FeatureTypeToOSM::typeToOSM(uint32_t type)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
FeatureTypeToOSM & getOSMTranslator()
|
||||
{
|
||||
static FeatureTypeToOSM translator;
|
||||
return translator;
|
||||
}
|
||||
} // namespace osm
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace editor
|
||||
{
|
||||
@@ -15,12 +16,17 @@ class FeatureTypeToOSM
|
||||
{
|
||||
|
||||
public:
|
||||
void loadConfigFile();
|
||||
FeatureTypeToOSM();
|
||||
|
||||
void loadConfigFile();
|
||||
//static void typeToOSM(uint32_t type);
|
||||
std::vector<OSMTag> typeToOSM(uint32_t type);
|
||||
|
||||
private:
|
||||
//std::vector<OSMTag> storage;
|
||||
std::map<uint32_t, std::vector<OSMTag>> m_storage;
|
||||
|
||||
};
|
||||
|
||||
FeatureTypeToOSM & getOSMTranslator();
|
||||
|
||||
} // namespace osm
|
||||
Reference in New Issue
Block a user