Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issues with Shifting of Insets to Position and String to Decimal Converter #218

Open
wants to merge 46 commits into
base: main
Choose a base branch
from

Conversation

nihalzp
Copy link
Collaborator

@nihalzp nihalzp commented Nov 17, 2024

Closes #219
Closes #214
Closes #204
Closes #180

@nihalzp nihalzp added bug Something isn't working important This is higher priority than average ready-to-review priority: high labels Nov 17, 2024
@nihalzp nihalzp self-assigned this Nov 17, 2024
@nihalzp nihalzp requested a review from adisidev November 18, 2024 02:18
Copy link
Collaborator

@adisidev adisidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are still a few changes needed. Let me try and make those, but it would be good for you @nihalzp to still read my code comments so we can keep our programming standards the same and avoid future review comments.

include/cartogram_info.hpp Outdated Show resolved Hide resolved
include/inset_state.hpp Outdated Show resolved Hide resolved
std::cerr << "Hole: " << h << std::endl;
std::cerr << "Polygon: " << ext_ring << std::endl;
std::cerr << "GeoDiv: " << gd.id() << std::endl;
std::cerr << "ERROR: Hole detected outside polygon!";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change this to follow the style of the rest of our std::cerr statements.

That is:

std:cerr << "Error: Hole detected outside polygon! "
  << "ABC"
  << "XYZ"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I have added an issue for this.

src/inset_state/fill_with_density_rays.cpp Show resolved Hide resolved
src/inset_state/inset_state.cpp Show resolved Hide resolved
{
auto &geo_divs = original_area ? geo_divs_original_transformed_ : geo_divs_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to just store this in a variable? Or do you mean the current area of the geo_divs_transformed, in which case probably we would want to change the name somehow.
Maybe "original_unit"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing the area in a variable would require us to update that variable each time we update the geo_divs, which would require extra book keeping in many places, and this will increase the possibilities of bugs.

<< std::endl;
std::cerr
<< "ERROR: Input GeoJSON is not a longitude-latitude map. Therefore, "
"it is not possible to produce an equal-area map."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this statement lighter. Or actually even remove it? Did you put it so that we can remember where this error came from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we should not remove it; this way we know that the --output_equal_area flag did not work for the given map. It is true that the statement contains redundant information because the first statement technically implies the second statement given the context. However, for a new user, it might not be obvious; and we do plan to display error messages to the users on the website.

@@ -410,11 +412,18 @@ int main(const int argc, const char *argv[])

// Rescale insets in correct proportion to each other
inset_state.normalize_inset_area(
cart_info.cart_initial_total_target_area());
cart_info.cart_initial_total_target_area(),
false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should name the bools? @mgastner's opinion on style may be helpful here.

The alternative is we keep it like this and rely on IDE hints.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Let's discuss it more.

src/main.cpp Show resolved Hide resolved
@@ -15,7 +15,7 @@ void FTReal2d::set_array_size(const unsigned int i, const unsigned int j)
void FTReal2d::allocate(const unsigned int lx, const unsigned int ly)
{
if (lx * ly <= 0) {
std::cerr << "Invalid array dimensions in FTReal2dArray::allocate_ft()"
std::cerr << "ERROR: Invalid array dimensions in FTReal2dArray::allocate_ft()"
<< std::endl;
_Exit(98915);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a side note, I wonder who is naming these exit codes.

@adisidev
Copy link
Collaborator

adisidev commented Nov 29, 2024

We should also resolve

/__w/cartogram-cpp/cartogram-cpp/src/cartogram_info/read_geojson.cpp:214:24: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  214 |               return x < 0 || x > 127;
      |                      ~~^~~
[ 20%] Building CXX object CMakeFiles/cartogram.dir/src/cartogram_i

Here is the entire snippet. I am unsure whether it should be x should remain unsigned and the condition should just be x > 127, or we should make x signed. @nihalzp I don't think we should convert it to signed right away without first understanding how chars are read and processed.

        id_header.erase(
          std::remove_if(
            id_header.begin(),
            id_header.end(),
            [](unsigned char x) {
              return x < 0 || x > 127;
            }),
          id_header.end());
        id_header_ = id_header;        

EDIT: I fixed this in f0536c9

@nihalzp nihalzp requested a review from adisidev December 2, 2024 08:01
@nihalzp nihalzp changed the title Fix Issues with Shifting of Insets to Position Fix Issues with Shifting of Insets to Position and String to Decimal Converter Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working important This is higher priority than average priority: high ready-to-review
Projects
None yet
2 participants