UCAR Library

This commit is contained in:
Fabio Sinibaldi 2021-03-03 16:14:22 +01:00
parent 8d8005f0c0
commit 05ff46dc6f
4 changed files with 92 additions and 71 deletions

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,5 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

41
pom.xml
View File

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -96,6 +97,36 @@
<artifactId>sis-netcdf</artifactId>
<version>${sis.utils.modules}</version>
</dependency>
<dependency>
<groupId>org.apache.sis.storage</groupId>
<artifactId>sis-earth-observation</artifactId>
<version>${sis.utils.modules}</version>
</dependency>
<dependency>
<groupId>org.apache.sis.storage</groupId>
<artifactId>sis-geotiff</artifactId>
<version>${sis.utils.modules}</version>
</dependency>
<!-- EPSG Dataset. NB Check Performances -->
<dependency>
<groupId>org.apache.sis.non-free</groupId>
<artifactId>sis-embedded-data</artifactId>
<version>${sis.version}</version>
<scope>runtime</scope>
</dependency>
<!-- UCAR Library used by SIS if embedded can't decode -->
<!-- https://mvnrepository.com/artifact/edu.ucar/netcdf -->
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>netcdf</artifactId>
<version>4.3.22</version>
</dependency>
<!-- TEST -->
<dependency>
@ -117,6 +148,14 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opengis</groupId>
<artifactId>geoapi-conformance</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -21,9 +21,26 @@ import org.gcube.data.transfer.plugins.thredds.sis.SisPlugin;
public class TestGetMetadata {
public static void main(String[] args) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
String[] toCheckFiles=new String[] {
"/Users/FabioISTI/Downloads/Aaptos_aaptos.nc",
"/Users/FabioISTI/Downloads/NASA_Precipitations_1950_2100_rcp45.nc",
};
for(String f:toCheckFiles) {
System.out.println("checking "+f);
check(false,f);
}
System.out.println("Done");
}
private static void check(boolean checkCopy,String src) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
File original=new File(src);
File dataset=original;
if(checkCopy) {
File temp=File.createTempFile("temp", ".temp");
File original=new File("/home/fabio/Downloads/oscar_vel2011_180.nc");
File copied=File.createTempFile("copied", ".nc");
transferStream(new FileInputStream(original),new FileOutputStream(temp));
System.out.println("copied. Moving..");
@ -35,12 +52,18 @@ public class TestGetMetadata {
Files.move(temp.toPath(), copied.toPath(),StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING);
if(copied.length()<original.length()) throw new RuntimeException("Different size after moving");
System.out.println(SisPlugin.getMetaFromFile(copied));
dataset=copied;
}
System.out.println(SisPlugin.getMetaFromFile(dataset));
}
private static String getChecksum(File datafile) throws NoSuchAlgorithmException, IOException {
MessageDigest md = MessageDigest.getInstance("SHA1");
FileInputStream fis = new FileInputStream(datafile);