From 2ff34d88b2738e96b614ddd24fef5c3963ad032f Mon Sep 17 00:00:00 2001 From: tegzed Date: Sun, 11 Sep 2011 18:01:37 +0000 Subject: [PATCH] fix:map/csv:fix quadtree splitting git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4777 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/map/csv/quadtree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/navit/navit/map/csv/quadtree.c b/navit/navit/map/csv/quadtree.c index 3d4911a..58096ed 100644 --- a/navit/navit/map/csv/quadtree.c +++ b/navit/navit/map/csv/quadtree.c @@ -349,8 +349,7 @@ quadtree_add(struct quadtree_node* this_, struct quadtree_item* item) { int i; double lon = this_->items[0].longitude, lat = this_->items[0].latitude; - this_->items[this_->node_num++] = *item; - if(QUADTREE_NODE_CAPACITY == this_->node_num) { + if(QUADTREE_NODE_CAPACITY-1 == this_->node_num) { //avoid infinite recursion when all elements has the same coordinate for(i=0;inode_num;++i) { if (lon != this_->items[i].longitude || lat != this_->items[i].latitude) { @@ -361,7 +360,10 @@ quadtree_add(struct quadtree_node* this_, struct quadtree_item* item) { if (bSame) { return; } + this_->items[this_->node_num++] = *item; quadtree_split(this_); + } else { + this_->items[this_->node_num++] = *item; } } else { -- 2.7.4