Re: [josm-dev] GPS coordinates
Hi Thanks for the feedback. I've incorporated your changes and fixed negative longitude and latitude so that in DMS N/S/W/E is displayed instead. I've attached a new patch to the ticket http://josm.openstreetmap.de/ticket/1730 It still only effects mapstatus and not selection though. Regards Markus 2008/11/29 Ævar Arnfjörð Bjarmason [EMAIL PROTECTED]: On Sat, Nov 29, 2008 at 3:18 PM, Markus Lindholm [EMAIL PROTECTED] wrote: Ok, attached a patch to ticket http://josm.openstreetmap.de/ticket/1730 [I'm not a JOSM dev] I reviewed it briefly and there are a few problems I can see: * The string you're writing to the preferences file to determine what coordinate system the user wants is the one displayed in the user interface, thus if you ever change the UI string (or it gets translated?) the preference will break. It would be better to write something like coordinates=DMS than coordinates=Degree Minute Second * Your convertDDToDMS() function breaks if either of the degrees is negative, e.g. -21.5050 will be -21°-30'-30 (approx values), you need to import java.lang.Math and do something like: public static String S(double pCordinate) { int tDegree = (int) pCordinate; double tTmpMinutes = (pCordinate - tDegree) * 60; int tMinutes = Math.abs((int) tTmpMinutes); double tSeconds = Math.abs((tTmpMinutes - tMinutes) * 60); return tDegree + \u00B0 + tMinutes + \' + DMSsFormatter.format(tSeconds) + \; * Your DMS format isn't a DMS format at all even without the negative values in the middle of the string. There are no negative numbers in DMS, 64,-21 is 64N,21W * This only works for the JOSM map display but not other places where coordinates are displayed, e.g. the selection dialog * The width of the coordinate display needs to be adjusted depending on the coordinate system in use or trailing dots will be displayed (see attached screenshot) And as a bit of random drive-by bikeshedding I prefer the Garmin coordinate selection format I've attached in my patch, which is broken by default unless you select a coordinate system since I was in the process of trying to add a DM system in addition do D and DMS. ___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev
Re: [josm-dev] GPS coordinates
On Sun, Nov 30, 2008 at 2:06 PM, Markus Lindholm [EMAIL PROTECTED] wrote: Thanks for the feedback. I've incorporated your changes and fixed negative longitude and latitude so that in DMS N/S/W/E is displayed instead. I've attached a new patch to the ticket http://josm.openstreetmap.de/ticket/1730 I should have been more clear about this, my patch was not something that should have been incorporated into your patch as-is but a work in progress modification I used to tweak josm when reviewing yours. You incorporated the ERROR selection between coordinate systems and as a result JOSM displays ERROR by default in the selection pane when no coordinate system has been selected in the preferences. The alternation between coordinate systems needs to be fixed and JOSM needs to work by default if none is selected. The coordinates should also be padded, mm and ss in hddd°mm'ss.s (and its DM equivalent) should always be two digits, e.g. 64°08'23.564°08'23.5 not 64°8'23.5. And the issue of writing the display string to the preferences file remains, this is what was written to my preferences: coordinates=hddd°mm'ss.s ___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev
Re: [josm-dev] GPS coordinates
2008/11/30 Ævar Arnfjörð Bjarmason [EMAIL PROTECTED]: On Sun, Nov 30, 2008 at 2:06 PM, Markus Lindholm [EMAIL PROTECTED] wrote: Thanks for the feedback. I've incorporated your changes and fixed negative longitude and latitude so that in DMS N/S/W/E is displayed instead. I've attached a new patch to the ticket http://josm.openstreetmap.de/ticket/1730 I should have been more clear about this, my patch was not something that should have been incorporated into your patch as-is but a work in progress modification I used to tweak josm when reviewing yours. You incorporated the ERROR selection between coordinate systems and as a result JOSM displays ERROR by default in the selection pane when no coordinate system has been selected in the preferences. The alternation between coordinate systems needs to be fixed and JOSM needs to work by default if none is selected. The coordinates should also be padded, mm and ss in hddd°mm'ss.s (and its DM equivalent) should always be two digits, e.g. 64°08'23.564°08'23.5 not 64°8'23.5. And the issue of writing the display string to the preferences file remains, this is what was written to my preferences: coordinates=hddd°mm'ss.s Ok, a new patch has been attached to the ticket. - The numbers are now padded - I use the I18n.tr() method on the string returned - I removed the DM code as it was not ready Regards Markus ___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev
Re: [josm-dev] GPS coordinates
The best way to get the changes included is to supply a diff containing the changes, and attach it to the trac ticket, posting a link to that trac ticket here. The following command will be useful: svn diff patchname.diff Shaun On 29 Nov 2008, at 14:53, Markus Lindholm wrote: Hi A few weeks ago I filed ticket #1730 about the possibility to configure how GPS coordinates are displayed. I've now implemented the possibility to configure JOSM to display them as Degree Minute Seconds. I'm rather new to OSM and JOSM so I don't know what's the proper way to get the code included in the repository, but I've included a jar-file with the changed source files. Regards Markus Ticket1730.jar___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev ___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev
Re: [josm-dev] GPS coordinates
Ok, attached a patch to ticket http://josm.openstreetmap.de/ticket/1730 2008/11/29 Shaun McDonald [EMAIL PROTECTED]: The best way to get the changes included is to supply a diff containing the changes, and attach it to the trac ticket, posting a link to that trac ticket here. The following command will be useful: svn diff patchname.diff Shaun On 29 Nov 2008, at 14:53, Markus Lindholm wrote: Hi A few weeks ago I filed ticket #1730 about the possibility to configure how GPS coordinates are displayed. I've now implemented the possibility to configure JOSM to display them as Degree Minute Seconds. I'm rather new to OSM and JOSM so I don't know what's the proper way to get the code included in the repository, but I've included a jar-file with the changed source files. Regards Markus Ticket1730.jar___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev ___ josm-dev mailing list josm-dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/josm-dev
Re: [josm-dev] GPS coordinates
On Sat, Nov 29, 2008 at 3:18 PM, Markus Lindholm [EMAIL PROTECTED] wrote: Ok, attached a patch to ticket http://josm.openstreetmap.de/ticket/1730 [I'm not a JOSM dev] I reviewed it briefly and there are a few problems I can see: * The string you're writing to the preferences file to determine what coordinate system the user wants is the one displayed in the user interface, thus if you ever change the UI string (or it gets translated?) the preference will break. It would be better to write something like coordinates=DMS than coordinates=Degree Minute Second * Your convertDDToDMS() function breaks if either of the degrees is negative, e.g. -21.5050 will be -21°-30'-30 (approx values), you need to import java.lang.Math and do something like: public static String S(double pCordinate) { int tDegree = (int) pCordinate; double tTmpMinutes = (pCordinate - tDegree) * 60; int tMinutes = Math.abs((int) tTmpMinutes); double tSeconds = Math.abs((tTmpMinutes - tMinutes) * 60); return tDegree + \u00B0 + tMinutes + \' + DMSsFormatter.format(tSeconds) + \; * Your DMS format isn't a DMS format at all even without the negative values in the middle of the string. There are no negative numbers in DMS, 64,-21 is 64N,21W * This only works for the JOSM map display but not other places where coordinates are displayed, e.g. the selection dialog * The width of the coordinate display needs to be adjusted depending on the coordinate system in use or trailing dots will be displayed (see attached screenshot) And as a bit of random drive-by bikeshedding I prefer the Garmin coordinate selection format I've attached in my patch, which is broken by default unless you select a coordinate system since I was in the process of trying to add a DM system in addition do D and DMS. Index: src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java === --- src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java (revision 1096) +++ src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java (working copy) @@ -13,6 +13,7 @@ import org.openstreetmap.josm.Main; import org.openstreetmap.josm.data.projection.Projection; +import org.openstreetmap.josm.data.projection.Projection.CoordinateDisplay; import org.openstreetmap.josm.tools.GBC; public class ProjectionPreference implements PreferenceSetting { @@ -21,15 +22,26 @@ * Combobox with all projections available */ private JComboBox projectionCombo = new JComboBox(Projection.allProjections); + private JComboBox coordinatesCombo = new JComboBox(CoordinateDisplay.values()); public void addGui(PreferenceDialog gui) { - for (int i = 0; i projectionCombo.getItemCount(); ++i) { - if (projectionCombo.getItemAt(i).getClass().getName().equals(Main.pref.get(projection))) { -projectionCombo.setSelectedIndex(i); -break; - } - } + +for (int i = 0; i projectionCombo.getItemCount(); ++i) { +if (projectionCombo.getItemAt(i).getClass().getName().equals(Main.pref.get(projection))) { +projectionCombo.setSelectedIndex(i); +break; +} +} + +for (int i = 0; i coordinatesCombo.getItemCount(); ++i) { +if (coordinatesCombo.getItemAt(i).toString().equals(Main.pref.get(coordinates))) { +coordinatesCombo.setSelectedIndex(i); +break; +} +} + projectionCombo.addActionListener(gui.requireRestartAction); +coordinatesCombo.addActionListener(gui.requireRestartAction); JPanel projPanel = new JPanel(); projPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.gray), tr(Map Projection))); @@ -37,10 +49,14 @@ projPanel.add(new JLabel(tr(Projection method)), GBC.std().insets(5,5,0,5)); projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); + projPanel.add(new JLabel(tr(Display coordinates as)), GBC.std().insets(5,5,0,5)); + projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); + projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); gui.map.add(projPanel, GBC.eol().insets(0,0,0,10).fill(GBC.HORIZONTAL)); } public void ok() { Main.pref.put(projection, projectionCombo.getSelectedItem().getClass().getName()); + Main.pref.put(coordinates, coordinatesCombo.getSelectedItem().toString()); } } Index: src/org/openstreetmap/josm/gui/MapStatus.java === --- src/org/openstreetmap/josm/gui/MapStatus.java (revision 1096) +++ src/org/openstreetmap/josm/gui/MapStatus.java (working copy) @@ -88,11 +88,12 @@ } } + String mCord; DecimalFormat latlon = new DecimalFormat(###0.); -ImageLabel lonText = new ImageLabel(lon, tr(The geographic