Enable zooming out beyond data limit
authorRichard Fairhurst <richard@systemeD.net>
Sun, 26 Feb 2017 13:00:20 +0000 (13:00 +0000)
committerRichard Fairhurst <richard@systemeD.net>
Sun, 26 Feb 2017 13:00:20 +0000 (13:00 +0000)
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/MapPaint.as
net/systemeD/halcyon/TileSet.as
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/styleparser/RuleSet.as

index a3a613c..db15bf4 100644 (file)
@@ -24,7 +24,8 @@ package net.systemeD.halcyon {
                public const MASTERSCALE:Number=5825.4222222222; 
                                                                                                
                /** don't zoom out past this */
-               public const MINSCALE:uint=13; 
+               public const MINSCALE_TILES:uint=3;
+               public const MINSCALE_DATA:uint=14;
                /** don't zoom in past this */
                public const MAXSCALE:uint=23; 
 
@@ -225,6 +226,7 @@ package net.systemeD.halcyon {
         * The bounding box for the download is taken from the current map edges.
         */
                public function download():void {
+                       if (scale<MINSCALE_DATA) return;        // could potentially be different per layer
                        for (var i:uint=0; i<paintContainer.numChildren; i++)
                                if(getLayerAt(i).visible == true) {
                     getLayerAt(i).connection.loadBbox(edge_l,edge_r,edge_t,edge_b);
@@ -324,7 +326,7 @@ package net.systemeD.halcyon {
                }
 
                public function zoomOut():void {
-                       if (scale!=MINSCALE) changeScale(scale-1);
+                       if (scale!=MINSCALE_TILES) changeScale(scale-1);
                }
 
                public function changeScale(newscale:uint):void {
index 8016686..cc7d070 100644 (file)
@@ -169,7 +169,8 @@ package net.systemeD.halcyon {
         */
                public function updateEntityUIs(redraw:Boolean, remove:Boolean):void {
                        var way:Way, poi:Node, marker:Marker;
-                       var o:Object = connection.getObjectsByBbox(map.edge_l,map.edge_r,map.edge_t,map.edge_b);
+                       var o:Object = (map.scale < ruleset.minscale) ? connection.getEmptyObjectList() :
+                               connection.getObjectsByBbox(map.edge_l,map.edge_r,map.edge_t,map.edge_b);
 
                        for each (way in o.waysInside) {
                                if (!wayuis[way.id]) { createWayUI(way); }
@@ -371,7 +372,7 @@ package net.systemeD.halcyon {
                /** Switch to new MapCSS. */
                public function setStyle(url:String):void {
             style = url;
-                       ruleset=new RuleSet(map.MINSCALE,map.MAXSCALE,redraw,redrawPOIs);
+                       ruleset=new RuleSet(map.MINSCALE_DATA,map.MAXSCALE,redraw,redrawPOIs);
                        ruleset.loadFromCSS(url);
         }
 
index db541f5..5b84470 100644 (file)
@@ -75,7 +75,7 @@ package net.systemeD.halcyon {
                }
 
                private function createSprites():void {
-                       for (var i:uint=_map.MINSCALE; i<=_map.MAXSCALE; i++) {
+                       for (var i:uint=_map.MINSCALE_TILES; i<=_map.MAXSCALE; i++) {
                                this.addChild(new Sprite());
                        }
                }
@@ -108,8 +108,8 @@ package net.systemeD.halcyon {
 
                /** Set zoom scale (no update triggerd). */
                public function changeScale(scale:uint):void {
-                       for (var i:uint=_map.MINSCALE; i<=_map.MAXSCALE; i++) {
-                               this.getChildAt(i-_map.MINSCALE).visible=(scale==i);
+                       for (var i:uint=_map.MINSCALE_TILES; i<=_map.MAXSCALE; i++) {
+                               this.getChildAt(i-_map.MINSCALE_TILES).visible=(scale==i);
                        }
                        x=_map.lon2coord(_map.centre_lon+offset_lon)-_map.lon2coord(_map.centre_lon);
                        y=_map.lat2coord(_map.centre_lat+offset_lat)-_map.lat2coord(_map.centre_lat);
@@ -133,7 +133,7 @@ package net.systemeD.halcyon {
                                                loader.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, function(e:HTTPStatusEvent):void { tileLoadStatus(e,_map.scale,tx,ty); }, false, 0, true);
                                                loader.load(new URLRequest(tileURL(tx,ty,_map.scale)), 
                                                            new LoaderContext(true));
-                                               Sprite(this.getChildAt(_map.scale-_map.MINSCALE)).addChild(loader);
+                                               Sprite(this.getChildAt(_map.scale-_map.MINSCALE_TILES)).addChild(loader);
                                                loader.x=_map.lon2coord(tile2lon(tx));
                                                loader.y=_map.lat2coord(tile2lat(ty));
                                                if (sharpening) { loader.filters=[sharpenFilter]; }
index 2680353..01b9425 100644 (file)
@@ -390,6 +390,15 @@ package net.systemeD.halcyon.connection {
                        return o;
                }
 
+               public function getEmptyObjectList():Object {
+                       var o:Object = { poisInside: [], poisOutside: [], waysInside: [], waysOutside: [],
+                              markersInside: [], markersOutside: [] };
+                       for each (var way:Way in ways) o.waysOutside.push(way);
+                       for each (var poi:Node in pois) o.poisOutside.push(poi);
+            for each (var marker:Marker in markers) o.markersOutside.push(marker);
+                       return o;
+               }
+
                public function purgeOutside(left:Number, right:Number, top:Number, bottom:Number):void {
                        for each (var way:Way in ways) {
                                if (!way.within(left,right,top,bottom) && !way.isDirty && !way.locked && !way.hasLockedNodes()) {
index 09230d1..b32ecd3 100644 (file)
@@ -24,8 +24,8 @@ package net.systemeD.halcyon.styleparser {
                private var iconsToLoad:uint=0;                         // number of icons left to load (fire iconCallback when ==0)
                private var evalsToLoad:uint=0;                         // number of evals left to load (fire redrawCallback when ==0)
 
-               private var minscale:uint;
-               private var maxscale:uint;
+               public var minscale:uint;
+               public var maxscale:uint;
                public var choosers:Array;
                public var evals:Array;