Skip to content

Commit

Permalink
Fixed Multipolygon redraw when node was moved.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zangl committed Aug 19, 2015
1 parent 04f1a06 commit 5b4aee9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@
* </ol>
*
* All entries marked for drawing are then displayed. As soon as new geometries
* are generated, a redraw is scheduled (TODO: delayed).
* are generated, a redraw is scheduled.
* <p>
* TODO: Wait a bit here.
*
*
* <h2>Cache cleaning</h2>
Expand All @@ -82,6 +81,7 @@
* We should clean:
* <ul>
* <li>Primitives with tag changes
* <li>Primitives with style changes.
* </ul>
*
* @author Michael Zangl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ public void tagsChanged(TagsChangedEvent event) {
public void relationMembersChanged(RelationMembersChangedEvent event) {
// the changed members get a clearCachedStyle(), but not the
// relation itself.
invalidateGeometry(event.getRelation());
deepInvalidate(event.getRelation(), new HashSet<OsmPrimitive>());
}

@Override
public void primitivesRemoved(PrimitivesRemovedEvent event) {
HashSet<OsmPrimitive> hashSet = new HashSet<OsmPrimitive>();
for (final OsmPrimitive p : event.getPrimitives()) {
invalidateGeometry(p);
// we ignore child nodes/...
// we ignore child nodes but respect relations referencing this.
deepInvalidate(p, hashSet);
}
}

Expand All @@ -121,9 +122,17 @@ public void otherDatasetChange(AbstractDatasetChangedEvent event) {

@Override
public void nodeMoved(NodeMovedEvent event) {
invalidateGeometry(event.getNode());
for (final OsmPrimitive ref : event.getNode().getReferrers()) {
invalidateGeometry(ref);
deepInvalidate(event.getNode(), new HashSet<OsmPrimitive>());
}

private void deepInvalidate(OsmPrimitive p,
HashSet<OsmPrimitive> invalidated) {
if (!invalidated.add(p)) {
return;
}
invalidateGeometry(p);
for (final OsmPrimitive ref : p.getReferrers()) {
deepInvalidate(ref, invalidated);
}
}

Expand Down Expand Up @@ -402,10 +411,11 @@ public <T extends OsmPrimitive> void requestOrCreateGeometry(
final MergeGroup group = recordedForPrimitive.get(primitive);
// TODO: Listen to cache invalidation events.
if (group != null
&& (primitive.mappaintStyle == null || primitive.mappaintStyle != group
.getStyleCacheUsed(primitive) || primitive
.isHighlighted() != group
.getStyleCacheUsedHighlighted(primitive))) {
&& (primitive.mappaintStyle == null
|| primitive.mappaintStyle != group
.getStyleCacheUsed(primitive) || primitive
.isHighlighted() != group
.getStyleCacheUsedHighlighted(primitive))) {
groupsForThisFrame.remove(group);
invalidate(group);
regenerate = new ArrayList<>();
Expand Down Expand Up @@ -493,7 +503,8 @@ public void dispose() {
*/
public void invalidateAll() {
while (!recordedForPrimitive.isEmpty()) {
final MergeGroup first = recordedForPrimitive.values().iterator().next();
final MergeGroup first = recordedForPrimitive.values().iterator()
.next();
// this might also remove some other primitives form the cache.
invalidate(first);
}
Expand Down

0 comments on commit 5b4aee9

Please sign in to comment.