Skip to content

Commit

Permalink
Calculate inset area on transformed original coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
nihalzp committed Nov 17, 2024
1 parent a3e19b9 commit e493c85
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/inset_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class InsetState
void store_original_geo_divs();
double target_area_at(const std::string &) const;
bool target_area_is_missing(const std::string &) const;
double total_inset_area() const;
double total_inset_area(bool = false) const;
double total_target_area() const;
Polygon transform_to_equal_area_projection_coor(Polygon edge_points);
std::array<Point, 3> transformed_triangle(
Expand Down
5 changes: 3 additions & 2 deletions src/inset_state/inset_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,10 +895,11 @@ double InsetState::target_area_at(const std::string &id) const
}
}

double InsetState::total_inset_area() const
double InsetState::total_inset_area(bool original_area) const
{
auto &geo_divs = original_area ? geo_divs_original_transformed_ : geo_divs_;
double total_inset_area = 0.0;
for (const auto &gd : geo_divs_) {
for (const auto &gd : geo_divs) {
total_inset_area += gd.area();
}
return total_inset_area;
Expand Down
2 changes: 1 addition & 1 deletion src/inset_state/rescale_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void InsetState::normalize_inset_area(
const double inset_area_prop =
initial_target_area() / total_cart_target_area;
const double scale_factor =
equal_area ? 1.0 : sqrt(inset_area_prop / total_inset_area());
equal_area ? 1.0 : sqrt(inset_area_prop / total_inset_area(normalize_original));

// Rescale and translate all GeoDiv coordinates
const Transformation translate(
Expand Down

0 comments on commit e493c85

Please sign in to comment.