mirror of https://github.com/CGAL/cgal
added: 2 flags when recording the faces and code to check the smallest country
This commit is contained in:
parent
93811dfe4a
commit
a4c56c9f3d
|
|
@ -1121,6 +1121,8 @@ void Aos::save_arr(Kml::Placemarks& placemarks, const std::string& file_name)
|
|||
json js_face;
|
||||
auto face_name = face_name_map[fh];
|
||||
js_face["name"] = face_name;
|
||||
js_face["is_unbounded"] = false;
|
||||
js_face["is_valid"] = true;
|
||||
|
||||
// at this point we are sure that we have at least 1 outer-ccb
|
||||
auto& js_outer_ccbs = js_face["outer_ccbs"] = json::array();
|
||||
|
|
|
|||
|
|
@ -408,6 +408,16 @@ Kml::Nodes Kml::Placemark::get_all_nodes() const
|
|||
|
||||
return all_nodes;
|
||||
}
|
||||
int Kml::Placemark::get_all_nodes_count() const
|
||||
{
|
||||
int num_nodes = 0;
|
||||
for (const auto& polygon : polygons)
|
||||
{
|
||||
auto polygon_nodes = polygon.get_all_nodes();
|
||||
num_nodes += polygon_nodes.size();
|
||||
}
|
||||
return num_nodes;
|
||||
}
|
||||
|
||||
Kml::Arcs Kml::LinearRing::get_arcs() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public:
|
|||
|
||||
// collects all nodes from all polygons
|
||||
Nodes get_all_nodes() const;
|
||||
int get_all_nodes_count() const;
|
||||
|
||||
Arcs get_all_arcs() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -178,8 +178,29 @@ void Main_widget::initializeGL()
|
|||
|
||||
//const auto file_name = data_path + "world_countries.kml";
|
||||
//const auto file_name = data_path + "ne_110m_admin_0_countries.kml";
|
||||
const auto file_name = data_path + "ne_110m_admin_0_countries_africa_1.kml";
|
||||
//const auto file_name = data_path + "ne_110m_admin_0_countries_africa_1.kml";
|
||||
const auto file_name = data_path + "ne_110m_admin_0_countries_equatorial_guinea.kml";
|
||||
m_countries = Kml::read(file_name);
|
||||
|
||||
// find the country with the least number of nodes
|
||||
if(0)
|
||||
{
|
||||
std::string smallest;
|
||||
int min_num_nodes = std::numeric_limits<int>::max();
|
||||
for (auto& p : m_countries)
|
||||
{
|
||||
int num_nodes = p.get_all_nodes_count();
|
||||
if (min_num_nodes > num_nodes)
|
||||
{
|
||||
min_num_nodes = num_nodes;
|
||||
smallest = p.name;
|
||||
}
|
||||
qDebug() << p.name << " = " << p.get_all_nodes_count();
|
||||
}
|
||||
qDebug() << "smallest = " << smallest;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
auto dup_nodes = Kml::get_duplicates(m_countries);
|
||||
//auto all_nodes = Kml::generate_ids(m_countries);
|
||||
qDebug() << "*** KML number of polygons = " <<
|
||||
|
|
@ -193,7 +214,8 @@ void Main_widget::initializeGL()
|
|||
// SAVING & LOADING ARR
|
||||
if(1)
|
||||
{
|
||||
Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries_africa_1.json");
|
||||
//Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries_africa_1.json");
|
||||
Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries_equatorial_guinea.json");
|
||||
qDebug() << "done saving!";
|
||||
exit(0);
|
||||
//Aos::save_arr(m_countries, "C:/work/gsoc2023/ne_110m_admin_0_countries.json");
|
||||
|
|
|
|||
Loading…
Reference in New Issue