Changeset 15960 in osm for applications/editors/josm/plugins
- Timestamp:
- 2009-06-17T09:01:52+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/CorrelateGpxWithImages.java
r14916 r15960 559 559 new String[] { tr("Correlate"), tr("Auto-Guess"), tr("Cancel") }, 560 560 new String[] { "ok.png", "dialogs/gpx2imgManual.png", "cancel.png" }).getValue(); 561 561 562 562 if(answer != 1 && answer != 2) 563 563 return; 564 564 565 565 // Check the selected values 566 566 Object item = cbGpx.getSelectedItem(); … … 572 572 } 573 573 selectedGpx = ((GpxDataWrapper) item); 574 574 575 575 if (answer == 2) { 576 576 autoGuess(selectedGpx.data); … … 643 643 644 644 } 645 645 646 646 // These variables all belong to "auto guess" but need to be accessible 647 647 // from the slider change listener … … 659 659 private long firstGPXDate = -1; 660 660 private long firstExifDate = -1; 661 661 662 662 /** 663 663 * Tries to automatically match opened photos to a given GPX track. Changes are applied … … 669 669 autoImgs = getSortedImgList(true, false); 670 670 PrimaryDateParser dateParser = new PrimaryDateParser(); 671 671 672 672 // no images found, exit 673 673 if(autoImgs.size() <= 0) { … … 677 677 return; 678 678 } 679 679 680 680 // Free the user's vision 681 681 Main.pleaseWaitDlg.setVisible(false); 682 682 AgpifojDialog dialog = AgpifojDialog.getInstance(); 683 683 dialog.action.button.setSelected(true); 684 dialog.action.actionPerformed(null); 684 dialog.action.actionPerformed(null); 685 685 // Will show first photo if none is selected yet 686 686 if(!dialog.hasImage()) 687 687 yLayer.showNextPhoto(); 688 688 // FIXME: If the dialog is minimized it will not be maximized. ToggleDialog is 689 // in need of a complete re-write to allow this in a reasonable way. 689 // in need of a complete re-write to allow this in a reasonable way. 690 690 691 691 // Init variables 692 692 firstExifDate = autoImgs.get(0).time.getTime()/1000; 693 694 693 694 695 695 // Finds first GPX point 696 696 outer: for (GpxTrack trk : gpx.tracks) { … … 699 699 String curDateWpStr = (String) curWp.attr.get("time"); 700 700 if (curDateWpStr == null) continue; 701 701 702 702 try { 703 703 firstGPXDate = dateParser.parse(curDateWpStr).getTime()/1000; … … 707 707 } 708 708 } 709 709 710 710 // No GPX timestamps found, exit 711 711 if(firstGPXDate < 0) { … … 715 715 return; 716 716 } 717 717 718 718 // seconds 719 719 long diff = (yLayer.hasTimeoffset) 720 720 ? yLayer.timeoffset 721 : firstExifDate - firstGPXDate; 721 : firstExifDate - firstGPXDate; 722 722 yLayer.timeoffset = diff; 723 723 yLayer.hasTimeoffset = true; 724 724 725 725 double diffInH = (double)diff/(60*60); // hours 726 726 … … 728 728 dayOffset = (int)Math.round(diffInH / 24); // days 729 729 double timezone = diff - dayOffset*24*60*60; // seconds 730 730 731 731 // In hours, rounded to two decimal places 732 732 timezone = (double)Math.round(timezone*100/(60*60)) / 100; … … 736 736 double fixTimezone = (double)Math.round(timezone * 2)/2; // hours, rounded to one decimal place 737 737 int offset = (int)Math.round(diff - fixTimezone*60*60) - dayOffset*24*60*60; // seconds 738 738 739 739 /*System.out.println("phto " + firstExifDate); 740 740 System.out.println("gpx " + firstGPXDate); … … 745 745 System.out.println("fix " + fixTimezone); 746 746 System.out.println("offt " + offset);*/ 747 747 748 748 // This is called whenever one of the sliders is moved. 749 749 // It updates the labels and also calls the "match photos" code … … 756 756 : (int)Math.floor(tz/2) + ":30"; 757 757 if(sldTimezone.getValue() < 0) zone = "-" + zone; 758 758 759 759 lblTimezone.setText(tr("Timezone: {0}", zone)); 760 760 lblMinutes.setText(tr("Minutes: {0}", sldMinutes.getValue())); 761 761 lblSeconds.setText(tr("Seconds: {0}", sldSeconds.getValue())); 762 762 763 763 float gpstimezone = parseTimezone(zone).floatValue(); 764 764 765 765 // Reset previous position 766 766 for(ImageEntry x : autoImgs) { … … 768 768 x.pos = null; 769 769 } 770 770 771 771 long timediff = (long) (gpstimezone * 3600) 772 772 + dayOffset*24*60*60 773 773 + sldMinutes.getValue()*60 774 774 + sldSeconds.getValue(); 775 775 776 776 int matched = matchGpxTrack(autoImgs, autoGpx, timediff); 777 777 … … 783 783 ) 784 784 ); 785 785 786 786 int offset = (int)(firstGPXDate+timediff-firstExifDate); 787 787 int o = Math.abs(offset); … … 797 797 } 798 798 } 799 799 800 800 // Info Labels 801 801 lblMatches = new JLabel(); … … 807 807 lblTimezone = new JLabel(); 808 808 sldTimezone = new JSlider(-24, 24, 0); 809 sldTimezone.setPaintLabels(true); 809 sldTimezone.setPaintLabels(true); 810 810 Hashtable labelTable = new Hashtable(); 811 811 labelTable.put(-24, new JLabel("-12:00")); … … 815 815 labelTable.put( 24, new JLabel( "12:00")); 816 816 sldTimezone.setLabelTable(labelTable); 817 817 818 818 // Minutes Slider 819 819 lblMinutes = new JLabel(); 820 sldMinutes = new JSlider(-15, 15, 0); 821 sldMinutes.setPaintLabels(true); 822 sldMinutes.setMajorTickSpacing(5); 823 820 sldMinutes = new JSlider(-15, 15, 0); 821 sldMinutes.setPaintLabels(true); 822 sldMinutes.setMajorTickSpacing(5); 823 824 824 // Seconds slider 825 825 lblSeconds = new JLabel(); 826 sldSeconds = new JSlider(-60, 60, 0); 827 sldSeconds.setPaintLabels(true); 828 sldSeconds.setMajorTickSpacing(30); 829 826 sldSeconds = new JSlider(-60, 60, 0); 827 sldSeconds.setPaintLabels(true); 828 sldSeconds.setMajorTickSpacing(30); 829 830 830 // Put everything together 831 831 JPanel p = new JPanel(new GridBagLayout()); … … 839 839 p.add(lblSeconds, GBC.eol().fill()); 840 840 p.add(sldSeconds, GBC.eol().fill()); 841 841 842 842 // If there's an error in the calculation the found values 843 843 // will be off range for the sliders. Catch this error … … 849 849 } catch(Exception e) { 850 850 JOptionPane.showMessageDialog(Main.parent, 851 tr("An error occur ed while trying to match the photos to the GPX track."851 tr("An error occurred while trying to match the photos to the GPX track." 852 852 +" You can adjust the sliders to manually match the photos."), 853 853 tr("Matching photos to track failed"), 854 854 JOptionPane.WARNING_MESSAGE); 855 855 } 856 856 857 857 // Call the sliderListener once manually so labels get adjusted 858 858 new sliderListener().stateChanged(null); … … 862 862 sldMinutes.addChangeListener(new sliderListener()); 863 863 sldSeconds.addChangeListener(new sliderListener()); 864 864 865 865 // There is no way to cancel this dialog, all changes get applied 866 866 // immediately. Therefore "Close" is marked with an "OK" icon. 867 // Settings are only saved temporarily to the layer. 867 // Settings are only saved temporarily to the layer. 868 868 int answer = new ExtendedDialog(Main.parent, 869 869 tr("Adjust timezone and offset"), … … 872 872 new String[] { "ok.png", "dialogs/refresh.png"} 873 873 ).getValue(); 874 874 875 875 // User wants default values; discard old result and re-open dialog 876 876 if(answer == 2) { … … 879 879 } 880 880 } 881 881 882 882 /** 883 883 * Returns a list of images that fulfill the given criteria. … … 913 913 } 914 914 } 915 915 916 916 Collections.sort(dateImgLst, new Comparator<ImageEntry>() { 917 917 public int compare(ImageEntry arg0, ImageEntry arg1) { … … 919 919 } 920 920 }); 921 921 922 922 return dateImgLst; 923 923 } … … 966 966 // Time between the track point and the previous one, 5 sec if first point, i.e. photos take 967 967 // 5 sec before the first track point can be assumed to be take at the starting position 968 long interval = prevDateWp > 0 ? ((int)Math.abs(curDateWp - prevDateWp)) : 5; 968 long interval = prevDateWp > 0 ? ((int)Math.abs(curDateWp - prevDateWp)) : 5; 969 969 int ret = 0; 970 971 // i is the index of the timewise last photo that has the same or earlier EXIF time 970 971 // i is the index of the timewise last photo that has the same or earlier EXIF time 972 972 int i = getLastIndexOfListBefore(dateImgLst, curDateWp); 973 973 974 974 // no photos match 975 if (i < 0) 976 return 0; 977 975 if (i < 0) 976 return 0; 977 978 978 Double speed = null; 979 979 Double prevElevation = null; 980 980 Double curElevation = null; 981 981 982 982 if (prevWp != null) { 983 983 double distance = getDistance(prevWp, curWp); 984 984 // This is in km/h, 3.6 * m/s 985 985 if (curDateWp > prevDateWp) 986 speed = 3.6 * distance / (curDateWp - prevDateWp); 986 speed = 3.6 * distance / (curDateWp - prevDateWp); 987 987 try { 988 988 prevElevation = new Double((String) prevWp.attr.get("ele")); 989 989 } catch(Exception e) {} 990 990 } 991 991 992 992 try { 993 993 curElevation = new Double((String) curWp.attr.get("ele")); 994 994 } catch (Exception e) {} 995 996 // First trackpoint, then interval is set to five seconds, i.e. photos up to five seconds 997 // before the first point will be geotagged with the starting point 995 996 // First trackpoint, then interval is set to five seconds, i.e. photos up to five seconds 997 // before the first point will be geotagged with the starting point 998 998 if(prevDateWp == 0 || curDateWp <= prevDateWp) { 999 999 while(i >= 0 && (dateImgLst.get(i).time.getTime()/1000) <= curDateWp 1000 1000 && (dateImgLst.get(i).time.getTime()/1000) >= (curDateWp - interval)) { 1001 if(dateImgLst.get(i).coor == null) { 1001 if(dateImgLst.get(i).coor == null) { 1002 1002 dateImgLst.get(i).pos = curWp.eastNorth; 1003 1003 dateImgLst.get(i).coor = Main.proj.eastNorth2latlon(dateImgLst.get(i).pos); … … 1025 1025 dateImgLst.get(i).coor = Main.proj.eastNorth2latlon(dateImgLst.get(i).pos); 1026 1026 dateImgLst.get(i).speed = speed; 1027 1027 1028 1028 if (curElevation != null && prevElevation != null) 1029 1029 dateImgLst.get(i).elevation = interpolate(prevElevation, curElevation, timeDiff); 1030 1030 1031 1031 ret++; 1032 1032 } … … 1046 1046 if(lstSize == 0 || searchedDate < dateImgLst.get(0).time.getTime()/1000) 1047 1047 return -1; 1048 1048 1049 1049 // The search period is later than the last photo 1050 1050 if (searchedDate > dateImgLst.get(lstSize - 1).time.getTime() / 1000) 1051 return lstSize-1; 1051 return lstSize-1; 1052 1052 1053 1053 // The searched index is somewhere in the middle, do a binary search from the beginning … … 1055 1055 int startIndex= 0; 1056 1056 int endIndex= lstSize-1; 1057 while (endIndex - startIndex > 1) { 1057 while (endIndex - startIndex > 1) { 1058 1058 curIndex= (int) Math.round((double)(endIndex + startIndex)/2); 1059 1059 if (searchedDate > dateImgLst.get(curIndex).time.getTime()/1000) … … 1064 1064 if (searchedDate < dateImgLst.get(endIndex).time.getTime()/1000) 1065 1065 return startIndex; 1066 1067 // This final loop is to check if photos with the exact same EXIF time follows 1066 1067 // This final loop is to check if photos with the exact same EXIF time follows 1068 1068 while ((endIndex < (lstSize-1)) && (dateImgLst.get(endIndex).time.getTime() 1069 1069 == dateImgLst.get(endIndex + 1).time.getTime())) -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r15707 r15960 496 496 if (this.lambertZone != currentLambertZone) { 497 497 JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+ 498 " 498 "incompatible with current Lambert zone {1}", 499 499 this.lambertZone+1, currentLambertZone), tr("Cache Lambert Zone Error"), JOptionPane.ERROR_MESSAGE); 500 500 return false; -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java
r13497 r15960 94 94 public OsbDialog(final OsbPlugin plugin) { 95 95 super(tr("Open OpenStreetBugs"), "icon_error22", 96 tr("Open the OpenStreetBugs window and activatethe automatic download"), Shortcut.registerShortcut(96 tr("Opens the OpenStreetBugs window and activates the automatic download"), Shortcut.registerShortcut( 97 97 "view:openstreetbugs", tr("Toggle: {0}", tr("Open OpenStreetBugs")), KeyEvent.VK_O, 98 98 Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT), 150); -
applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/JoinAreasAction.java
r14356 r15960 193 193 DataSet.fireSelectionChanged(Main.ds.getSelected()); 194 194 } else 195 JOptionPane.showMessageDialog(Main.parent, tr("No intersection sfound. Nothing was changed."));195 JOptionPane.showMessageDialog(Main.parent, tr("No intersection found. Nothing was changed.")); 196 196 } 197 197 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Help_WMSmenuAction.java
r13497 r15960 12 12 13 13 /** 14 * 14 * 15 15 */ 16 16 17 17 18 18 public Help_WMSmenuAction() { 19 19 //super("Help / About"); 20 20 super(tr("help"), "help", tr("Help / About"), null, false); 21 21 22 22 } 23 23 24 24 public void actionPerformed(ActionEvent e) { 25 //todo - put this into a txt file? 26 String helptext = 25 //todo - put this into a txt file? 26 String helptext = 27 27 tr("You can add, edit and delete WMS entries in the WMSplugin Preference Tab - " + 28 28 "these will then show up in the WMS menu.\n\n"+ 29 29 30 30 "You can also do this manually in the Advanced Preferences, using the following schema:\n"+ 31 31 "wmsplugin.url.1.name=Landsat\n"+ 32 32 "wmsplugin.url.1.url=http://onearth.jpl.nasa.gov....\n"+ 33 33 "wmsplugin.url.2.name=NPE Maps... etc\n\n"+ 34 34 35 35 "Full WMS URL input format example (landsat)\n"+ 36 36 "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&\n"+ 37 "layers=global_mosaic&styles=&srs=EPSG:4326&\n"+ 38 "format=image/jpeg \n\n"+ 39 37 "layers=global_mosaic&styles=&srs=EPSG:4326&format=image/jpeg\n\n"+ 38 40 39 "For Metacarta's Map Rectifier http://labs.metacarta.com/rectifier/ , you only need to input the relevant 'id'.\n" + 41 "To add a Metacarta Map Rectifier menu item, manually create the URL like in this example, " +42 "replacing 73 with your image id: 40 "To add a Metacarta Map Rectifier menu item, manually create the URL like in this example, " + 41 "replacing 73 with your image id:\n" + 43 42 "http://labs.metacarta.com/rectifier/wms.cgi?id=73\n" + 44 "&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png\n " +45 " \n" + 43 "&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png\n\n" + 44 46 45 "Note: Make sure the image is suitable, copyright-wise, if in doubt, don't use."); 47 46 48 47 JTextPane tp = new JTextPane(); 49 48 JScrollPane js = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 50 49 JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 51 52 50 51 53 52 js.getViewport().add(tp); 54 53 JFrame jf = new JFrame(tr("WMS Plugin Help")); … … 56 55 jf.pack(); 57 56 jf.setSize(400,500); 58 jf.setVisible(true); 57 jf.setVisible(true); 59 58 tp.setText(helptext); 60 59 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java
r13584 r15960 1 package wmsplugin; 1 package wmsplugin; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 25 25 26 26 public WMSAdjustAction(MapFrame mapFrame) { 27 super(tr("Adjust WMS"), "adjustwms", 28 tr("Adjust the position of the selected WMS layer"), mapFrame, 27 super(tr("Adjust WMS"), "adjustwms", 28 tr("Adjust the position of the selected WMS layer"), mapFrame, 29 29 ImageProvider.getCursor("normal", "move")); 30 30 } … … 45 45 if (e.getButton() != MouseEvent.BUTTON1) 46 46 return; 47 47 48 48 Layer layer=Main.map.mapView.getActiveLayer(); 49 49 if (layer.visible && layer instanceof WMSLayer) { … … 63 63 Main.map.mapView.getEastNorth(e.getX(),e.getY()); 64 64 selectedLayer.displace( 65 eastNorth.east()-prevEastNorth.east(), 65 eastNorth.east()-prevEastNorth.east(), 66 66 eastNorth.north()-prevEastNorth.north() 67 67 ); … … 74 74 Main.map.mapView.repaint(); 75 75 Main.map.mapView.setCursor(Cursor.getDefaultCursor()); 76 selectedImage = null; 76 selectedImage = null; 77 77 prevEastNorth = null; 78 78 selectedLayer = null; … … 88 88 @Override public void mouseClicked(MouseEvent e) { 89 89 } 90 90 91 91 // This only makes the buttons look disabled, but since no keyboard shortcut is 92 92 // provided there aren't any other means to activate this tool
Note:
See TracChangeset
for help on using the changeset viewer.