From: Richard Fairhurst Date: Sat, 12 Jun 2010 18:37:49 +0000 (+0000) Subject: basic multipolygon rendering X-Git-Tag: 0.5~407 X-Git-Url: https://git.openstreetmap.org/potlatch2.git/commitdiff_plain/b3578832a3d02f56e046537fbc7cb2690b4ff219 basic multipolygon rendering --- diff --git a/TODO.txt b/TODO.txt index ca549aba..53fe9ded 100644 --- 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 diff --git a/net/systemeD/halcyon/WayBitmapFiller.as b/net/systemeD/halcyon/WayBitmapFiller.as index 34cf8cf8..6140d374 100644 --- a/net/systemeD/halcyon/WayBitmapFiller.as +++ b/net/systemeD/halcyon/WayBitmapFiller.as @@ -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(); } } diff --git a/net/systemeD/halcyon/WayUI.as b/net/systemeD/halcyon/WayUI.as index 0ef5f281..dec24870 100755 --- a/net/systemeD/halcyon/WayUI.as +++ b/net/systemeD/halcyon/WayUI.as @@ -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)); } } diff --git a/net/systemeD/halcyon/connection/Entity.as b/net/systemeD/halcyon/connection/Entity.as index 949efc9e..3d6a7ac7 100644 --- a/net/systemeD/halcyon/connection/Entity.as +++ b/net/systemeD/halcyon/connection/Entity.as @@ -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