Changeset 44 in josm for src/org/openstreetmap/josm/io


Ignore:
Timestamp:
2006-01-23T00:00:39+01:00 (19 years ago)
Author:
imi
Message:
  • Save of GPX files does not save deleted - state.
  • Please wait window is always at the middle of the window where JOSM started, not the middle of the current JOSM window.
  • When saving data with tracks as OSM, an IllegalAddException may occour.
  • Saving OSM files reset the new object counter.
  • Loading of files changes coordinates (loaded as float, saved as double)
Location:
src/org/openstreetmap/josm/io
Files:
5 edited

Legend:

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

    r35 r44  
    6666                Node data = new Node();
    6767                data.coor = new GeoPoint(
    68                         Float.parseFloat(e.getAttributeValue("lat")),
    69                         Float.parseFloat(e.getAttributeValue("lon")));
     68                        Double.parseDouble(e.getAttributeValue("lat")),
     69                        Double.parseDouble(e.getAttributeValue("lon")));
    7070               
    7171                for (Object o : e.getChildren()) {
     
    190190                                osm.id = Long.parseLong(idElement.getText());
    191191                        osm.modified = e.getChild("modified", JOSM) != null;
     192                        osm.setDeleted(e.getChild("deleted", JOSM) != null);
    192193                        osm.modifiedProperties = e.getChild("modifiedProperties", JOSM) != null;
    193194                }
  • src/org/openstreetmap/josm/io/GpxWriter.java

    r35 r44  
    242242        @SuppressWarnings("unchecked")
    243243        private void addPropertyExtensions(Element e, Map<Key, String> keys, OsmPrimitive osm) {
    244                 if ((keys == null || keys.isEmpty()) && osm.id == 0 && !osm.modified && !osm.modifiedProperties)
     244                if ((keys == null || keys.isEmpty()) && osm.id == 0 && !osm.modified && !osm.isDeleted() && !osm.modifiedProperties)
    245245                        return;
    246246                Element extensions = e.getChild("extensions", GPX);
     
    264264                        extensions.getChildren().add(modElement);
    265265                }
     266                if (osm.isDeleted()) {
     267                        Element modElement = new Element("deleted", JOSM);
     268                        extensions.getChildren().add(modElement);
     269                }
    266270                if (osm.modifiedProperties) {
    267271                        Element modElement = new Element("modifiedProperties", JOSM);
  • src/org/openstreetmap/josm/io/OsmReader.java

    r39 r44  
    6666                Node data = new Node();
    6767                data.coor = new GeoPoint(
    68                         Float.parseFloat(e.getAttributeValue("lat")),
    69                         Float.parseFloat(e.getAttributeValue("lon")));
     68                        Double.parseDouble(e.getAttributeValue("lat")),
     69                        Double.parseDouble(e.getAttributeValue("lon")));
    7070                if (Double.isNaN(data.coor.lat) ||
    7171                                data.coor.lat < -90 || data.coor.lat > 90 ||
  • src/org/openstreetmap/josm/io/OsmWriter.java

    r40 r44  
    102102         */
    103103        private void addProperties(Element e, OsmPrimitive osm) {
    104                 if (osm.id == 0)
    105                         osm.id = newIdCounter--;
    106                 e.setAttribute("uid", ""+osm.id);
     104                long id = osm.id;
     105                if (id == 0)
     106                        id = newIdCounter--;
     107                e.setAttribute("uid", ""+id);
    107108                if (osm.keys != null)
    108109                        for (Entry<Key, String> entry : osm.keys.entrySet())
     
    135136        @SuppressWarnings("unchecked")
    136137        public void visit(Track t) {
    137                 Element e = new Element("track");
    138                 addProperties(e, t);
     138                element = new Element("track");
     139                addProperties(element, t);
    139140                for (LineSegment ls : t.segments)
    140                         e.getChildren().add(new Element("segment").setAttribute("uid", ""+ls.id));
     141                        element.getChildren().add(new Element("segment").setAttribute("uid", ""+ls.id));
    141142        }
    142143
  • src/org/openstreetmap/josm/io/RawGpsReader.java

    r40 r44  
    6363                for (Object o : root.getChildren("wpt", GPX)) {
    6464                        Collection<GeoPoint> line = new LinkedList<GeoPoint>();
    65                         line.add(new GeoPoint(parseFloat((Element)o, LatLon.lat), parseFloat((Element)o, LatLon.lon)));
     65                        line.add(new GeoPoint(parseDouble((Element)o, LatLon.lat), parseDouble((Element)o, LatLon.lon)));
    6666                        data.add(line);
    6767                }
     
    8888         * @throws JDOMException If the absolute of the value is out of bound.
    8989         */
    90         private float parseFloat(Element e, LatLon attr) throws JDOMException {
    91                 float f = Float.parseFloat(e.getAttributeValue(attr.toString()));
    92                 if (Math.abs(f) > (attr == LatLon.lat ? 90 : 180))
    93                         throw new JDOMException("Data error: "+attr+" value '"+f+"' is out of bound.");
    94                 return f;
     90        private double parseDouble(Element e, LatLon attr) throws JDOMException {
     91                double d = Double.parseDouble(e.getAttributeValue(attr.toString()));
     92                if (Math.abs(d) > (attr == LatLon.lat ? 90 : 180))
     93                        throw new JDOMException("Data error: "+attr+" value '"+d+"' is out of bound.");
     94                return d;
    9595        }
    9696
     
    102102                Collection<GeoPoint> data = new LinkedList<GeoPoint>();
    103103                for (Element e : wpt)
    104                         data.add(new GeoPoint(parseFloat(e, LatLon.lat), parseFloat(e, LatLon.lon)));
     104                        data.add(new GeoPoint(parseDouble(e, LatLon.lat), parseDouble(e, LatLon.lon)));
    105105                return data;
    106106        }
Note: See TracChangeset for help on using the changeset viewer.