当前位置: 首页>>代码示例>>Java>>正文


Java GpsDirectory类代码示例

本文整理汇总了Java中com.drew.metadata.exif.GpsDirectory的典型用法代码示例。如果您正苦于以下问题:Java GpsDirectory类的具体用法?Java GpsDirectory怎么用?Java GpsDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GpsDirectory类属于com.drew.metadata.exif包,在下文中一共展示了GpsDirectory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nacti

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
@Override
protected void nacti(final InputStream istm, final String name, final IImportBuilder builder, final Future<?> future) throws IOException {
	if (future.isCancelled()) {
		return;
	}
	BufferedInputStream bis;
	if (istm instanceof BufferedInputStream) {
		bis = (BufferedInputStream) istm;
	} else {
		bis = new BufferedInputStream(istm);
	}
	Metadata imageMetadata;
	try {
		imageMetadata = ImageMetadataReader.readMetadata(bis, true);
	} catch (final ImageProcessingException e) {
		log.error("The input stream for file " + name + "couldn't be loaded!", e);
		return;
	}
	final GpsDirectory gpsDirectory = imageMetadata.getDirectory(GpsDirectory.class);
	if (gpsDirectory == null) {
		log.info("Image has no GPS metadata.");
		return;
	}
	final GeoLocation exifLocation = gpsDirectory.getGeoLocation();
	if (exifLocation != null) {
		final GpxWpt gpxWpt = new GpxWpt();
		gpxWpt.wgs = new Wgs(exifLocation.getLatitude(), exifLocation.getLongitude());
		gpxWpt.name = Iterables.getLast(Arrays.asList(name.split(Pattern.quote(File.separator))), "");
		gpxWpt.link.href = name;
		gpxWpt.desc = "EXIF coordinates";
		gpxWpt.type = "pic";
		gpxWpt.sym = "Photo";
		builder.addGpxWpt(gpxWpt);
	} else {
		log.info("Image {} has GPS metadata, but no lat/lon information.", name);
	}
}
 
开发者ID:marvertin,项目名称:geokuk,代码行数:38,代码来源:NacitacImageMetadata.java

示例2: getLocation

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
/**
 * Checks for known Location in metadata
 *  
 * @param metadata {@link Metadata} read from a file
 * @return A {@link GeoLocation} object if successful, null otherwise
 */
