Permalink
Browse files

Quadtree fixup

  • Loading branch information...
systemed committed Oct 17, 2012
1 parent 710f239 commit 6939ad9bc6768a707bd8acbba04183aef3c8d553
Showing with 21 additions and 5 deletions.
  1. +14 −4 net/systemeD/halcyon/connection/Connection.as
  2. +7 −1 net/systemeD/quadtree/QuadTree.as
@@ -251,10 +251,10 @@ package net.systemeD.halcyon.connection {
nodeMap.remove({x:node.lon, y:node.lat, key:node});
}
public function addToWayMap(way:Way):void {
- nodeMap.insert({x:way.left, y:way.bottom, width:way.right-way.left, height:way.top-way.bottom, key:way});
+ wayMap.insert({x:way.left, y:way.bottom, width:way.right-way.left, height:way.top-way.bottom, key:way});
}
public function removeFromWayMap(way:Way):void {
- nodeMap.remove({x:way.left, y:way.bottom, width:way.right-way.left, height:way.top-way.bottom, key:way});
+ wayMap.remove({x:way.left, y:way.bottom, width:way.right-way.left, height:way.top-way.bottom, key:way});
}
// Remove data from Connection
@@ -401,9 +401,19 @@ package net.systemeD.halcyon.connection {
public function getObjectsByBbox(left:Number, right:Number, top:Number, bottom:Number):Object {
var o:Object = { poisInside: [], poisOutside: [], waysInside: [], waysOutside: [],
markersInside: [], markersOutside: [] };
+// var r:Array=wayMap.retrieve({ x:left, y:bottom, width:right-left, height:top-bottom });
+// trace ("**"+r[0]);
+// for each (var way:Way in ways) {
+// if (way.within(left,right,top,bottom)) { o.waysInside.push(way); }
+// else { o.waysOutside.push(way); }
+ var r:Array=wayMap.retrieve({ x:left, y:bottom, width:right-left, height:top-bottom });
+ trace(r);
+ for each (var obj:Object in r) {
+ var t:String=''; for (var k:String in obj) { t+=k+"="+obj[k]+";"; } trace(t);
+ if (obj.key) o.waysInside.push(obj.key);
+ }
for each (var way:Way in ways) {
- if (way.within(left,right,top,bottom)) { o.waysInside.push(way); }
- else { o.waysOutside.push(way); }
+ if (o.waysInside.indexOf(way)==-1) o.waysOutside.push(way);
}
for each (var poi:Node in pois) {
if (poi.within(left,right,top,bottom)) { o.poisInside.push(poi); }
@@ -21,7 +21,13 @@ package net.systemeD.quadtree {
}
public function insert(item:Object):void {
- root.insert(item);
+ if (item is Array) {
+ for (var i:Number=0; i<(item as Array).length; i++) {
+ root.insert(item[i]);
+ }
+ } else {
+ root.insert(item);
+ }
}
public function remove(item:Object):Boolean {

0 comments on commit 6939ad9

Please sign in to comment.