public static Geopoint getFirstGeopoint(final Metadata metadata) {
        return safeProcess("geopoint", metadata, null, () -> {
            final Collection<GpsDirectory> gpsDirectories = metadata.getDirectoriesOfType(GpsDirectory.class);
            if (gpsDirectories == null) {
                return null;
            }

            for (final GpsDirectory gpsDirectory : gpsDirectories) {
                // Try to read out the location, making sure it's non-zero
                final GeoLocation geoLocation = gpsDirectory.getGeoLocation();
                if (geoLocation != null && !geoLocation.isZero()) {
                    return new Geopoint(geoLocation.getLatitude(), geoLocation.getLongitude());
                }
            }
            return null;
        });
    }
Tries to read metadata from given stream, assuming it is an image data stream

@param description describes the stream. Used for logging in case of errors
@param imageStream image data stream
@param closeAfter  if true, stream is closed after read
@return Metadata read, or null if metadata could not be read
main/src/main/java/cgeo/geocaching/utils/MetadataUtils.java