public static GeoLocation getLocation(Metadata metadata) {
		
	if(metadata == null) {
		System.err.println("Metadata is null");
		return null;
	}
	
	GeoLocation geoLocation = null;
	
	// TODO:nics-247 Handle case where multiple GPS directories exist?
	GpsDirectory geoDir = metadata.getFirstDirectoryOfType(GpsDirectory.class);
	
	if(geoDir != null) {
		geoLocation = geoDir.getGeoLocation();
	} else
	{
		System.err.println("GeoLocation is null!");
	}
	
	return geoLocation;
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:28,代码来源:ImageProcessor.java

示例3: nactiKdyzUmis

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
@Override
protected void nactiKdyzUmis(InputStream istm, String jmeno, IImportBuilder builder, Future<?> future)
    throws IOException {
  if (!VALID_FILENAME_REGEX.matcher(jmeno).matches()) {
    return;
  }
  BufferedInputStream bis;
  if (istm instanceof BufferedInputStream) {
    bis = (BufferedInputStream) istm;
  } else {
    bis = new BufferedInputStream(istm);
  }
  Metadata imageMetadata;
  try {
    imageMetadata = ImageMetadataReader.readMetadata(bis, true);
  } catch (ImageProcessingException e) {
    log.error("The input stream with name " + jmeno + " couldn't be loaded!", e);
    return;
  }
  GpsDirectory gpsDirectory = imageMetadata.getDirectory(GpsDirectory.class);
  if (gpsDirectory == null) {
    log.info("Image {} has no GPS metadata.", jmeno);
    return;
  }
  GeoLocation exifLocation = gpsDirectory.getGeoLocation();
  if (exifLocation != null) {
    GpxWpt gpxWpt = new GpxWpt();
    gpxWpt.wgs = new Wgs(exifLocation.getLatitude(), exifLocation.getLongitude());
    gpxWpt.name = Iterables.getLast(Arrays.asList(jmeno.split(Pattern.quote(File.separator))), "");
    gpxWpt.link.href = jmeno;
    gpxWpt.desc = "EXIF coordinates";
    gpxWpt.type = "pic";
    gpxWpt.sym = "Photo";
    builder.addGpxWpt(gpxWpt);
  } else {
    log.info("Image {} has GPS metadata, but no lat/lon information.", jmeno);
  }
}
 
开发者ID:Danstahr,项目名称:Geokuk,代码行数:39,代码来源:NacitacImageMetadata.java

示例4: testSetAndGetMultipleTagsInMultilpeDirectories

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
public void testSetAndGetMultipleTagsInMultilpeDirectories() throws Exception
{
    Metadata metadata = new Metadata();
    Directory exifDir = metadata.getDirectory(ExifDirectory.class);
    Directory gpsDir = metadata.getDirectory(GpsDirectory.class);
    exifDir.setString(ExifDirectory.TAG_APERTURE, "ExifAperture");
    exifDir.setString(ExifDirectory.TAG_BATTERY_LEVEL, "ExifBatteryLevel");
    gpsDir.setString(GpsDirectory.TAG_GPS_ALTITUDE, "GpsAltitude");
    gpsDir.setString(GpsDirectory.TAG_GPS_DEST_BEARING, "GpsDestBearing");
    assertEquals("ExifAperture", exifDir.getString(ExifDirectory.TAG_APERTURE));
    assertEquals("ExifBatteryLevel", exifDir.getString(ExifDirectory.TAG_BATTERY_LEVEL));
    assertEquals("GpsAltitude", gpsDir.getString(GpsDirectory.TAG_GPS_ALTITUDE));
    assertEquals("GpsDestBearing", gpsDir.getString(GpsDirectory.TAG_GPS_DEST_BEARING));
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:15,代码来源:MetadataTest.java

示例5: getJpegData

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
protected void getJpegData(byte[] toMatch, int i, List<Integer> offsets, int resultIndex) {
    try {
        Metadata reader = JpegMetadataReader
                .readMetadata(new ByteArrayInputStream(Arrays.copyOfRange(toMatch, i - offsets.get(resultIndex), toMatch.length)));
        ExifIFD0Directory info = reader.getFirstDirectoryOfType(ExifIFD0Directory.class);
        String cameraMake = null;
        String cameraModel = null;
        if (info != null) {
            cameraMake = info.getString(ExifDirectoryBase.TAG_MAKE);
            cameraModel = info.getString(ExifDirectoryBase.TAG_MODEL);
        }
        for (Directory dir : reader.getDirectoriesOfType(GpsDirectory.class)) {
            GpsDescriptor descriptor = new GpsDescriptor((GpsDirectory) dir);

            Map<String, String> gpsInfoDict = new LinkedHashMap<>();
            gpsInfoDict.put("Camera Make: ", cameraMake);
            gpsInfoDict.put("Camera Model: ", cameraModel);
            gpsInfoDict.put("Latitude: ", tagOrEmpty(descriptor.getGpsLatitudeDescription()));
            gpsInfoDict.put("Longitude: ", tagOrEmpty(descriptor.getGpsLongitudeDescription()));
            gpsInfoDict.put("Altitude: ", descriptor.getGpsAltitudeDescription());
            gpsInfoDict.put("Altitude Reference: ", descriptor.getGpsAltitudeRefDescription());
            gpsInfoDict.put("Timestamp: ", descriptor.getGpsTimeStampDescription());

            if (notEmptyGPS(descriptor.getGpsLatitudeDescription(), descriptor.getGpsLongitudeDescription())) {
                logGPS(gpsInfoDict);
                wasGPSFound = true;
            }

        }

    }
    catch (IOException | ImageProcessingException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:36,代码来源:MagicCarver.java

示例6: handle

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
public void handle(Directory directory, Metadata metadata) throws MetadataException {
    GeoLocation geoLocation = ((GpsDirectory) directory).getGeoLocation();
    if (geoLocation != null) {
        DecimalFormat geoDecimalFormat = new DecimalFormat(GEO_DECIMAL_FORMAT_STRING,
                new DecimalFormatSymbols(Locale.ENGLISH));
        metadata.set(TikaCoreProperties.LATITUDE, geoDecimalFormat.format(new Double(geoLocation.getLatitude())));
        metadata.set(TikaCoreProperties.LONGITUDE, geoDecimalFormat.format(new Double(geoLocation.getLongitude())));
    }
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:10,代码来源:ImageMetadataExtractor.java

示例7: handleGpsDirectory

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
private void handleGpsDirectory(MetaData metaData, Directory directory) throws MetadataException{
		
	GpsDirectory gd = (GpsDirectory)directory;
	GeoLocation geoLocation = gd.getGeoLocation();

	if (geoLocation != null){
		metaData.put(Image.MetaName.GpsLongitude, geoLocation.getLongitude());
		metaData.put(Image.MetaName.GpsLatitude, geoLocation.getLatitude());
	}
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:11,代码来源:ExifMetaDataPaser.java

示例8: extractMetadataFeatures

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
/**
 * @param node
 * @param exifTag
 */
public void extractMetadataFeatures(IIOMetadataNode node)
{
  NodeList unknownElements = node.getElementsByTagName(EXIF_ELEMENT_TAG_NAME);
  for (int i = 0; i < unknownElements.getLength(); i++)
  {
    IIOMetadataNode foundUnknownNode = (IIOMetadataNode) unknownElements.item(i);
    if ("225".equals(foundUnknownNode.getAttribute("MarkerTag")))
    {
      boolean dated = false;
      byte[] exifSegment = (byte[]) foundUnknownNode.getUserObject();

      final com.drew.metadata.Metadata exifMetadata = new com.drew.metadata.Metadata();
      new ExifReader(exifSegment).extract(exifMetadata);
      com.drew.metadata.Directory exifDir = exifMetadata.getDirectory(ExifDirectory.class);

      Image image = getDocument();
      boolean mixedIn = image.containsMixin(MM_TAG_CAMERA_SETTINGS);
      if (!mixedIn && !GisFeatures.containsGisMixin(image))
      {
        if (!dated && ORIG_DATE_FEATURE.extract(image, exifDir) == null)
        {
          dated = true;
          DATE_FEATURE.extract(image, exifDir);
        }
        if (!mixedIn && CAMERA_MODEL_FEATURE.getStringValue(exifDir) != null)
        {
          mixedIn = true;
          extractMixin(exifDir, EXIF_METADATA_FEATURES, MM_TAG_CAMERA_SETTINGS);
        }
        com.drew.metadata.Directory gpsDir = exifMetadata.getDirectory(GpsDirectory.class);
        Metadata gpsMixin = GisFeatures.extractMixin(gpsDir, getSemanticsScope(), image);
        Iterator<com.drew.metadata.Tag> gpsList = printDirectory(gpsDir);
        int qq = 33;
      }
    }
  }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:42,代码来源:ImageParserAwt.java

示例9: getGpsDirectory

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
public GpsDirectory getGpsDirectory() {
    return mGpsDirectory;
}
 
开发者ID:trixon,项目名称:java-mapollage,代码行数:4,代码来源:PhotoInfo.java

示例10: supports

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
public boolean supports(Class<? extends Directory> directoryType) {
    return directoryType == GpsDirectory.class;
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:4,代码来源:ImageMetadataExtractor.java

示例11: process

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
@Override
public void process(final Directory directory, final Map<String, Object> metadata) {
    final GeoLocation geolocation = ((GpsDirectory) directory).getGeoLocation();
    metadata.put(GEOLOCATION, geolocation);
}
 
开发者ID:edouardhue,项目名称:comeon,代码行数:6,代码来源:GpsPreProcessor.java

示例12: getSupportedClass

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
@Override
public Class<? extends Directory> getSupportedClass() {
    return GpsDirectory.class;
}
 
开发者ID:edouardhue,项目名称:comeon,代码行数:5,代码来源:GpsPreProcessor.java

示例13: ofExif

import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
/**
 * Extracts the GPS data from the given file by reading the available Exif data. In particular,
 * latitude, longitude, date and time stamp are read from the file.
 *
 * @param file file to extract exif data from
 * @return an object containing the extracted information, if available, otherwise an
 *         empty object.
 */
public static GpsData ofExif(Path file) {
  Optional<GpsDirectory> gps = MetadataUtil.getMetadataDirectoryOfType(file, GpsDirectory.class);
  Optional<Location> location = gps.map(GpsDirectory::getGeoLocation).map(Location::of);
  Optional<Instant> instant = gps.map(GpsDirectory::getGpsDate).map(Date::toInstant);
  return ofData(location.orElse(null), instant.orElse(null));
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:15,代码来源:GpsData.java


注:本文中的com.drew.metadata.exif.GpsDirectory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。