Changeset 1629 in josm


Ignore:
Timestamp:
2009-05-30T17:24:29+02:00 (11 years ago)
Author:
stoecker
Message:

close #2426 - now mappaint handles area types which require closed ways (e.g. cliff) correctly

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r1553 r1629  
    223223        else if (wayStyle instanceof AreaElemStyle)
    224224        {
     225            AreaElemStyle areaStyle = (AreaElemStyle) wayStyle;
    225226            /* way with area style */
    226227            //if(!profilerOmitDraw)
    227228            //{
    228             if (fillAreas > dist)
     229            if (fillAreas > dist && (!areaStyle.closed || w.isClosed()))
    229230            {
    230231            //    profilerVisibleAreas++;
    231                 drawArea(w, w.selected ? selectedColor : ((AreaElemStyle)wayStyle).color);
     232                drawArea(w, w.selected ? selectedColor : areaStyle.color);
    232233                if(!w.isClosed())
    233234                    w.putError(tr("Area style way is not closed."), true);
    234235            }
    235             drawWay(w, ((AreaElemStyle)wayStyle).line, ((AreaElemStyle)wayStyle).color, w.selected);
     236            drawWay(w, areaStyle.line, areaStyle.color, w.selected);
    236237            //}
    237238        }
     
    456457            if(style instanceof AreaElemStyle)
    457458            {
    458                 drawWay((Way)osm, ((AreaElemStyle)style).line, selectedColor, true);
    459                 if(area)
    460                     drawArea((Way)osm, areaselected ? selectedColor
    461                     : ((AreaElemStyle)style).color);
     459                Way way = (Way)osm;
     460                AreaElemStyle areaStyle = (AreaElemStyle)style;
     461                drawWay(way, areaStyle.line, selectedColor, true);
     462                if(area && (!areaStyle.closed || way.isClosed()))
     463                    drawArea(way, areaselected ? selectedColor : areaStyle.color);
    462464            }
    463465            else
     
    907909                        inner.add(p);
    908910                    }
     911                    public boolean isClosed()
     912                    {
     913                        return (poly.npoints >= 3
     914                        && poly.xpoints[0] == poly.xpoints[poly.npoints-1]
     915                        && poly.ypoints[0] == poly.ypoints[poly.npoints-1]);
     916                    }
    909917                    public Polygon get()
    910918                    {
     
    967975                    o.addInner(polygon);
    968976                }
     977                AreaElemStyle areaStyle = (AreaElemStyle)wayStyle;
    969978                for (PolyData pd : poly)
    970979                {
    971                     if(isPolygonVisible(pd.get()))
    972                     {
    973                         drawAreaPolygon(pd.get(), (pd.way.selected || r.selected) ? selectedColor
    974                         : ((AreaElemStyle)wayStyle).color);
     980                    Polygon p = pd.get();
     981                    if(isPolygonVisible(p) && (!areaStyle.closed || pd.isClosed()))
     982                    {
     983                        drawAreaPolygon(p, (pd.way.selected || r.selected) ? selectedColor
     984                        : areaStyle.color);
    975985                        visible = true;
    976986                    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java

    r1204 r1629  
    55{
    66    public Color color;
     7    public boolean closed;
    78    public LineElemStyle line = null;
    89
    910    public AreaElemStyle (AreaElemStyle a, long maxScale, long minScale) {
    1011        this.color = a.color;
     12        this.closed = a.closed;
    1113        this.priority = a.priority;
    1214        this.maxScale = maxScale;
     
    1719    {
    1820        this.color = a.color;
     21        this.closed = a.closed;
    1922        this.priority = a.priority;
    2023        this.maxScale = a.maxScale;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java

    r1583 r1629  
    7373        System.out.println(styleName + " (" + rule.key + "=" + rule.value + "): " + message);
    7474    }
    75    
     75
    7676    private void startElementLine(String qName, Attributes atts, LineElemStyle line) {
    7777        for (int count=0; count<atts.getLength(); count++)
     
    110110                    if(dashed) {
    111111                        line.dashed = 9;
    112                     }               
     112                    }
    113113                }
    114114            } else if (atts.getQName(count).equals("dashedcolour"))
     
    194194                    if (atts.getQName(count).equals("colour"))
    195195                        rule.area.color=convertColor(atts.getValue(count));
     196                    else if (atts.getQName(count).equals("closed"))
     197                        rule.area.closed=Boolean.parseBoolean(atts.getValue(count));
    196198                    else if(atts.getQName(count).equals("priority"))
    197199                        rule.area.priority = Integer.parseInt(atts.getValue(count));
  • trunk/styles/standard/elemstyles.xml

    r1556 r1629  
    2626        - colour
    2727        - priority
     28        - closed (true or false - when true the area style is ignored for unclosed ways)
    28296. icon attributes
    2930        - icon path to icon, relative to the icon path (default: subdirectory icons in
    3031          directory where this file is)
    3132        - priority
     33        - annonate (true or false)
    32347. scale_min / scale_max
    3335        - zoom scale for display
     
    353355                <condition k="barrier" v="bollard"/>
    354356                <icon annotate="true" src="vehicle/restriction/bollard.png"/>
    355         <line width="3" colour="barrier#F0F050"/>
     357                <line width="3" colour="barrier#F0F050" closed="true"/>
    356358                <scale_min>1</scale_min>
    357359                <scale_max>50000</scale_max>
     
    366368                <condition k="barrier" v="hedge"/>
    367369                <icon annotate="true" src="misc/deprecated.png"/>
    368         <line width="3" colour="barrier#F0F050"/>
    369         <area colour="barrier#F0F050"/>
     370                <line width="3" colour="barrier#F0F050"/>
     371                <area colour="barrier#F0F050" closed="true"/>
    370372                <scale_min>1</scale_min>
    371373                <scale_max>50000</scale_max>
     
    380382                <condition k="barrier" v="fence"/>
    381383                <icon annotate="true" src="misc/deprecated.png"/>
    382         <line width="3" colour="barrier#F0F050"/>
    383         <area colour="barrier#F0F050"/>
     384                <line width="3" colour="barrier#F0F050"/>
     385                <area colour="barrier#F0F050" closed="true"/>
    384386                <scale_min>1</scale_min>
    385387                <scale_max>50000</scale_max>
     
    400402                <condition k="barrier" v="wall"/>
    401403                <icon annotate="true" src="misc/deprecated.png"/>
    402         <line width="3" colour="barrier#F0F050"/>
    403         <area colour="barrier#F0F050"/>
     404                <line width="3" colour="barrier#F0F050"/>
     405                <area colour="barrier#F0F050" closed="true"/>
    404406                <scale_min>1</scale_min>
    405407                <scale_max>50000</scale_max>
     
    408410                <condition k="barrier" v="toll_booth"/>
    409411                <icon annotate="true" src="vehicle/toll_booth.png"/>
    410         <area colour="barrier#F0F050"/>
     412                <area colour="barrier#F0F050" closed="true"/>
    411413                <scale_min>1</scale_min>
    412414                <scale_max>50000</scale_max>
     
    421423                <condition k="barrier" v="city_wall"/>
    422424                <icon annotate="true" src="misc/deprecated.png"/>
    423         <line width="3" colour="barrier#F0F050"/>
    424         <area colour="barrier#F0F050"/>
     425                <line width="3" colour="barrier#F0F050"/>
     426                <area colour="barrier#F0F050" closed="true"/>
    425427                <scale_min>1</scale_min>
    426428                <scale_max>50000</scale_max>
     
    435437                <condition k="barrier" v="retaining_wall"/>
    436438                <icon annotate="true" src="misc/deprecated.png"/>
    437         <line width="3" colour="barrier#F0F050"/>
    438         <area colour="barrier#F0F050"/>
     439                <line width="3" colour="barrier#F0F050"/>
     440                <area colour="barrier#F0F050" closed="true"/>
    439441                <scale_min>1</scale_min>
    440442                <scale_max>50000</scale_max>
     
    449451                <condition k="barrier" v="block"/>
    450452                <icon annotate="true" src="misc/no_icon.png"/>
    451         <line width="3" colour="barrier#F0F050"/>
    452         <area colour="barrier#F0F050"/>
     453                <line width="3" colour="barrier#F0F050"/>
     454                <area colour="barrier#F0F050" closed="true"/>
    453455                <scale_min>1</scale_min>
    454456                <scale_max>50000</scale_max>
     
    668670                <condition k="highway" v="pedestrian"/>
    669671                <line width="3" realwidth="5" colour="foot#00ff00"/>
    670                 <!-- seems to be common to use area=yes for areas here -->
    671                 <!-- some people seem to have problems that polylines displayed as areas, so comment this out -->
    672                 <!--<area colour="foot#00ff00"/>-->
     672                <area colour="foot#00ff00" closed="true"/>
    673673                <icon annotate="true" src="misc/deprecated.png"/>
    674674                <scale_min>1</scale_min>
     
    849849        <rule>
    850850                <condition k="junction" v="roundabout"/>
    851                 <area colour="roundabout#eeeeee"/>
     851                <area colour="roundabout#eeeeee" closed="true"/>
    852852                <!-- tagging a node makes no real sense, a roundabout should be tagged with several nodes, or a highway=mini_roundabout should probably be used -->
    853853                <icon annotate="true" src="misc/deprecated.png"/>
     
    12181218                <icon annotate="true" src="misc/deprecated.png"/>
    12191219                <line width="2" colour="rail#404040"/>
    1220                 <area colour="rail#404040"/>
     1220                <area colour="rail#404040" closed="true"/>
    12211221                <scale_min>1</scale_min>
    12221222                <scale_max>50000</scale_max>
     
    15271527        <rule>
    15281528                <condition k="man_made" v="pier"/>
    1529                 <!-- seems to be common to use area=yes for areas here -->
    1530                 <!-- some people seem to have problems that polylines displayed as areas, so comment this out -->
    1531                 <!--<area colour="pier#660000"/>-->
     1529                <area colour="pier#660000" closed="true"/>
    15321530                <line width="2" colour="pier#660000"/>
    15331531                <icon annotate="true" src="nautical/pier.png"/>
     
    32673265                <icon src="misc/no_icon.png"/>
    32683266                <line width="2" colour="natural#002f00"/>
    3269                 <area colour="natural#002f00"/>
     3267                <area colour="natural#002f00" closed="true"/>
    32703268                <scale_min>1</scale_min>
    32713269                <scale_max>50000</scale_max>
Note: See TracChangeset for help on using the changeset viewer.