Ignore:
Timestamp:
2024-05-13T20:34:55+02:00 (4 months ago)
Author:
taylor.smock
Message:

Fix #4142: Track fully downloaded objects (patch by stoecker, GerdP, and myself)

The serialization move from PrimitiveData to AbstractPrimitive should be
reverted prior to 24.05 (see #23677).

The serialization move was required since we want to ensure that all downstream
users of AbstractPrimitive were not using the flags field, which was done by
making the field private instead of protected. They may still be using that
field (via updateFlags) which would not be caught by compile-time or runtime
errors.

Additionally, a good chunk of common functionality was moved up from
OsmPrimitive, even though much of it wasn't useful for PrimitiveData.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r18320 r19078  
    77import java.io.InputStream;
    88import java.net.SocketException;
     9import java.util.Collection;
     10import java.util.Collections;
    911import java.util.List;
    1012
     
    216218                }
    217219            }
     220            // From https://wiki.openstreetmap.org/wiki/API_v0.6#Retrieving_map_data_by_bounding_box:_GET_/api/0.6/map,
     221            // relations are not recursed up, so they *may* have parent relations.
     222            // Nodes inside the download area should have all relations and ways that refer to them.
     223            // Ways should have all relations that refer to them and all child nodes, but those child nodes may not
     224            //    have their parent referrers.
     225            // Relations will have the *first* parent relations downloaded, but those are not split out in the returns.
     226            // So we always assume that a relation has referrers that need to be downloaded unless it has no child relations.
     227            // Our "full" overpass query doesn't return the same data as a standard download, so we cannot
     228            // mark relations with no child relations as fully downloaded *yet*.
     229            if (this.considerAsFullDownload()) {
     230                final Collection<Bounds> bounds = this.getBounds();
     231                // We cannot use OsmPrimitive#isOutsideDownloadArea yet since some download methods haven't added
     232                // the download bounds to the dataset yet. This is specifically the case for overpass downloads.
     233                ds.getNodes().stream().filter(n -> bounds.stream().anyMatch(b -> b.contains(n)))
     234                        .forEach(i -> i.setReferrersDownloaded(true));
     235                ds.getWays().forEach(i -> i.setReferrersDownloaded(true));
     236            }
    218237            return ds;
    219238        } catch (OsmTransferException e) {
     
    280299    }
    281300
     301    /**
     302     * Get the bounds for this downloader
     303     * @return The bounds for this downloader
     304     * @since xxx
     305     */
     306    protected Collection<Bounds> getBounds() {
     307        return Collections.singleton(new Bounds(this.lat1, this.lon1, this.lat2, this.lon2));
     308    }
    282309}
Note: See TracChangeset for help on using the changeset viewer.