Changeset 4649 in josm for trunk/src/org


Ignore:
Timestamp:
2011-12-10T16:56:02+01:00 (9 years ago)
Author:
Don-vip
Message:

see #7131 and #6987 - Let Multipolygon cache handle incomplete relations

Location:
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java

    r4639 r4649  
    336336    private final List<PolyData> outerPolygons = new ArrayList<PolyData>();
    337337    private final List<PolyData> combinedPolygons = new ArrayList<PolyData>();
     338   
     339    private boolean incomplete;
    338340
    339341    public Multipolygon(Relation r) {
     
    346348        // Fill inner and outer list with valid ways
    347349        for (RelationMember m : r.getMembers()) {
    348             if (m.getMember().isDrawable()) {
     350            if (m.getMember().isIncomplete()) {
     351                this.incomplete = true;
     352            } else if (m.getMember().isDrawable()) {
    349353                if (m.isWay()) {
    350354                    Way w = m.getWay();
     
    370374            addInnerToOuters();
    371375        }
     376    }
     377   
     378    public final boolean isIncomplete() {
     379        return incomplete;
    372380    }
    373381
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java

    r4636 r4649  
    229229    @Override
    230230    public void dataChanged(DataChangedEvent event) {
    231         // Do nothing
     231        // Do not call updateMultipolygonsReferringTo as getPrimitives()
     232        // can return all the data set primitives for this event
     233        Collection<Map<Relation, Multipolygon>> maps = null;
     234        for (OsmPrimitive p : event.getPrimitives()) {
     235            if (isMultipolygon(p)) {
     236                if (maps == null) {
     237                    maps = getMapsFor(event.getDataset());
     238                }
     239                for (Map<Relation, Multipolygon> map : maps) {
     240                    Multipolygon mp = map.get(p);
     241                    // DataChangedEvent is sent after downloading incomplete members,
     242                    // without having received RelationMembersChangedEvent or PrimitivesAddedEvent
     243                    if (mp != null && mp.isIncomplete()) {
     244                        // This ensures previously incomplete multipolygons will be correctly redrawn
     245                        map.remove(p);
     246                    }
     247                }
     248            }
     249        }
    232250    }
    233251
Note: See TracChangeset for help on using the changeset viewer.