diff --git a/plugins/navteq/converter/HamletConverter.cpp b/plugins/navteq/converter/HamletConverter.cpp
new file mode 100644
index 0000000..bfb685d
--- /dev/null
+++ b/plugins/navteq/converter/HamletConverter.cpp
@@ -0,0 +1,101 @@
+/*
+ * This file is part of the Morituri project.
+ * Morituri is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Morituri is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Morituri. If not, see .
+ */
+
+#include "HamletConverter.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../comm2osm_exceptions.hpp"
+#include "../../util.hpp"
+
+void HamletConverter::convert(const std::vector &dirs,
+ osmium::io::Writer &writer) {
+
+ const boost::filesystem::path HAMLET_SHP = "Hamlet.shp";
+
+ for (const auto &dir : dirs) {
+ add_hamlet(dir / HAMLET_SHP, writer);
+ }
+}
+
+void HamletConverter::add_hamlet(boost::filesystem::path hamlet_file,
+ osmium::io::Writer &writer) {
+
+ auto ds = GDALDatasetUniquePtr(GDALDataset::Open(hamlet_file.c_str()));
+ if (!ds) {
+ BOOST_LOG_TRIVIAL(debug) << "No hamlet shp found in " << hamlet_file;
+ return;
+ }
+ auto layer = ds->GetLayer(0);
+ if (!layer) {
+ throw(shp_empty_error(hamlet_file.string()));
+ }
+
+ osmium::memory::Buffer node_buffer(BUFFER_SIZE);
+
+ int facTypeField = layer->FindFieldIndex(FAC_TYPE.data(), true);
+ int poiNmTypeField = layer->FindFieldIndex(POI_NMTYPE.data(), true);
+
+ for (auto &feat : *layer) {
+ uint fac_type = feat->GetFieldAsInteger(facTypeField);
+ if (fac_type != 9998) {
+ BOOST_LOG_TRIVIAL(error)
+ << "Skipping hamlet node because of wrong POI type";
+ continue;
+ }
+
+ std::string name_type = feat->GetFieldAsString(poiNmTypeField);
+ if (name_type != "B") {
+ // Skip this entry as it's just a translated namePlc of former one
+ continue;
+ }
+ process_hamlets(feat, node_buffer);
+ }
+ writer(std::move(node_buffer));
+}
+
+void HamletConverter::process_hamlets(const OGRFeatureUniquePtr &feat,
+ osmium::memory::Buffer &node_buffer) {
+
+ auto geom = feat->GetGeometryRef();
+ auto geom_type = geom->getGeometryType();
+
+ if (geom_type != wkbPoint) {
+ throw(std::runtime_error(
+ "Hamlet item with geometry=" + std::string(geom->getGeometryName()) +
+ " is not yet supported."));
+ }
+
+ auto point = static_cast(geom);
+ osmium::Location location(point->getX(), point->getY());
+ {
+ // scope node_builder
+ // Add new node
+ osmium::builder::NodeBuilder node_builder(node_buffer);
+ build_node(location, node_builder);
+ osmium::builder::TagListBuilder tl_builder(node_builder);
+
+ std::string name = feat->GetFieldAsString(POI_NAME.data());
+ tl_builder.add_tag("name", to_camel_case_with_spaces(name));
+ tl_builder.add_tag("place", "hamlet");
+ }
+ node_buffer.commit();
+}
\ No newline at end of file
diff --git a/plugins/navteq/converter/HamletConverter.hpp b/plugins/navteq/converter/HamletConverter.hpp
new file mode 100644
index 0000000..4fd7e79
--- /dev/null
+++ b/plugins/navteq/converter/HamletConverter.hpp
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the Morituri project.
+ * Morituri is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Morituri is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Morituri. If not, see .
+ */
+
+#ifndef HAMELTCONVERTER_HPP
+#define HAMELTCONVERTER_HPP
+
+#include "PointLayerConverter.hpp"
+
+#include
+
+class HamletConverter : public PointLayerConverter {
+
+public:
+ HamletConverter();
+ virtual ~HamletConverter();
+
+ virtual void convert(const std::vector &dirs,
+ osmium::io::Writer &writer);
+
+private:
+ void add_hamlet(boost::filesystem::path hamlet_file,
+ osmium::io::Writer &writer);
+
+ void process_hamlets(const OGRFeatureUniquePtr &feat,
+ osmium::memory::Buffer &node_buffer);
+};
+
+#endif // HAMELTCONVERTER_HPP
diff --git a/plugins/navteq/converter/PointLayerConverter.hpp b/plugins/navteq/converter/PointLayerConverter.hpp
new file mode 100644
index 0000000..5ca5697
--- /dev/null
+++ b/plugins/navteq/converter/PointLayerConverter.hpp
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the Morituri project.
+ * Morituri is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Morituri is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Morituri. If not, see .
+ */
+
+#ifndef POINTLAYERCONVERTER_HPP
+#define POINTLAYERCONVERTER_HPP
+
+#include "Converter.hpp"
+
+#include
+
+class PointLayerConverter : public Converter {
+
+public:
+ PointLayerConverter();
+ virtual ~PointLayerConverter();
+
+ virtual void convert(const std::vector &dirs,
+ osmium::io::Writer &writer);
+
+private:
+};
+
+#endif // POINTLAYERCONVERTER_HPP
\ No newline at end of file
diff --git a/plugins/navteq/converter/RestAreaConverter.cpp b/plugins/navteq/converter/RestAreaConverter.cpp
index 1165deb..d055ca9 100644
--- a/plugins/navteq/converter/RestAreaConverter.cpp
+++ b/plugins/navteq/converter/RestAreaConverter.cpp
@@ -16,6 +16,16 @@
#include "RestAreaConverter.hpp"
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../comm2osm_exceptions.hpp"
+#include "../../util.hpp"
+
void RestAreaConverter::convert(
const std::vector &dirs,
osmium::io::Writer &writer) {
@@ -78,7 +88,7 @@ void RestAreaConverter::process_rest_area(const OGRFeatureUniquePtr &feat,
// scope node_builder
// Add new node
osmium::builder::NodeBuilder node_builder(node_buffer);
- build_node(location, &node_builder);
+ build_node(location, node_builder);
osmium::builder::TagListBuilder tl_builder(node_builder);
std::string name = feat->GetFieldAsString(POI_NAME.data());
diff --git a/plugins/navteq/converter/RestAreaConverter.hpp b/plugins/navteq/converter/RestAreaConverter.hpp
index a79017a..6084e65 100644
--- a/plugins/navteq/converter/RestAreaConverter.hpp
+++ b/plugins/navteq/converter/RestAreaConverter.hpp
@@ -17,11 +17,11 @@
#ifndef RESTAREACONVERTER_HPP
#define RESTAREACONVERTER_HPP
-#include "Converter.hpp"
+#include "PointLayerConverter.hpp"
#include
-class RestAreaConverter : public Converter {
+class RestAreaConverter : public PointLayerConverter {
public:
RestAreaConverter();
diff --git a/plugins/navteq/navteq.hpp b/plugins/navteq/navteq.hpp
index d9c8fd1..0009012 100644
--- a/plugins/navteq/navteq.hpp
+++ b/plugins/navteq/navteq.hpp
@@ -1208,37 +1208,6 @@ void process_city(const OGRFeatureUniquePtr &feat, uint fac_type,
node_buffer.commit();
}
-/**
- * \brief adds hamlets to the node_buffer
- */
-void process_hamlets(const OGRFeatureUniquePtr &feat,
- osmium::memory::Buffer &node_buffer) {
-
- auto geom = feat->GetGeometryRef();
- auto geom_type = geom->getGeometryType();
-
- if (geom_type != wkbPoint) {
- throw(std::runtime_error(
- "Hamlet item with geometry=" + std::string(geom->getGeometryName()) +
- " is not yet supported."));
- }
-
- auto point = static_cast(geom);
- osmium::Location location(point->getX(), point->getY());
- {
- // scope node_builder
- // Add new node
- osmium::builder::NodeBuilder node_builder(node_buffer);
- build_node(location, &node_builder);
- osmium::builder::TagListBuilder tl_builder(node_builder);
-
- std::string name = feat->GetFieldAsString(POI_NAME);
- tl_builder.add_tag("name", to_camel_case_with_spaces(name));
- tl_builder.add_tag("place", "hamlet");
- }
- node_buffer.commit();
-}
-
/**
* \brief adds tags from administrative boundaries to mtd_area_map.
* adds tags from administrative boundaries to mtd_area_map
@@ -1369,44 +1338,6 @@ void add_city_nodes(const std::vector &dirs,
}
}
-void add_hamlet_nodes(const std::vector &dirs,
- osmium::io::Writer &writer) {
-
- for (auto dir : dirs) {
-
- // hamlets are optional
- if (!shp_file_exists(dir / HAMLET_SHP))
- continue;
-
- auto ds = open_shape_file(dir / HAMLET_SHP);
- auto layer = ds->GetLayer(0);
- if (layer == nullptr)
- throw(shp_empty_error(dir.string()));
-
- osmium::memory::Buffer node_buffer(buffer_size);
-
- int facTypeField = layer->FindFieldIndex(FAC_TYPE, true);
- int poiNmTypeField = layer->FindFieldIndex(POI_NMTYPE, true);
-
- for (auto &feat : *layer) {
- uint fac_type = feat->GetFieldAsInteger(facTypeField);
- if (fac_type != 9998) {
- BOOST_LOG_TRIVIAL(error)
- << "Skipping hamlet node because of wrong POI type";
- continue;
- }
-
- std::string name_type = feat->GetFieldAsString(poiNmTypeField);
- if (name_type != "B") {
- // Skip this entry as it's just a translated namePlc of former one
- continue;
- }
- process_hamlets(feat, node_buffer);
- }
- writer(std::move(node_buffer));
- }
-}
-
void init_g_cnd_mod_map(const boost::filesystem::path &dir) {
DBFHandle cnd_mod_handle = read_dbf_file(dir / CND_MOD_DBF);
for (int i = 0; i < DBFGetRecordCount(cnd_mod_handle); i++) {
diff --git a/plugins/navteq/navteq_mappings.hpp b/plugins/navteq/navteq_mappings.hpp
index 06ce232..344dac2 100644
--- a/plugins/navteq/navteq_mappings.hpp
+++ b/plugins/navteq/navteq_mappings.hpp
@@ -24,7 +24,7 @@ static const boost::filesystem::path ADMINBNDY_5_SHP = "Adminbndy5.shp";
static const boost::filesystem::path LAND_USE_A_SHP = "LandUseA.shp";
static const boost::filesystem::path LAND_USE_B_SHP = "LandUseB.shp";
static const boost::filesystem::path NAMED_PLC_SHP = "NamedPlc.shp";
-static const boost::filesystem::path HAMLET_SHP = "Hamlet.shp";
+
static const boost::filesystem::path POINT_ADDRESS_SHP = "PointAddress.shp";
static const boost::filesystem::path MTD_CNTRY_REF_DBF = "MtdCntryRef.dbf";
diff --git a/plugins/navteq/navteq_plugin.cpp b/plugins/navteq/navteq_plugin.cpp
index 7d0594a..7c955e0 100644
--- a/plugins/navteq/navteq_plugin.cpp
+++ b/plugins/navteq/navteq_plugin.cpp
@@ -17,6 +17,7 @@
#include
#include "converter/BuildingConverter.hpp"
+#include "converter/HamletConverter.hpp"
#include "converter/RailwayConverter.hpp"
#include "converter/RestAreaConverter.hpp"
#include "converter/WaterConverter.hpp"
@@ -36,6 +37,7 @@ navteq_plugin::navteq_plugin(const boost::filesystem::path &executable_path)
// setting executable_path in navteq2osm_tag_parser.hpp for reading ISO-file
g_executable_path = this->executable_path;
+ converter.emplace_back(new HamletConverter());
converter.emplace_back(new BuildingConverter());
converter.emplace_back(new RestAreaConverter());
converter.emplace_back(new RailwayConverter());
@@ -247,9 +249,6 @@ void navteq_plugin::execute() {
BOOST_LOG_TRIVIAL(info) << "Add city nodes";
add_city_nodes(dataDirs, writer);
- BOOST_LOG_TRIVIAL(info) << "Add hamlet nodes";
- add_hamlet_nodes(dataDirs, writer);
-
// run converters
for (auto &c : converter)
c->convert(dataDirs, writer);