Changeset 34827 in osm for applications/editors/josm


Ignore:
Timestamp:
2019-01-16T09:18:48+01:00 (6 years ago)
Author:
gerdp
Message:

see #14545 - Open o5m files with negative IDs fails
Same solution for o5m: use AbstractReader.buildPrimitive()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/o5m/src/org/openstreetmap/josm/plugins/o5m/io/O5mReader.java

    r34820 r34827  
    1818import org.openstreetmap.josm.data.coor.LatLon;
    1919import org.openstreetmap.josm.data.osm.DataSet;
    20 import org.openstreetmap.josm.data.osm.Node;
     20import org.openstreetmap.josm.data.osm.NodeData;
    2121import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    22 import org.openstreetmap.josm.data.osm.Relation;
     22import org.openstreetmap.josm.data.osm.RelationData;
    2323import org.openstreetmap.josm.data.osm.RelationMemberData;
    2424import org.openstreetmap.josm.data.osm.User;
    25 import org.openstreetmap.josm.data.osm.Way;
     25import org.openstreetmap.josm.data.osm.WayData;
    2626import org.openstreetmap.josm.data.osm.UploadPolicy;
    2727import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    257257            if (version == 0)
    258258                discourageUpload = true;
    259             Node node = new Node(lastNodeId, version == 0 ? 1 : version);
    260             node.setCoor(new LatLon(flat, flon).getRoundedToOsmPrecision());
    261 
    262 
    263             checkCoordinates(node.getCoor());
     259            NodeData nd = new NodeData(lastNodeId);
     260            nd.setVersion(version == 0 ? 1 : version);
     261            nd.setCoor(new LatLon(flat, flon).getRoundedToOsmPrecision());
     262
     263            checkCoordinates(nd.getCoor());
    264264            checkChangesetId(lastChangeSet);
    265             node.setChangesetId((int) lastChangeSet);
     265            nd.setChangesetId((int) lastChangeSet);
    266266            // User id
    267267            if (lastTs != 0) {
    268268                checkTimestamp(lastTs);
    269                 node.setTimestamp(new Date(lastTs * 1000));
     269                nd.setTimestamp(new Date(lastTs * 1000));
    270270                if (osmUser != null)
    271                     node.setUser(osmUser);
     271                    nd.setUser(osmUser);
    272272            }
    273273            if (bytesToRead > 0) {
    274274                Map<String, String> keys = readTags();
    275                 node.setKeys(keys);
    276             }
    277             externalIdMap.put(node.getPrimitiveId(), node);
     275                nd.setKeys(keys);
     276            }
     277            buildPrimitive(nd);
     278           
    278279        } catch (IllegalDataException e) {
    279280            exception = e;
     
    299300            if (version == 0)
    300301                discourageUpload = true;
    301             final Way way = new Way(lastWayId, version == 0 ? 1 : version);
     302            final WayData wd = new WayData(lastWayId);
     303            wd.setVersion(version == 0 ? 1 : version);
    302304            checkChangesetId(lastChangeSet);
    303             way.setChangesetId((int) lastChangeSet);
     305            wd.setChangesetId((int) lastChangeSet);
    304306            // User id
    305307            if (lastTs != 0) {
    306308                checkTimestamp(lastTs);
    307                 way.setTimestamp(new Date(lastTs * 1000));
     309                wd.setTimestamp(new Date(lastTs * 1000));
    308310                if (osmUser != null)
    309                     way.setUser(osmUser);
     311                    wd.setUser(osmUser);
    310312            }
    311313
     
    320322
    321323            Map<String, String> keys = readTags();
    322             way.setKeys(keys);
    323             ways.put(way.getUniqueId(), nodeIds);
    324             externalIdMap.put(way.getPrimitiveId(), way);
     324            wd.setKeys(keys);
     325            ways.put(wd.getUniqueId(), nodeIds);
     326            buildPrimitive(wd);
    325327        } catch (IllegalDataException e) {
    326328            exception = e;
     
    345347            if (version == 0)
    346348                discourageUpload = true;
    347             final Relation rel = new Relation(lastRelId, version == 0 ? 1 : version);
     349            final RelationData rel = new RelationData(lastRelId);
     350            rel.setVersion(version == 0 ? 1 : version);
    348351            checkChangesetId(lastChangeSet);
    349352            rel.setChangesetId((int) lastChangeSet);
     
    378381            rel.setKeys(keys);
    379382            relations.put(rel.getUniqueId(), members);
    380             externalIdMap.put(rel.getPrimitiveId(), rel);
     383            buildPrimitive(rel);
    381384        } catch (IllegalDataException e) {
    382385            exception = e;
Note: See TracChangeset for help on using the changeset viewer.