basic multipolygon rendering
authorRichard Fairhurst <richard@systemed.net>
Sat, 12 Jun 2010 18:37:49 +0000 (18:37 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sat, 12 Jun 2010 18:37:49 +0000 (18:37 +0000)
TODO.txt
net/systemeD/halcyon/WayBitmapFiller.as
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/connection/Entity.as
net/systemeD/halcyon/connection/Relation.as

index ca549ab..53fe9de 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -13,6 +13,7 @@ Potlatch 2: main outstanding issues
 
 * TagTransform (cf http://wiki.openstreetmap.org/wiki/Osmosis/TagTransform)
 * Import from OSM (is this worth sharing with the XML API stuff?)
+* Load GPX from API
 
 == Other core ==
 
@@ -31,6 +32,7 @@ Potlatch 2: main outstanding issues
 ** Doesn't always update selected tab when you select a new entity
 ** Doesn't update selected tab when you change the relations on an entity
 ** Direct click-to-edit of relation role should actually work
+** Double-clicking a relation to edit it comes up with the POIs!
 * Dynamic reloading of stylesheet/map_features, so that you don't need to reload the full page when editing them
 * If a select name is too long then, the select menu seems to give a horizontal scrollbar instead of the name of the item e.g. cuisine#Coffee Shop
 * If you have both inputSets names and buildingAddress, and name= key is filled in then the basic tab will get both, surely only name should be shown and building name should be ignored e.g. cafes. [Actually this was an issue of addr: being missing from one of them, however this may still be a problem for other overlapping inputSets]
@@ -46,6 +48,7 @@ Potlatch 2: main outstanding issues
 ** Potlatch 1-style "floaty warnings"
 ** Should remember which background imagery layer you had previously selected
 ** Dialog for adding custom imagery url
+* Ctrl-clicking two areas (one inside the other) should create a multipolygon
 * B keypress for background source tag
 * Bbox-sensitive menu for background imagery
 * Mouse wheel zooming
@@ -53,6 +56,7 @@ Potlatch 2: main outstanding issues
 * Quick-search on add-relations-to-way dialog (RelationSelectPanel)
 * Bug: when drawing way, escape ends drawing. Should revert to previous way.
 * i18n
+* Multiple selection
 
 == Miscellaneous data model ==
 
@@ -67,3 +71,4 @@ Potlatch 2: main outstanding issues
 * Complete MapCSS support
 * 'Light' version without vectorlayer support etc.
 * .gz support for OSMConnection
+* Multipolygon rendering for dashedLine, lineDecoration, and WayBitmapFiller
index 34cf8cf..6140d37 100644 (file)
@@ -26,7 +26,7 @@ package net.systemeD.halcyon {
                        var image:BitmapData = new BitmapData(loader.width, loader.height, false);
                        image.draw(loader);
                        graphics.beginBitmapFill(image);
-                       wayui.solidLine(graphics);
+                       wayui.solidLines(graphics,[]);
                        graphics.endFill();
                }
        }
index 0ef5f28..dec2487 100755 (executable)
@@ -172,6 +172,11 @@ package net.systemeD.halcyon {
                        // Iterate through each sublayer, drawing any styles on that layer
                        if (!sl) { sl=paint.ruleset.getStyles(this.way, tags); }
                        var drawn:Boolean;
+                       var multis:Array=way.findParentRelationsOfType('multipolygon','outer');
+                       var inners:Array=[];
+                       for each (var m:Relation in multis) {
+                               inners=inners.concat(m.findMembersByRole('inner'));
+                       }
                        for (var sublayer:int=10; sublayer>=0; sublayer--) {
                                if (sl.shapeStyles[sublayer]) {
                                        var s:ShapeStyle=sl.shapeStyles[sublayer];
@@ -187,17 +192,17 @@ package net.systemeD.halcyon {
                                                if (s.dashes && s.dashes.length>0) {
                                                        var segments:Array=dashedLine(stroke.graphics,s.dashes); 
                                                        if (s.line_style) { lineDecoration(stroke.graphics,s,segments); }
-                                               } else { solidLine(stroke.graphics); }
+                                               } else { solidLines(stroke.graphics,inners); }
                                                drawn=true;
                                        }
 
                                        // Fill
-                                       if (s.fill_color || s.fill_image) {
+                                       if ((s.fill_color || s.fill_image) && way.findParentRelationsOfType('multipolygon','inner').length==0) {
                                                fill=new Shape(); addToLayer(fill,FILLSPRITE);
                                                fill.graphics.moveTo(x0,y0);
                                                if (s.fill_image) { new WayBitmapFiller(this,fill.graphics,s); }
                                                                         else { s.applyFill(fill.graphics); }
-                                               solidLine(fill.graphics);
+                                               solidLines(fill.graphics,inners);
                                                fill.graphics.endFill();
                                                drawn=true;
                                        }
@@ -208,7 +213,7 @@ package net.systemeD.halcyon {
                                                casing.graphics.moveTo(x0,y0);
                                                s.applyCasingStyle(casing.graphics);
                                                if (s.casing_dashes && s.casing_dashes.length>0) { dashedLine(casing.graphics,s.casing_dashes); }
-                                                                                                                                       else { solidLine(casing.graphics); }
+                                                                                                                                       else { solidLines(casing.graphics,inners); }
                                                drawn=true;
                                        }
                                }
@@ -264,7 +269,7 @@ package net.systemeD.halcyon {
             // create a generic "way" hitzone sprite
             hitzone = new Sprite();
             hitzone.graphics.lineStyle(4, 0x000000, 1, false, "normal", CapsStyle.ROUND, JointStyle.ROUND);
-            solidLine(hitzone.graphics);
+            solidLines(hitzone.graphics,[]);
             addToLayer(hitzone, CLICKSPRITE);
             hitzone.visible = false;
                        setListenSprite(hitzone);
@@ -277,11 +282,16 @@ package net.systemeD.halcyon {
 
                // Draw solid polyline
                
-               public function solidLine(g:Graphics):void {
-            var node:Node = way.getNode(0);
+               public function solidLines(g:Graphics,inners:Array):void {
+                       solidLine(g,this.way);
+                       for each (var w:Way in inners) { solidLine(g,w); }
+               }
+
+               private function solidLine(g:Graphics,w:Way):void {
+            var node:Node = w.getNode(0);
                        g.moveTo(paint.map.lon2coord(node.lon), paint.map.latp2coord(node.latp));
                        for (var i:uint = 1; i < way.length; i++) {
-                node = way.getNode(i);
+                node = w.getNode(i);
                                g.lineTo(paint.map.lon2coord(node.lon), paint.map.latp2coord(node.latp));
                        }
                }
index 949efc9..3d6a7ac 100644 (file)
@@ -52,6 +52,11 @@ package net.systemeD.halcyon.connection {
         public function getTag(key:String):String {
             return tags[key];
         }
+
+               public function tagIs(key:String,value:String):Boolean {
+                       if (!tags[key]) { return false; }
+                       return tags[key]==value;
+               }
         
         public function setTag(key:String, value:String, performAction:Function):void {
             performAction(new SetTagAction(this, key, value));
@@ -183,6 +188,20 @@ package net.systemeD.halcyon.connection {
                        return a;
                }
                
+               public function findParentRelationsOfType(type:String, role:String=""):Array {
+                       var a:Array=[];
+                       for (var o:Object in parents) {
+                               if (o is Relation && Relation(o).tagIs('type',type)) { 
+                                       for (var i:uint=0; i<o.length; i++) {
+                                               if (o.getMember(i).entity==this && o.getMember(i).role==role) {
+                                                       a.push(o);
+                                               }
+                                       }
+                               }
+                       }
+                       return a;
+               }
+               
                public function get parentObjects():Array {
                        var a:Array=[];
                        for (var o:Object in parents) { a.push(o); }
index 6049c45..5cab404 100644 (file)
@@ -60,6 +60,14 @@ package net.systemeD.halcyon.connection {
                        markDirty();
         }
 
+               public function findMembersByRole(role:String):Array {
+                       var a:Array=[];
+            for (var index:uint = 0; index < members.length; index++) {
+                if (members[index].role==role) { a.push(members[index].entity); }
+            }
+                       return a;
+               }
+
         public function insertMember(index:uint, member:RelationMember, performAction:Function):void {
             performAction(new AddMemberToRelationAction(this, index, member, members));
         }