Ignore:
Timestamp:
2011-01-31T14:18:47+01:00 (9 years ago)
Author:
bastiK
Message:

mappaint restructuring aimed at mapcss support:

  • area- and line style of multipolygon outer & inner ways are no longer determined by MapPaintVisitor, but the information is calculated in advance and cached
  • cache is aware of zoom level
  • z_index property to allow more fancy styles in future

Performance: when the style cache is filled, painting is the same or ~5% faster. The first painting, which includes style generation, takes ~30% longer than before. (There is potential for optimization, though.) Memory usage unchanged.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r3825 r3836  
    2626import org.openstreetmap.josm.gui.mappaint.ElemStyles;
    2727import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    28 import org.openstreetmap.josm.gui.mappaint.StyleCache;
    2928import org.openstreetmap.josm.gui.mappaint.xml.AreaPrototype;
    3029
     
    4746    private final List<List<Node>> nonClosedWays = new ArrayList<List<Node>>();
    4847
     48    private final double SCALE = 1.0; // arbitrary scale - we could test every possible scale, but this should suffice
     49
    4950    public MultipolygonTest() {
    5051        super(tr("Multipolygon"),
     
    115116    public void visit(Way w) {
    116117        if (styles != null && !w.isClosed()) {
    117             AreaPrototype e = styles.getAreaProto(w);
    118             if (e != null && ! e.closed) {
    119                 errors.add( new TestError(this, Severity.WARNING, tr("Area style way is not closed"), NOT_CLOSED,  w));
     118            for (ElemStyle s : styles.generateStyles(w, SCALE, null, false).a) {
     119                if (s instanceof AreaElemStyle) {
     120                    errors.add( new TestError(this, Severity.WARNING, tr("Area style way is not closed"), NOT_CLOSED,  w));
     121                    break;
     122                }
    120123            }
    121124        }
     
    143146            List<List<Node>> outerWays = joinWays(polygon.getOuterWays());
    144147            if (styles != null) {
    145                 StyleCache sc = styles.get(r);
    146148
    147149                AreaElemStyle area = null;
    148                 for (ElemStyle s : sc.getStyles()) {
     150                for (ElemStyle s : styles.generateStyles(r, SCALE, null, false).a) {
    149151                    if (s instanceof AreaElemStyle) {
    150152                        area = (AreaElemStyle) s;
     
    155157                if (area == null) {
    156158                    errors.add( new TestError(this, Severity.OTHER, tr("No style in multipolygon relation"),
    157                     NO_STYLE_POLYGON, r));
     159                            NO_STYLE_POLYGON, r));
    158160                    for (Way w : polygon.getOuterWays()) {
    159161
    160                         for (ElemStyle s : styles.getArea(w).getStyles()) {
     162                        for (ElemStyle s : styles.generateStyles(r, SCALE, null, true).a) {
    161163                            if (s instanceof AreaElemStyle) {
    162164                                area = (AreaElemStyle) s;
     
    173175                    for (Way wInner : polygon.getInnerWays()) {
    174176                        AreaElemStyle areaInner = null;
    175                         for (ElemStyle s : styles.get(wInner).getStyles()) {
     177                        for (ElemStyle s : styles.generateStyles(wInner, SCALE, null, false).a) {
    176178                            if (s instanceof AreaElemStyle) {
    177179                                areaInner = (AreaElemStyle) s;
     
    185187                            l.add(wInner);
    186188                            errors.add( new TestError(this, Severity.WARNING, tr("Style for inner way equals multipolygon"),
    187                             INNER_STYLE_MISMATCH, l, Collections.singletonList(wInner)));
     189                                    INNER_STYLE_MISMATCH, l, Collections.singletonList(wInner)));
    188190                        }
    189191                    }
    190192                    for (Way wOuter : polygon.getOuterWays()) {
    191193                        AreaElemStyle areaOuter = null;
    192                         for (ElemStyle s : styles.get(wOuter).getStyles()) {
     194                        for (ElemStyle s : styles.generateStyles(wOuter, SCALE, null, false).a) {
    193195                            if (s instanceof AreaElemStyle) {
    194196                                areaOuter = (AreaElemStyle) s;
Note: See TracChangeset for help on using the changeset viewer.