本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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));
}
示例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();
}
}
示例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())));
}
}
示例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());
}
}
示例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;
}
}
}
}
示例9: getGpsDirectory
import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
public GpsDirectory getGpsDirectory() {
return mGpsDirectory;
}
示例10: supports
import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
public boolean supports(Class<? extends Directory> directoryType) {
return directoryType == GpsDirectory.class;
}
示例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);
}
示例12: getSupportedClass
import com.drew.metadata.exif.GpsDirectory; //导入依赖的package包/类
@Override
public Class<? extends Directory> getSupportedClass() {
return GpsDirectory.class;
}
示例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));
}