Commit 59484e86 authored by Daniel Eggert's avatar Daniel Eggert
Browse files

added csv2db class stump

parent ee427b28
package de.potsdam.gfz.gms.metadatacrawler;
import java.nio.file.Paths;
import java.sql.ResultSet;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import de.potsdam.gfz.gms.database.SceneDatabase;
public class LandsatCollection1CsvUpdate {
// browseAvailable,browseURL,sceneID,LANDSAT_PRODUCT_ID,sensor,acquisitionDate,dateUpdated,path,row,upperLeftCornerLatitude,upperLeftCornerLongitude,upperRightCornerLatitude,upperRightCornerLongitude,lowerLeftCornerLatitude,lowerLeftCornerLongitude,lowerRightCornerLatitude,lowerRightCornerLongitude,sceneCenterLatitude,sceneCenterLongitude,cloudCover,cloudCoverFull,dayOrNight,sunElevation,sunAzimuth,receivingStation,sceneStartTime,sceneStopTime,imageQuality1,DATA_TYPE_L1,cartURL,ROLL_ANGLE,GEOMETRIC_RMSE_MODEL,GEOMETRIC_RMSE_MODEL_X,GEOMETRIC_RMSE_MODEL_Y,FULL_PARTIAL_SCENE,NADIR_OFFNADIR,PROCESSING_SOFTWARE_VERSION,CPF_NAME,RLUT_FILE_NAME,BPF_NAME_OLI,BPF_NAME_TIRS,GROUND_CONTROL_POINTS_MODEL,GROUND_CONTROL_POINTS_VERSION,DATE_L1_GENERATED,TIRS_SSM_MODEL,COLLECTION_NUMBER,COLLECTION_CATEGORY,CLOUD_COVER_LAND
public static void main(String[] args) throws Throwable {
// get all entityids for L8C1 from database as well as from the csv file
SceneDatabase db = SceneDatabase.getInstance();
ResultSet rs = db.placeCustomQuery("select entityid from scenes where datasetid=250;");
Set<String> dbEntityIds = new HashSet<>();
while (rs.next()) {
String entityid = rs.getString(1);
dbEntityIds.add(entityid.substring(0, entityid.length() - 2));
}
System.out.println(dbEntityIds.size() + " scenes in db");
// Set<String> csvEntityIds = new HashSet<>();
int matchCount = 0;
int noMatchCount = 0;
Scanner s = new Scanner(Paths.get("/home/eggert/Downloads/LANDSAT_8_C1.csv"));
// skip header
s.nextLine();
while (s.hasNext()) {
String[] lineSplit = s.nextLine().split(",");
String entityid = lineSplit[2];
entityid = entityid.substring(0, entityid.length() - 2);
if (dbEntityIds.contains(entityid)) {
// match found
dbEntityIds.remove(entityid);
++matchCount;
} else {
// csvEntityIds.add(entityid);
++noMatchCount;
}
}
s.close();
System.out.println(dbEntityIds.size() + " unmatched scenes in db");
System.out.println(noMatchCount + " unmatched scenes in csv");
System.out.println(matchCount + " matching scenes in db and csv");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment