Changeset 3365 in josm for trunk/src/org


Ignore:
Timestamp:
2010-07-07T19:18:19+02:00 (14 years ago)
Author:
bastiK
Message:

see #5220 - Timestamp and GPS tags fail to load from HTC Tattoo images

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r3310 r3365  
    517517    private static void extractExif(ImageEntry e) {
    518518
     519        int deg;
     520        double min, sec;
     521        double lon, lat;
     522        Metadata metadata = null;
     523        Directory dir = null;
     524       
    519525        try {
    520             int deg;
    521             double min, sec;
    522             double lon, lat;
    523 
    524             Metadata metadata = JpegMetadataReader.readMetadata(e.getFile());
    525             Directory dir = metadata.getDirectory(GpsDirectory.class);
    526 
     526            metadata = JpegMetadataReader.readMetadata(e.getFile());
     527            dir = metadata.getDirectory(GpsDirectory.class);
     528        } catch (CompoundException p) {
     529            e.setExifCoor(null);
     530            e.setPos(null);
     531            return;
     532        }
     533       
     534        try {
    527535            // longitude
    528536
     
    553561            }
    554562
    555 
    556             // compass direction value
    557 
    558             Rational direction = null;
    559            
    560             try {
    561                 direction = dir.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);
    562             } catch (CompoundException p) {
    563                 direction = null;
    564             }
    565 
    566563            // Store values
    567564
    568565            e.setExifCoor(new LatLon(lat, lon));
    569566            e.setPos(e.getExifCoor());
    570             if (direction != null) {
    571                 e.setExifImgDir(direction.doubleValue());
    572             }
    573567
    574568        } catch (CompoundException p) {
    575             e.setExifCoor(null);
    576             e.setPos(null);
    577         }
     569            // Try to read lon/lat as double value (Nonstandard, created by some cameras -> #5220)
     570            try {
     571                Double longitude = dir.getDouble(GpsDirectory.TAG_GPS_LONGITUDE);
     572                Double latitude = dir.getDouble(GpsDirectory.TAG_GPS_LATITUDE);
     573                if (longitude == null || latitude == null)
     574                    throw new CompoundException("");
     575
     576                // Store values
     577
     578                e.setExifCoor(new LatLon(latitude, longitude));
     579                e.setPos(e.getExifCoor());
     580            } catch (CompoundException ex) {
     581                e.setExifCoor(null);
     582                e.setPos(null);
     583            }
     584        }
     585
     586        // compass direction value
     587
     588        Rational direction = null;
     589       
     590        try {
     591            direction = dir.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);
     592        } catch (CompoundException p) {
     593            direction = null;
     594        }
     595        if (direction != null) {
     596            e.setExifImgDir(direction.doubleValue());
     597        }
     598
    578599    }
    579600
     
    605626
    606627    public void checkPreviousNextButtons() {
    607         //        System.err.println("showing image " + currentPhoto);
    608628        ImageViewerDialog.setNextEnabled(currentPhoto < data.size() - 1);
    609629        ImageViewerDialog.setPreviousEnabled(currentPhoto > 0);
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r3336 r3365  
    204204        osmWriter.footer();
    205205        osmWriter.out.flush();
    206         return swriter.toString();
     206        String s = swriter.toString();
     207        System.err.println("OsmApi/toXml:\n"+s+"_|");
     208        return s;
    207209    }
    208210
  • trunk/src/org/openstreetmap/josm/io/OsmChangeBuilder.java

    r3083 r3365  
    130130
    131131    public String getDocument() {
    132         return swriter.toString();
     132        String s = swriter.toString();
     133        System.err.println("OsmChangeBuilder/getDocument:\n"+s+"_|");
     134        return s;
    133135    }
    134136}
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r2990 r3365  
    8888    /**
    8989     * Like {@link #get(String)}, but does not throw and return <code>null</code> in case of nothing
    90      * is found. Use this, if the image to retrieve is optional.
     90     * is found. Use this, if the image to retrieve is optional. Nevertheless a warning will
     91     * be printed on the console if the image could not be found.
    9192     */
    9293    public static ImageIcon getIfAvailable(Collection<String> dirs, String id, String subdir, String name) {
     
    9495    }
    9596
     97    /**
     98     * The full path of the image is either a url (starting with http://)
     99     * or something like
     100     *   dirs.get(i)+"/"+subdir+"/"+name+".png".
     101     * @param dirs      Directories to look.
     102     * @param id        An id used for caching. Id is not used for cache if name starts with http://. (URL is unique anyway.)
     103     * @param subdir    Subdirectory the image lies in.
     104     * @param name      The name of the image. If it contains no '.', a png extension is added.
     105     * @param archive   A zip file where the image is located.
     106     */
    96107    public static ImageIcon getIfAvailable(Collection<String> dirs, String id, String subdir, String name, File archive) {
    97108        if (name == null)
Note: See TracChangeset for help on using the changeset viewer.