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


Java GeoLocation类代码示例

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


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

示例1: nacti

import com.drew.lang.GeoLocation; //导入依赖的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.lang.GeoLocation; //导入依赖的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: getGeoLocation

import com.drew.lang.GeoLocation; //导入依赖的package包/类
/**
 * Parses various tags in an attempt to obtain a single object representing the latitude and longitude
 * at which this image was captured.
 *
 * @return The geographical location of this image, if possible, otherwise null
 */
@Nullable
public GeoLocation getGeoLocation()
{
    Rational[] latitudes = getRationalArray(TAG_LATITUDE);
    Rational[] longitudes = getRationalArray(TAG_LONGITUDE);
    String latitudeRef = getString(TAG_LATITUDE_REF);
    String longitudeRef = getString(TAG_LONGITUDE_REF);

    // Make sure we have the required values
    if (latitudes == null || latitudes.length != 3)
        return null;
    if (longitudes == null || longitudes.length != 3)
        return null;
    if (latitudeRef == null || longitudeRef == null)
        return null;

    Double lat = GeoLocation.degreesMinutesSecondsToDecimal(latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S"));
    Double lon = GeoLocation.degreesMinutesSecondsToDecimal(longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W"));

    // This can return null, in cases where the conversion was not possible
    if (lat == null || lon == null)
        return null;

    return new GeoLocation(lat, lon);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:32,代码来源:GpsDirectory.java

示例4: getGeoLocation

import com.drew.lang.GeoLocation; //导入依赖的package包/类
/**
 * Parses various tags in an attempt to obtain a single object representing the latitude and longitude
 * at which this image was captured.
 *
 * @return The geographical location of this image, if possible, otherwise null
 */
@Nullable
public GeoLocation getGeoLocation()
{
    Rational[] latitudes = getRationalArray(GpsDirectory.TAG_LATITUDE);
    Rational[] longitudes = getRationalArray(GpsDirectory.TAG_LONGITUDE);
    String latitudeRef = getString(GpsDirectory.TAG_LATITUDE_REF);
    String longitudeRef = getString(GpsDirectory.TAG_LONGITUDE_REF);

    // Make sure we have the required values
    if (latitudes == null || latitudes.length != 3)
        return null;
    if (longitudes == null || longitudes.length != 3)
        return null;
    if (latitudeRef == null || longitudeRef == null)
        return null;

    Double lat = GeoLocation.degreesMinutesSecondsToDecimal(latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S"));
    Double lon = GeoLocation.degreesMinutesSecondsToDecimal(longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W"));

    // This can return null, in cases where the conversion was not possible
    if (lat == null || lon == null)
        return null;

    return new GeoLocation(lat, lon);
}
 
开发者ID:byronb92,项目名称:ImageEXIFExtraction,代码行数:32,代码来源:GpsDirectory.java

示例5: nactiKdyzUmis

import com.drew.lang.GeoLocation; //导入依赖的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

示例6: getGeoLocation

import com.drew.lang.GeoLocation; //导入依赖的package包/类
/**
 * Parses various tags in an attempt to obtain a single object representing the latitude and longitude
 * at which this image was captured.
 *
 * @return The geographical location of this image, if possible, otherwise null
 */
@Nullable
public GeoLocation getGeoLocation()
{
    Rational[] latitudes = getRationalArray(GpsDirectory.TAG_GPS_LATITUDE);
    Rational[] longitudes = getRationalArray(GpsDirectory.TAG_GPS_LONGITUDE);
    String latitudeRef = getString(GpsDirectory.TAG_GPS_LATITUDE_REF);
    String longitudeRef = getString(GpsDirectory.TAG_GPS_LONGITUDE_REF);

    // Make sure we have the required values
    if (latitudes == null || latitudes.length != 3)
        return null;
    if (longitudes == null || longitudes.length != 3)
        return null;
    if (latitudeRef == null || longitudeRef == null)
        return null;

    Double lat = GeoLocation.degreesMinutesSecondsToDecimal(latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S"));
    Double lon = GeoLocation.degreesMinutesSecondsToDecimal(longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W"));

    // This can return null, in cases where the conversion was not possible
    if (lat == null || lon == null)
        return null;

    return new GeoLocation(lat, lon);
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:32,代码来源:GpsDirectory.java

示例7: handle

import com.drew.lang.GeoLocation; //导入依赖的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

示例8: PhotoLocation

import com.drew.lang.GeoLocation; //导入依赖的package包/类
public PhotoLocation(final GeoLocation location, final File file)
{
    this.location = location;
    this.file = file;
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:6,代码来源:GeoTagMapBuilder.java

示例9: testGeoLocation

import com.drew.lang.GeoLocation; //导入依赖的package包/类
@Test
public void testGeoLocation() throws IOException, MetadataException
{
    Metadata metadata = ExifReaderTest.processBytes("Tests/Data/withExifAndIptc.jpg.app1.0");

    GpsDirectory gpsDirectory = metadata.getFirstDirectoryOfType(GpsDirectory.class);
    assertNotNull(gpsDirectory);
    GeoLocation geoLocation = gpsDirectory.getGeoLocation();
    assertEquals(54.989666666666665, geoLocation.getLatitude(), 0.001);
    assertEquals(-1.9141666666666666, geoLocation.getLongitude(), 0.001);
}
 
开发者ID:drewnoakes,项目名称:metadata-extractor,代码行数:12,代码来源:ExifDirectoryTest.java

示例10: getGpsLatitudeDescription

import com.drew.lang.GeoLocation; //导入依赖的package包/类
@Nullable
public String getGpsLatitudeDescription()
{
    GeoLocation location = _directory.getGeoLocation();

    if (location == null)
        return null;

    return GeoLocation.decimalToDegreesMinutesSecondsString(location.getLatitude());
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:11,代码来源:GpsDescriptor.java

示例11: getGpsLongitudeDescription

import com.drew.lang.GeoLocation; //导入依赖的package包/类
@Nullable
public String getGpsLongitudeDescription()
{
    GeoLocation location = _directory.getGeoLocation();

    if (location == null)
        return null;

    return GeoLocation.decimalToDegreesMinutesSecondsString(location.getLongitude());
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:11,代码来源:GpsDescriptor.java

示例12: getDegreesMinutesSecondsDescription

import com.drew.lang.GeoLocation; //导入依赖的package包/类
@Nullable
public String getDegreesMinutesSecondsDescription()
{
    GeoLocation location = _directory.getGeoLocation();

    if (location == null)
        return null;

    return location.toDMSString();
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:11,代码来源:GpsDescriptor.java

示例13: handleGpsDirectory

import com.drew.lang.GeoLocation; //导入依赖的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

示例14: testSample

import com.drew.lang.GeoLocation; //导入依赖的package包/类
@Test
public void testSample() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    final Map<String, Object> metadata = sample.getMetadata();
    Assert.assertNotNull(metadata.get(IptcPreProcessor.KEYWORDS));
    Assert.assertEquals("2016-09-24 16:11:00", metadata.get(IptcPreProcessor.DATE));
    Assert.assertEquals(new GeoLocation(48d, 2d), metadata.get(GpsPreProcessor.GEOLOCATION));

    Assert.assertEquals("Commentaire utilisateur", PropertyUtils.getProperty(metadata.get("ExifSubIFD"), "UserComment"));
    Assert.assertEquals("20mm", PropertyUtils.getProperty(metadata.get("ExifSubIFD"), "LensModel"));
    Assert.assertEquals("0000000000", PropertyUtils.getProperty(metadata.get("ExifSubIFD"), "LensSerialNumber"));
    Assert.assertEquals("Description", PropertyUtils.getProperty(metadata.get("ExifIFD0"), "ImageDescription"));

    Assert.assertEquals("Canon", PropertyUtils.getProperty(metadata.get("ExifIFD0"), "Make"));
    Assert.assertEquals("Canon EOS 60D", PropertyUtils.getProperty(metadata.get("ExifIFD0"), "Model"));
    Assert.assertEquals("Édouard Hue", PropertyUtils.getProperty(metadata.get("ExifIFD0"), "Artist"));
    Assert.assertEquals("Édouard Hue", PropertyUtils.getProperty(metadata.get("ExifIFD0"), "Copyright"));

    Assert.assertEquals("Titre", PropertyUtils.getProperty(metadata.get("IPTC"), "ObjectName"));
    Assert.assertEquals("Édouard Hue", PropertyUtils.getProperty(metadata.get("IPTC"), "Byline"));
    Assert.assertEquals("Q1", PropertyUtils.getProperty(metadata.get("IPTC"), "Sublocation"));
    Assert.assertEquals("Édouard Hue", PropertyUtils.getProperty(metadata.get("IPTC"), "CopyrightNotice"));
    Assert.assertEquals("Description", PropertyUtils.getProperty(metadata.get("IPTC"), "CaptionAbstract"));

    Assert.assertEquals("20mm", PropertyUtils.getProperty(metadata.get("XMP"), "Lens"));
    Assert.assertEquals("1280614195", PropertyUtils.getProperty(metadata.get("XMP"), "SerialNumber"));

    Assert.assertEquals("https://creativecommons.org/licenses/by-sa/4.0/", PropertyUtils.getProperty(metadata.get("Photoshop"), "URL"));
}
 
开发者ID:edouardhue,项目名称:comeon,代码行数:29,代码来源:MediaTest.java

示例15: of

import com.drew.lang.GeoLocation; //导入依赖的package包/类
public static Location of(GeoLocation geoLocation) {
  return of((float) geoLocation.getLatitude(), (float) geoLocation.getLongitude());
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:4,代码来源:Location.java


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