Changeset 44 in josm for src/org


Ignore:
Timestamp:
2006-01-23T00:00:39+01:00 (18 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
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/Main.java

    r40 r44  
    5656         */
    5757        private Container panel;
    58         /**
    59          * The name of the current loaded mapFrame
    60          */
    61         private String name;
    6258        /**
    6359         * The mapFrame currently loaded.
     
    182178         * aborts, nothing happens.
    183179         */
    184         public void setMapFrame(String name, MapFrame mapFrame) {
     180        public void setMapFrame(MapFrame mapFrame) {
    185181                //TODO: Check for changes and ask user
    186                 this.name = name;
    187182                if (this.mapFrame != null)
    188183                        this.mapFrame.setVisible(false);
     
    197192        }
    198193        /**
    199          * @return Returns the name.
    200          */
    201         public String getNameOfLoadedMapFrame() {
    202                 return name;
    203         }
    204         /**
    205194         * @return Returns the mapFrame.
    206195         */
  • src/org/openstreetmap/josm/actions/DownloadAction.java

    r43 r44  
    175175                                        Layer layer = null;
    176176                                        if (rawGps.isSelected()) {
    177                                                 layer = new RawGpsDataLayer(osmReader.parseRawGps(),
    178                                                                 name);
     177                                                layer = new RawGpsDataLayer(osmReader.parseRawGps(), name);
    179178                                        } else {
    180179                                                DataSet dataSet = osmReader.parseOsm();
    181180                                                if (dataSet == null)
    182181                                                        return; // user cancelled download
    183                                                 if (dataSet.nodes.isEmpty())
     182                                                if (dataSet.nodes.isEmpty()) {
     183                                                        pleaseWaitDlg.setVisible(false);
     184                                                        pleaseWaitDlg.dispose();
    184185                                                        JOptionPane.showMessageDialog(Main.main,
    185186                                                                        "No data imported.");
    186 
    187                                                 layer = new OsmDataLayer(dataSet, name);
     187                                                }
     188
     189                                                layer = new OsmDataLayer(dataSet, "Data Layer");
    188190                                        }
    189191
    190192                                        if (Main.main.getMapFrame() == null)
    191                                                 Main.main.setMapFrame(name, new MapFrame(layer));
     193                                                Main.main.setMapFrame(new MapFrame(layer));
    192194                                        else
    193195                                                Main.main.getMapFrame().mapView.addLayer(layer);
     
    195197                                } catch (JDOMException x) {
    196198                                        pleaseWaitDlg.setVisible(false);
     199                                        pleaseWaitDlg.dispose();
    197200                                        x.printStackTrace();
    198201                                        JOptionPane.showMessageDialog(Main.main, x.getMessage());
    199202                                } catch (FileNotFoundException x) {
    200203                                        pleaseWaitDlg.setVisible(false);
     204                                        pleaseWaitDlg.dispose();
    201205                                        x.printStackTrace();
    202206                                        JOptionPane.showMessageDialog(Main.main,
     
    204208                                } catch (IOException x) {
    205209                                        pleaseWaitDlg.setVisible(false);
     210                                        pleaseWaitDlg.dispose();
    206211                                        x.printStackTrace();
    207212                                        JOptionPane.showMessageDialog(Main.main, x.getMessage());
    208213                                } finally {
    209                                         pleaseWaitDlg.setVisible(false);
     214                                        if (pleaseWaitDlg.isVisible()) {
     215                                                pleaseWaitDlg.setVisible(false);
     216                                                pleaseWaitDlg.dispose();
     217                                        }
    210218                                }
    211219                        }
  • src/org/openstreetmap/josm/actions/JosmAction.java

    r43 r44  
    4747                pleaseWaitDlg.getContentPane().add(l);
    4848                pleaseWaitDlg.pack();
    49                 pleaseWaitDlg.setLocation(Main.main.getWidth()/2-pleaseWaitDlg.getWidth()/2,
    50                                 Main.main.getHeight()/2-pleaseWaitDlg.getHeight()/2);
     49                pleaseWaitDlg.setLocation(Main.main.getX()+Main.main.getWidth()/2-pleaseWaitDlg.getWidth()/2,
     50                                Main.main.getY()+Main.main.getHeight()/2-pleaseWaitDlg.getHeight()/2);
    5151                pleaseWaitDlg.setResizable(false);
    52                 pleaseWaitDlg.setAlwaysOnTop(true);
    5352                return pleaseWaitDlg;
    5453        }
  • src/org/openstreetmap/josm/actions/OpenAction.java

    r40 r44  
    8282                                        return;
    8383                                }
    84                                 layer = new OsmDataLayer(dataSet, filename.getName());
     84                                layer = new OsmDataLayer(dataSet, "Data Layer");
    8585                        }
    8686                       
    8787                        if (Main.main.getMapFrame() == null)
    88                                 Main.main.setMapFrame(filename.getName(), new MapFrame(layer));
     88                                Main.main.setMapFrame(new MapFrame(layer));
    8989                        else
    9090                                Main.main.getMapFrame().mapView.addLayer(layer);
  • src/org/openstreetmap/josm/actions/UploadAction.java

    r43 r44  
    8383                                } catch (JDOMException x) {
    8484                                        dlg.setVisible(false);
     85                                        dlg.dispose();
    8586                                        x.printStackTrace();
    8687                                        JOptionPane.showMessageDialog(Main.main, x.getMessage());
    8788                                } finally {
    88                                         dlg.setVisible(false);
     89                                        if (dlg.isVisible()) {
     90                                                dlg.setVisible(false);
     91                                                dlg.dispose();
     92                                        }
    8993                                }
    9094                        }
  • src/org/openstreetmap/josm/gui/BugReportExceptionHandler.java

    r40 r44  
    2727public final class BugReportExceptionHandler implements Thread.UncaughtExceptionHandler {
    2828        public void uncaughtException(Thread t, Throwable e) {
     29                e.printStackTrace();
    2930                if (Main.main == null)
    3031                        e.printStackTrace();
  • src/org/openstreetmap/josm/gui/dialogs/LayerList.java

    r30 r44  
    153153                        public void actionPerformed(ActionEvent e) {
    154154                                if (model.size() == 1) {
    155                                         Main.main.setMapFrame(null, null);
     155                                        Main.main.setMapFrame(null);
    156156                                        Main.main.ds = new DataSet();
    157157                                } else {
  • 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.