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

Prevent division by zero #9

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

caotrido
Copy link

@caotrido caotrido commented Jul 7, 2016

Made a change to prevent a division by zero when there is only one value in the datas or one color.

@danieldabate
Copy link

Great change, thank you! It would be awesome to see it merged on FSInteractiveMap.

@@ -45,6 +45,47 @@ - (void)setDefaultParameters

#pragma mark - SVG map loading

- (void)loadMap:(NSString*)mapName forSize:(CGSize)size withColors:(NSDictionary*)colorsDict {
Copy link
Owner

Choose a reason for hiding this comment

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

There is a log of duplication in that method from - (void)loadMap:(NSString*)mapName withColors:(NSDictionary*)colorsDict. Can you try to factor it?

@xiaomage1478
Copy link

Hello, i need to show the name of the province on the map in China, what do i need to do?

@danielebogo
Copy link

@ArthurGuibert can this PR being merged? Or at least have another PR with those lines?

float s = ([value floatValue] - min) / ( ((max-min) == 0 ? 1 : (max-min)) );
float segmentLength = 1.0 / ( (([colors count] - 1) == 0 ? 1 : ([colors count] - 1)) );

Happy to do it and help. Without this fix it crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants