-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GeoTIFF test using sample data from OSGEO/libgeotiff
- Loading branch information
Showing
50 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Geotiff_Information: | ||
Version: 1 | ||
Key_Revision: 1.0 | ||
Tagged_Information: | ||
ModelTiepointTag (2,3): | ||
50.5 50.5 0 | ||
9.00105738 52.001376 0 | ||
ModelPixelScaleTag (1,3): | ||
2.77777778e-005 2.77777778e-005 1 | ||
End_Of_Tags. | ||
Keyed_Information: | ||
GTModelTypeGeoKey (Short,1): ModelTypeGeographic | ||
GTRasterTypeGeoKey (Short,1): RasterPixelIsArea | ||
GeographicTypeGeoKey (Short,1): User-Defined | ||
GeogGeodeticDatumGeoKey (Short,1): User-Defined | ||
GeogAngularUnitsGeoKey (Short,1): Angular_Degree | ||
GeogEllipsoidGeoKey (Short,1): Ellipse_Bessel_1841 | ||
Unknown-2062 (Double,7): 598.1 73.7 418.2 | ||
0.202 0.045 -2.455 | ||
6.7 | ||
End_Of_Keys. | ||
End_Of_Geotiff. | ||
|
||
Ellipsoid: 7004/(unknown) (0.00,0.00) | ||
|
||
Corner Coordinates: | ||
Upper Left ( 8d59'58.76"E, 52d 0'10.00"N) | ||
Lower Left ( 8d59'58.76"E, 51d59'59.90"N) | ||
Upper Right ( 9d 0' 8.86"E, 52d 0'10.00"N) | ||
Lower Right ( 9d 0' 8.86"E, 51d59'59.90"N) | ||
Center ( 9d 0' 3.81"E, 52d 0' 4.95"N) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
GeogToWGS84GeoKey5.tif is an sample GeoTIFF file for the GeogToWGS84GeoKey | ||
geo key. After datum transformation to the WGS84 reference system the center | ||
of the image (marked by a red pixel) should be exactly at N 52° E 9° in a | ||
geographic coordinate system. | ||
|
||
The output of listgeo is included as GeogToWGS84GeoKey5.lgo. | ||
|
||
The files are placed in the public domain. | ||
|
||
Christian Zietz <czietz@gmx.net> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_2046_transverse_mercator_south_oriented.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_27200_new_zealand_mapping_grid.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_28191_cassini_soldner.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_3032_polar_stereographic_variant_b.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_3035_lambert_azimuthal_equal_area.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_3083_albers_equal_area.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_3410_lambert_cylindrical_equal_area.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_3814_transverse_mercator.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_4087_equidistant_cylindrical.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_5482_polar_stereographic_variant_a.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_5588_oblique_stereographic.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_6808_hotine_oblique_mercator_variant_a.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_8065_hotine_oblique_mercator_variant_b.tif
Binary file not shown.
Binary file added
BIN
+288 Bytes
Tests/Data/libgeotiff/ProjectedCSTypeGeoKey_8441_oblique_mercator_laborde.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright 2002-2022 Drew Noakes and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* More information about this project is available at: | ||
* | ||
* https://drewnoakes.com/code/exif/ | ||
* https://github.com/drewnoakes/metadata-extractor | ||
*/ | ||
package com.drew.metadata.geotiff; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
import java.io.FilenameFilter; | ||
import java.util.Objects; | ||
|
||
import org.junit.Test; | ||
|
||
import com.drew.imaging.tiff.TiffMetadataReader; | ||
import com.drew.metadata.Metadata; | ||
import com.drew.metadata.exif.ExifDirectoryBase; | ||
import com.drew.metadata.exif.ExifIFD0Directory; | ||
|
||
public class GeoTiffTest { | ||
|
||
@Test | ||
public void testGeogToWGS84GeoKey5() throws Exception { | ||
Metadata metadata = TiffMetadataReader.readMetadata(new File("Tests/Data/GeogToWGS84GeoKey5.tif")); | ||
assertNotNull(metadata); | ||
|
||
ExifIFD0Directory exif = checkExif(metadata, 24); | ||
|
||
assertEquals("[32 values]", exif.getDescription(ExifDirectoryBase.TAG_GEOTIFF_GEO_KEYS)); | ||
assertEquals("[768 values]", exif.getDescription(ExifDirectoryBase.TAG_COLOR_MAP)); | ||
assertEquals("0 0 1", exif.getDescription(ExifDirectoryBase.TAG_PIXEL_SCALE)); | ||
assertEquals("50.5 50.5 0 9.001 52.001 0", exif.getDescription(ExifDirectoryBase.TAG_MODEL_TIE_POINT).replace(',', '.')); | ||
assertNull(exif.getDescription(ExifDirectoryBase.TAG_GEOTIFF_GEO_ASCII_PARAMS)); | ||
assertNull(exif.getDescription(ExifDirectoryBase.TAG_GEOTIFF_GEO_DOUBLE_PARAMS)); | ||
assertNull(exif.getDescription(ExifDirectoryBase.TAG_GDAL_METADATA)); | ||
assertNull(exif.getDescription(ExifDirectoryBase.TAG_GDAL_NO_DATA)); | ||
|
||
GeoTiffDirectory geotiff = checkGeoTiff(metadata); | ||
|
||
assertEquals("Geographic", geotiff.getDescription(GeoTiffDirectory.TAG_MODEL_TYPE)); | ||
assertEquals("PixelIsArea", geotiff.getDescription(GeoTiffDirectory.TAG_RASTER_TYPE)); | ||
assertEquals("User Defined", geotiff.getDescription(GeoTiffDirectory.TAG_GEOGRAPHIC_TYPE)); | ||
assertEquals("User Defined", geotiff.getDescription(GeoTiffDirectory.TAG_GEODETIC_DATUM)); | ||
assertEquals("Angular Degree", geotiff.getDescription(GeoTiffDirectory.TAG_GEOGRAPHIC_ANGULAR_UNITS)); | ||
assertEquals("Bessel 1841", geotiff.getDescription(GeoTiffDirectory.TAG_GEOGRAPHIC_ELLIPSOID)); | ||
assertEquals("598.1 73.7 418.2 0.202 0.045 -2.455 6.7", geotiff.getDescription(GeoTiffDirectory.TAG_GEOGRAPHIC_TO_WGS84).replace(',', '.')); | ||
assertEquals(7, geotiff.getTagCount()); | ||
} | ||
|
||
@Test | ||
public void testLibgeotiff() throws Exception { | ||
for (File tiffFile : new File("Tests/Data/libgeotiff").listFiles(new FilenameFilter() { | ||
@Override | ||
public boolean accept(File dir, String name) { | ||
return name.endsWith(".tif"); | ||
} | ||
})) | ||
{ | ||
Metadata metadata = TiffMetadataReader.readMetadata(tiffFile); | ||
assertNotNull(tiffFile.getName(), metadata); | ||
checkExif(metadata, 14); | ||
String description = tiffFile.getName() + "\n " + checkGeoTiff(metadata).getTags(); | ||
assertFalse(description, description.contains("Unknown")); | ||
} | ||
} | ||
|
||
private static ExifIFD0Directory checkExif(Metadata metadata, int numberOfTags) { | ||
ExifIFD0Directory exif = metadata.getDirectoriesOfType(ExifIFD0Directory.class).iterator().next(); | ||
assertNotNull(exif); | ||
assertFalse(Objects.toString(exif.getErrors()), exif.hasErrors()); | ||
assertEquals(numberOfTags, exif.getTagCount()); | ||
return exif; | ||
} | ||
|
||
private static GeoTiffDirectory checkGeoTiff(Metadata metadata) { | ||
GeoTiffDirectory geotiff = metadata.getDirectoriesOfType(GeoTiffDirectory.class).iterator().next(); | ||
assertNotNull(geotiff); | ||
assertFalse(Objects.toString(geotiff.getErrors()), geotiff.hasErrors()); | ||
assertTrue(geotiff.getTagCount() > 0); | ||
return geotiff; | ||
} | ||
} |