UCAR Library
This commit is contained in:
parent
8d8005f0c0
commit
05ff46dc6f
36
.classpath
36
.classpath
|
@ -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>
|
|
|
@ -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
|
|
43
pom.xml
43
pom.xml
|
@ -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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -96,6 +97,36 @@
|
||||||
<artifactId>sis-netcdf</artifactId>
|
<artifactId>sis-netcdf</artifactId>
|
||||||
<version>${sis.utils.modules}</version>
|
<version>${sis.utils.modules}</version>
|
||||||
</dependency>
|
</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 -->
|
<!-- TEST -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -117,11 +148,19 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.opengis</groupId>
|
||||||
|
<artifactId>geoapi-conformance</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
|
|
@ -21,48 +21,71 @@ import org.gcube.data.transfer.plugins.thredds.sis.SisPlugin;
|
||||||
public class TestGetMetadata {
|
public class TestGetMetadata {
|
||||||
|
|
||||||
public static void main(String[] args) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
|
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",
|
||||||
|
};
|
||||||
|
|
||||||
File temp=File.createTempFile("temp", ".temp");
|
for(String f:toCheckFiles) {
|
||||||
File original=new File("/home/fabio/Downloads/oscar_vel2011_180.nc");
|
System.out.println("checking "+f);
|
||||||
File copied=File.createTempFile("copied", ".nc");
|
check(false,f);
|
||||||
transferStream(new FileInputStream(original),new FileOutputStream(temp));
|
}
|
||||||
System.out.println("copied. Moving..");
|
System.out.println("Done");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void check(boolean checkCopy,String src) throws UnsupportedStorageException, DataStoreException, IOException, NoSuchAlgorithmException {
|
||||||
|
|
||||||
|
File original=new File(src);
|
||||||
|
|
||||||
System.out.println("Checksum original : "+getChecksum(original));
|
File dataset=original;
|
||||||
System.out.println("Checksum temp : "+getChecksum(temp));
|
|
||||||
|
|
||||||
|
if(checkCopy) {
|
||||||
|
File temp=File.createTempFile("temp", ".temp");
|
||||||
Files.move(temp.toPath(), copied.toPath(),StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING);
|
File copied=File.createTempFile("copied", ".nc");
|
||||||
if(copied.length()<original.length()) throw new RuntimeException("Different size after moving");
|
transferStream(new FileInputStream(original),new FileOutputStream(temp));
|
||||||
System.out.println(SisPlugin.getMetaFromFile(copied));
|
System.out.println("copied. Moving..");
|
||||||
|
|
||||||
|
System.out.println("Checksum original : "+getChecksum(original));
|
||||||
|
System.out.println("Checksum temp : "+getChecksum(temp));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Files.move(temp.toPath(), copied.toPath(),StandardCopyOption.ATOMIC_MOVE,StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
if(copied.length()<original.length()) throw new RuntimeException("Different size after moving");
|
||||||
|
|
||||||
|
dataset=copied;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println(SisPlugin.getMetaFromFile(dataset));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static String getChecksum(File datafile) throws NoSuchAlgorithmException, IOException {
|
private static String getChecksum(File datafile) throws NoSuchAlgorithmException, IOException {
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA1");
|
MessageDigest md = MessageDigest.getInstance("SHA1");
|
||||||
FileInputStream fis = new FileInputStream(datafile);
|
FileInputStream fis = new FileInputStream(datafile);
|
||||||
byte[] dataBytes = new byte[1024];
|
byte[] dataBytes = new byte[1024];
|
||||||
|
|
||||||
int nread = 0;
|
int nread = 0;
|
||||||
|
|
||||||
while ((nread = fis.read(dataBytes)) != -1) {
|
while ((nread = fis.read(dataBytes)) != -1) {
|
||||||
md.update(dataBytes, 0, nread);
|
md.update(dataBytes, 0, nread);
|
||||||
};
|
};
|
||||||
|
|
||||||
byte[] mdbytes = md.digest();
|
byte[] mdbytes = md.digest();
|
||||||
|
|
||||||
//convert the byte to hex format
|
//convert the byte to hex format
|
||||||
StringBuffer sb = new StringBuffer("");
|
StringBuffer sb = new StringBuffer("");
|
||||||
for (int i = 0; i < mdbytes.length; i++) {
|
for (int i = 0; i < mdbytes.length; i++) {
|
||||||
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
|
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void transferStream(InputStream in, OutputStream out){
|
private static void transferStream(InputStream in, OutputStream out){
|
||||||
|
|
||||||
|
@ -74,12 +97,12 @@ public class TestGetMetadata {
|
||||||
while ((received=in.read(internalBuf))!=-1){
|
while ((received=in.read(internalBuf))!=-1){
|
||||||
out.write(internalBuf,0,received);
|
out.write(internalBuf,0,received);
|
||||||
receivedTotal+=received;
|
receivedTotal+=received;
|
||||||
|
|
||||||
}
|
}
|
||||||
out.flush();
|
out.flush();
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
throw new RuntimeException("Unable to read from source.");
|
throw new RuntimeException("Unable to read from source.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue