Changeset 9325 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-01-05T23:48:02+01:00 (9 years ago)
Author:
simon04
Message:

see #7670 fix #7647 - Fetching objects via Overpass API recurses down

Thus, there is no need for separately querying way nodes, or relation members.

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r9241 r9325  
    9292            if (primitive instanceof Node && !primitive.isNew()) {
    9393                reader.append(primitive);
    94             } else if (primitive instanceof Way) {
    95                 Way way = (Way) primitive;
    96                 for (Node node: way.getNodes()) {
    97                     if (!node.isNew()) {
    98                         reader.append(node);
    99                     }
    100                 }
    10194            }
    10295        }
     
    107100        for (OsmPrimitive primitive : toUpdate) {
    108101            if (primitive instanceof Way && !primitive.isNew()) {
     102                // this also adds way nodes
    109103                reader.append(primitive);
    110104            }
     
    116110        for (OsmPrimitive primitive : toUpdate) {
    117111            if (primitive instanceof Relation && !primitive.isNew()) {
     112                // this also adds relation members
    118113                reader.append(primitive);
    119114            }
  • trunk/src/org/openstreetmap/josm/io/MultiFetchOverpassObjectReader.java

    r9242 r9325  
    3131        return OverpassServerPreference.getOverpassServer();
    3232    }
     33
     34    @Override
     35    protected boolean recursesDown() {
     36        // see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Recurse_down_.28.3E.29 for documentation
     37        // accomplished using >; in the query string above
     38        return true;
     39    }
    3340}
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r9324 r9325  
    171171        if (way == null) return this;
    172172        if (way.isNew()) return this;
    173         for (Node node: way.getNodes()) {
     173        for (Node node: !recursesDown() ? way.getNodes() : Collections.<Node>emptyList()) {
    174174            if (!node.isNew()) {
    175175                remember(node.getPrimitiveId());
     
    190190        if (relation.isNew()) return this;
    191191        remember(relation.getPrimitiveId());
    192         for (RelationMember member : relation.getMembers()) {
     192        for (RelationMember member : !recursesDown() ? relation.getMembers() : Collections.<RelationMember>emptyList()) {
    193193            if (OsmPrimitiveType.from(member.getMember()).equals(OsmPrimitiveType.RELATION)) {
    194194                // avoid infinite recursion in case of cyclic dependencies in relations
     
    403403    public Set<PrimitiveId> getMissingPrimitives() {
    404404        return missingPrimitives;
     405    }
     406
     407    /**
     408     * Whether this reader fetches nodes when loading ways, or members when loading relations.
     409     *
     410     * @return {@code true} if the reader recurses down
     411     */
     412    protected boolean recursesDown() {
     413        return false;
    405414    }
    406415
Note: See TracChangeset for help on using the changeset viewer.