Ignore:
Timestamp:
2009-09-07T23:06:19+02:00 (15 years ago)
Author:
Gubaer
Message:

Had to replace DataSet:getPrimitiveById(id) with DataSet:getPrimitiveById(id,type). Primitive ids are not globally unique, only per type of primitive.
Fixed problems in unit test, available unit tests passing again.

File:
1 edited

Legend:

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

    r2070 r2077  
    110110     *   id=<code>id</code>
    111111     */
    112     protected void remember(DataSet ds, long id) throws IllegalArgumentException, NoSuchElementException{
     112    protected void remember(DataSet ds, long id, OsmPrimitiveType type) throws IllegalArgumentException, NoSuchElementException{
    113113        if (ds == null)
    114114            throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "ds"));
    115115        if (id <= 0) return;
    116         OsmPrimitive primitive = ds.getPrimitiveById(id);
     116        OsmPrimitive primitive = ds.getPrimitiveById(id, type);
    117117        if (primitive == null)
    118118            throw new NoSuchElementException(tr("no primitive with id {0} in local dataset. Can't infer primitive type", id));
     
    122122
    123123    /**
    124      * appends a list of  ids to the list of ids which will be fetched from the server. ds must
    125      * include an {@see OsmPrimitive} for each id in ids.
    126      *
    127      * id is ignored if id <= 0.
    128      *
    129      * @param ds  the dataset
    130      * @param ids  the list of ids
     124     * appends a {@see Node}s id to the list of ids which will be fetched from the server.
     125     *
     126     * @param node  the node (ignored, if null)
    131127     * @return this
    132128     *
    133129     */
    134     public MultiFetchServerObjectReader append(DataSet ds, long ... ids)  {
    135         if (ids == null) return this;
    136         for (int i=0; i < ids.length; i++) {
    137             remember(ds, ids[i]);
    138         }
    139         return this;
    140     }
    141 
    142     /**
    143      * appends a collection of  ids to the list of ids which will be fetched from the server. ds must
    144      * include an {@see OsmPrimitive} for each id in ids.
    145      *
    146      * id is ignored if id <= 0.
    147      *
    148      * @param ds  the dataset
    149      * @param ids  the collection of ids
    150      * @return this
    151      *
    152      */
    153     public MultiFetchServerObjectReader append(DataSet ds, Collection<Long> ids) {
    154         if (ids == null) return null;
    155         for (long id: ids) {
    156             append(ds,id);
     130    public MultiFetchServerObjectReader append(DataSet ds, long id, OsmPrimitiveType type) {
     131        switch(type) {
     132        case NODE:
     133            Node n = (Node)ds.getPrimitiveById(id,type);
     134            append(n);
     135            break;
     136        case WAY:
     137            Way w= (Way)ds.getPrimitiveById(id,type);
     138            append(w);
     139            break;
     140        case RELATION:
     141            Relation r = (Relation)ds.getPrimitiveById(id,type);
     142            append(r);
     143            break;
    157144        }
    158145        return this;
     
    376363                String msg = "";
    377364                switch(type) {
    378                     case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;
    379                     case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;
    380                     case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;
     365                case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;
     366                case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;
     367                case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break;
    381368                }
    382369                progressMonitor.setCustomText(msg);
     
    414401        String msg = "";
    415402        switch(type) {
    416             case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;
    417             case WAY:  msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;
    418             case RELATION:  msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;
     403        case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;
     404        case WAY:  msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;
     405        case RELATION:  msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break;
    419406        }
    420407        progressMonitor.setCustomText(msg);
Note: See TracChangeset for help on using the changeset viewer.