aboutsummaryrefslogtreecommitdiff
path: root/web/lib
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-18 21:34:21 +0100
committerJochen Topf <jochen@topf.org>2013-01-18 21:34:21 +0100
commit34bdd4c02b55047e2101219e58ef5131220ecb16 (patch)
treeeb9e3fc4f58aa931d6861591ecde78232ce2da07 /web/lib
parentd03d0b821aac5ae4f75c462aadd5e5709abdbdd0 (diff)
downloadtaginfo-34bdd4c02b55047e2101219e58ef5131220ecb16.tar
taginfo-34bdd4c02b55047e2101219e58ef5131220ecb16.tar.gz
Fix for #14 (NaN on API call)
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/api/v4/relation.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/web/lib/api/v4/relation.rb b/web/lib/api/v4/relation.rb
index 791dfd0..cd4aab5 100644
--- a/web/lib/api/v4/relation.rb
+++ b/web/lib/api/v4/relation.rb
@@ -59,11 +59,11 @@ class Taginfo < Sinatra::Base
:count_all_members => row['count_all'].to_i,
:count_all_members_fraction => (row['count_all'].to_f / relation_type_info['members_all'].to_i).round_to(4),
:count_node_members => row['count_nodes'].to_i,
- :count_node_members_fraction => (row['count_nodes'].to_f / relation_type_info['members_nodes'].to_i).round_to(4),
+ :count_node_members_fraction => relation_type_info['members_nodes'].to_i == 0 ? 0 : (row['count_nodes'].to_f / relation_type_info['members_nodes'].to_i).round_to(4),
:count_way_members => row['count_ways'].to_i,
- :count_way_members_fraction => (row['count_ways'].to_f / relation_type_info['members_ways'].to_i).round_to(4),
+ :count_way_members_fraction => relation_type_info['members_ways'].to_i == 0 ? 0 : (row['count_ways'].to_f / relation_type_info['members_ways'].to_i).round_to(4),
:count_relation_members => row['count_relations'].to_i,
- :count_relation_members_fraction => (row['count_relations'].to_f / relation_type_info['members_relations'].to_i).round_to(4),
+ :count_relation_members_fraction => relation_type_info['members_relations'].to_i == 0 ? 0 : (row['count_relations'].to_f / relation_type_info['members_relations'].to_i).round_to(4),
} }
}.to_json
end