Gianpaolo Coro 2013-07-19 09:57:05 +00:00
parent ab02a49369
commit 6ed47d5a45
12 changed files with 523 additions and 21 deletions

View File

@ -27,14 +27,19 @@ import org.gcube.dataanalysis.ecoengine.interfaces.DataAnalysis;
import org.gcube.dataanalysis.ecoengine.utils.DatabaseUtils;
import org.gcube.dataanalysis.ecoengine.utils.IOHelper;
import org.gcube.dataanalysis.geo.insertion.RasterTable;
import org.gcube.dataanalysis.geo.meta.OGCFormatter;
import org.gcube.dataanalysis.geo.meta.features.FeaturesManager;
import org.gcube.dataanalysis.geo.retrieval.GeoIntersector;
import org.gcube.dataanalysis.geo.utils.ThreddsDataExplorer;
import org.jfree.chart.JFreeChart;
import org.jfree.data.function.NormalDistributionFunction2D;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.xy.XYSeriesCollection;
import org.opengis.metadata.Metadata;
import ucar.nc2.dt.GridDatatype;
import ucar.nc2.dt.grid.GridDataset;
public class MapsComparator extends DataAnalysis {
static String layer1 = "Layer_1";
@ -94,18 +99,21 @@ public class MapsComparator extends DataAnalysis {
try {
// delete this force
// String scope = config.getGcubeScope();
String scope = ScopeProvider.instance.get();
// String scope = "/gcube";
String scope = config.getGcubeScope();
if (scope == null)
scope = ScopeProvider.instance.get();
// scope = "/gcube";
// String scope = null;
AnalysisLogger.getLogger().debug("MapsComparator: Using Scope: " + scope + " Z: " + z + " Values Threshold: " + valuesthreshold + " Layer1: " + layerT1 + " vs " + layerT2);
GeoIntersector intersector = new GeoIntersector(scope, config.getConfigPath());
AnalysisLogger.getLogger().debug("MapsComparator: GeoIntersector initialized");
double x1 = -180;
double x2 = 180;
double y1 = -90;
double y2 = 90;
status = 10;
FeaturesManager fm = intersector.getFeaturer();
AnalysisLogger.getLogger().debug("MapsComparator: Taking info for the layer: " + layerT1);
@ -118,6 +126,21 @@ public class MapsComparator extends DataAnalysis {
AnalysisLogger.getLogger().debug("MapsComparator: Undefined resolution");
}
AnalysisLogger.getLogger().debug("MapsComparator: Resolution: " + resolution1);
if (fm.isThreddsFile(meta1)){
AnalysisLogger.getLogger().debug("MapsComparator: recalculating the spatial extent of the comparison");
String fileurl = fm.getOpenDapLink(meta1);
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(fileurl);
List<GridDatatype> gridTypes = gds.getGrids();
GridDatatype gdt = gridTypes.get(0);
x1 = ThreddsDataExplorer.getMinX(gdt.getCoordinateSystem());
x2 = ThreddsDataExplorer.getMaxX(gdt.getCoordinateSystem());
y1 = ThreddsDataExplorer.getMinY(gdt.getCoordinateSystem());
y2 = ThreddsDataExplorer.getMaxY(gdt.getCoordinateSystem());
}
AnalysisLogger.getLogger().debug("MapsComparator: Spatial extent of the comparison: x1: "+x1+" x2: "+x2+" y1: "+y1+" y2: "+y2);
status = 15;
AnalysisLogger.getLogger().debug("MapsComparator: Taking info for the layer: " + layerT2);
AnalysisLogger.getLogger().debug("MapsComparator: Trying with UUID..." + layerT2);
@ -134,9 +157,14 @@ public class MapsComparator extends DataAnalysis {
status = 20;
// take the lowest resolution to perform the comparison
double resolution = Math.max(resolution1, resolution2);
AnalysisLogger.getLogger().debug("MapsComparator: Theoretical Resolution: " + resolution);
if (resolution == 0)
resolution = 0.5d;
AnalysisLogger.getLogger().debug("MapsComparator: Evaluation Resolution: " + resolution);
// I added the following control to limit the amount of calculations
if (resolution<0.01)
resolution = 0.01d;
AnalysisLogger.getLogger().debug("MapsComparator: Evaluation Indeed at Resolution: " + resolution);
AnalysisLogger.getLogger().debug("MapsComparator: ****Rasterizing map 1****");
double[][] slice1 = intersector.takeTimeSlice(layerT1, time1, x1, x2, y1, y2, z, resolution, resolution);

View File

@ -0,0 +1,132 @@
package org.gcube.dataanalysis.geo.batch;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.gcube.dataanalysis.geo.meta.GenericLayerMetadata;
import org.gcube.dataanalysis.geo.meta.OGCFormatter;
import org.gcube.dataanalysis.geo.utils.ThreddsDataExplorer;
import org.opengis.metadata.identification.TopicCategory;
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.dt.GridDatatype;
import ucar.nc2.dt.grid.GridDataset;
public class EnvriMetadataInsertDev {
// static String geonetworkurl = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/";
static String geonetworkurl = "http://geoserver-last.d4science-ii.research-infrastructures.eu/geonetwork/";
/*
static String geonetworkurl = "http://geonetwork.d4science.org/geonetwork/";
static String geoserverurl = "http://geoserver.d4science-ii.research-infrastructures.eu/geoserver";
*/
//static String geoserverurl = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver";
static String user = "admin";
static String password = "admin";
static String[] envrilayers = {
"geo_filt_070620-070725-sim_HDR_4rlks.nc",
"geo_filt_070620-070829-sim_HDR_4rlks.nc",
"geo_filt_070620-071003-sim_HDR_4rlks.nc",
"geo_filt_070620-071107-sim_HDR_4rlks.nc",
"geo_filt_070620-071212-sim_HDR_4rlks.nc",
"geo_filt_070620-080326-sim_HDR_4rlks.nc",
"geo_filt_070620-080604-sim_HDR_4rlks.nc",
"geo_filt_070620-080709-sim_HDR_4rlks.nc",
"geo_filt_070620-080813-sim_HDR_4rlks.nc",
"geo_filt_070620-080917-sim_HDR_4rlks.nc",
"geo_filt_070620-081022-sim_HDR_4rlks.nc",
"geo_filt_070620-081231-sim_HDR_4rlks.nc"};
static String threddsbaseURL= "thredds.d4science.org";
static String threddsURL = "http://"+threddsbaseURL+"/thredds/catalog/public/netcdf/catalog.xml";
public static void main(String[] args) throws Exception{
for (int i=1;i<envrilayers.length+1;i++) {
envriEtnalayers(i);
// break;
}
}
//gebco
private static void envriEtnalayers(int index) throws Exception{
GenericLayerMetadata metadataInserter = new GenericLayerMetadata();
metadataInserter.setGeonetworkUrl(geonetworkurl);
metadataInserter.setGeonetworkUser(user);
metadataInserter.setGeonetworkPwd(password);
String title = "Etna Volcano SAR Analysis ";
String filename = envrilayers[index-1];
String layername = "band_1";
int minusInt = filename.indexOf("-");
int minusInt2 = filename.lastIndexOf("-");
String datastart = filename.substring("geo_filt_".length(),minusInt);
String dataend = filename.substring(minusInt,minusInt2);
System.out.println("DataStart: "+datastart);
System.out.println("DataEnd: "+dataend);
metadataInserter.setTitle(title+index);
metadataInserter.setCategoryTypes("_"+TopicCategory.ENVIRONMENT.name()+"_");
metadataInserter.setResolution(0.0083);
metadataInserter.setAbstractField("SAR analysis of the Etna volcano. Produced by the Istituto Nazionale di Geofisica e Vulcanologia (INGV). Hosted on the D4Science Thredds Catalog: "+threddsURL);
metadataInserter.setCustomTopics("D4Science","ENVRI","Etna","SAR Analysis","Istituto Nazionale di Geofisica e Vulcanologia","INGV","Thredds");
metadataInserter.setAuthor("D4Science");
String url = OGCFormatter.getOpenDapURL(threddsURL, filename);
System.out.println("URL "+url);
GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(url);
List<GridDatatype> gridTypes = gds.getGrids();
GridDatatype gdt = gridTypes.get(0);
double minX = ThreddsDataExplorer.getMinX(gdt.getCoordinateSystem());
double maxX = ThreddsDataExplorer.getMaxX(gdt.getCoordinateSystem());
double minY = ThreddsDataExplorer.getMinY(gdt.getCoordinateSystem());
double maxY = ThreddsDataExplorer.getMaxY(gdt.getCoordinateSystem());
System.out.println("minX: "+minX+" minY: "+minY+" maxX:"+maxX+" maxY:"+maxY);
String wms = OGCFormatter.getWmsNetCDFUrl(url, layername, OGCFormatter.buildBoundingBox(minX, minY, maxX, maxY)).replace("width=676", "width=640").replace("height=330", "height=480");
System.out.println("WMS "+wms);
String wcs = OGCFormatter.getWcsNetCDFUrl(url, layername, OGCFormatter.buildBoundingBox(minX, minY, maxX, maxY)).replace("width=676", "width=640").replace("height=330", "height=480");
System.out.println("WCS "+wcs);
String [] urls = {"http://thredds.research-infrastructures.eu/thredds/fileServer/public/netcdf/"+filename,wms,wcs,url};
String [] protocols = {"HTTP","WMS","WCS","OPeNDAP"};
DateFormat formatter = new SimpleDateFormat("yyMMdd");
Date datestart = formatter.parse(datastart);
Date dateend = formatter.parse(dataend);
metadataInserter.setStartDate(datestart);
metadataInserter.setEndDate(dateend);
metadataInserter.setXLeftLow(minX);
metadataInserter.setYLeftLow(minY);
metadataInserter.setXRightUpper(maxX);
metadataInserter.setYRightUpper(maxY);
CoordinateAxis xAxis = gdt.getCoordinateSystem().getXHorizAxis();
CoordinateAxis yAxis = gdt.getCoordinateSystem().getYHorizAxis();
double resolutionX = Math.abs((double) (xAxis.getMaxValue() - xAxis.getMinValue()) / (double) xAxis.getShape()[0]);
double resolutionY = Math.abs((double) (yAxis.getMaxValue() - yAxis.getMinValue()) / (double) yAxis.getShape()[0]);
metadataInserter.setResolution(Math.max(resolutionX, resolutionY));
System.out.println("Resolution: "+Math.max(resolutionX, resolutionY));
metadataInserter.customMetaDataInsert(urls,protocols);
}
}

View File

@ -8,7 +8,7 @@ public class ThreddsMetadataBatchInserter {
public static void main(String[] args) throws Exception{
AnalysisLogger.setLogger("./cfg/"+AlgorithmConfiguration.defaultLoggerFile);
ThreddsFetcher tf = new ThreddsFetcher(null);
ThreddsFetcher tf = new ThreddsFetcher("/gcube/devsec");
tf.fetch("http://thredds.research-infrastructures.eu/thredds/catalog/public/netcdf/catalog.xml");
}
}

View File

@ -0,0 +1,49 @@
package org.gcube.dataanalysis.geo.batch;
import org.gcube.dataanalysis.geo.meta.GenericLayerMetadata;
import org.gcube.dataanalysis.geo.meta.NetCDFMetadata;
import org.opengis.metadata.identification.TopicCategory;
public class WorldClimMetadataInsertDev {
static String geonetworkurl = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/";
/*
static String geonetworkurl = "http://geonetwork.d4science.org/geonetwork/";
static String geoserverurl = "http://geoserver.d4science-ii.research-infrastructures.eu/geoserver";
*/
//static String geoserverurl = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver";
static String user = "admin";
static String password = "admin";
public static void main(String[] args) throws Exception{
for (int i=1;i<20;i++) {
worldclim(i);
// break;
}
}
//gebco
private static void worldclim(int index) throws Exception{
GenericLayerMetadata metadataInserter = new GenericLayerMetadata();
metadataInserter.setGeonetworkUrl(geonetworkurl);
metadataInserter.setGeonetworkUser(user);
metadataInserter.setGeonetworkPwd(password);
metadataInserter.setTitle("WorldClimBio"+index);
metadataInserter.setCategoryTypes("_"+TopicCategory.ENVIRONMENT.name()+"_");
metadataInserter.setResolution(0.0083);
metadataInserter.setAbstractField("WorldClim is a set of global climate layers (climate grids) with a spatial resolution of about 1 square kilometer. The data can be used for mapping and spatial modeling in a GIS or with other computer programs. Hijmans, R.J., S.E. Cameron, J.L. Parra, P.G. Jones and A. Jarvis, 2005. Very high resolution interpolated climate surfaces for global land areas. International Journal of Climatology 25: 1965-1978. Hosted on the D4Science Thredds Catalog: http://thredds.research-infrastructures.eu/thredds/catalog/public/netcdf/catalog.xml");
metadataInserter.setCustomTopics("D4Science","EUBrazilOpenBio","WorldClim","WorldClimBio"+index+".tiff","Thredds");
metadataInserter.setAuthor("D4Science");
String [] urls = {"http://thredds.research-infrastructures.eu/thredds/fileServer/public/netcdf/WorldClimBio"+index+".tiff"};
String [] protocols = {"HTTP"};
metadataInserter.customMetaDataInsert(urls,protocols);
}
}

View File

@ -33,7 +33,9 @@ public class ThreddsFetcher {
List<String> filesURL = ThreddsDataExplorer.getFiles(threddsCatalogURL);
for (String filename : filesURL) {
// if (!filename.equalsIgnoreCase("cami_0000-09-01_64x128_L26_c030918.nc"))
if (!filename.endsWith(".nc"))
continue;
// if (!filename.equalsIgnoreCase("geo_filt_070620-070725-sim_HDR_4rlks_CLIMATOLOGY_METEOROLOGY_ATMOSPHERE_.nc"))
// continue;
String url = OGCFormatter.getOpenDapURL(threddsCatalogURL, filename);

View File

@ -78,7 +78,7 @@ public class GenericLayerMetadata {
private String usageLimitations = "Not for commercial scopes";
private Date sourceGenerationDate = new Date(System.currentTimeMillis());
private String categoryTypes = "_BIOTA_";
private String contactInfo = "support@d4science.research-infrastructures.eu";
private String contactInfo = "support@d4science.org";
private String abstractField = "";
private String purpose = "Maps publication";
private String author = "i-Marine";
@ -462,6 +462,182 @@ public class GenericLayerMetadata {
}
public void customMetaDataInsert(String[] urls, String[] protocols) throws Exception {
// layer uri: wms, wfs wcs
List<String> layerUris = new ArrayList<String>();
for (int i=0;i<urls.length;i++)
layerUris.add(urls[i]);
// layer keywords
HashMap<KeywordType, HashSet<String>> descriptiveKeyWords = new HashMap<KeywordType, HashSet<String>>();
HashSet<String> keySet = new HashSet<String>();
if (customTopics!=null)
keySet.addAll(customTopics);
descriptiveKeyWords.put(KeywordType.THEME, keySet);
if (startDate!=null){
HashSet<String> temporalkeySet = new HashSet<String>();
temporalkeySet.add(startDate.toString());
if (!endDate.equals(startDate))
temporalkeySet.add(endDate.toString());
descriptiveKeyWords.put(KeywordType.TEMPORAL, temporalkeySet);
}
// author:
DefaultResponsibleParty party = new DefaultResponsibleParty();
party.setIndividualName(author);
DefaultContact contact = new DefaultContact();
contact.setContactInstructions(new DefaultInternationalString(contactInfo));
party.setContactInfo(contact);
party.setRole(Role.ORIGINATOR);
// citation:
DefaultCitation citation = new DefaultCitation();
citation.setTitle(new DefaultInternationalString(title));
ArrayList<DefaultCitationDate> citDates = new ArrayList<DefaultCitationDate>();
citDates.add(new DefaultCitationDate(sourceGenerationDate, DateType.CREATION));
citDates.add(new DefaultCitationDate(sourceGenerationDate, DateType.PUBLICATION));
citDates.add(new DefaultCitationDate(sourceGenerationDate, DateType.REVISION));
citation.setDates(citDates);
ArrayList<InternationalString> citAltTitle = new ArrayList<InternationalString>();
citAltTitle.add(new DefaultInternationalString(title));
citation.setAlternateTitles(citAltTitle);
citation.setEditionDate(sourceGenerationDate);
citation.getPresentationForms().add(PresentationForm.MAP_DIGITAL);
ArrayList<DefaultKeywords> keywordslist = new ArrayList<DefaultKeywords>();
for (Entry<KeywordType, HashSet<String>> entry : descriptiveKeyWords.entrySet()) {
DefaultKeywords keywords = new DefaultKeywords();
for (String key : entry.getValue())
keywords.getKeywords().add(new DefaultInternationalString(key));
keywords.setType(entry.getKey());
DefaultCitation thesaurus = new DefaultCitation();
thesaurus.setTitle(new DefaultInternationalString("General"));
thesaurus.setDates(citDates);
keywords.setThesaurusName(thesaurus);
keywordslist.add(keywords);
}
// usage:
DefaultUsage usage = new DefaultUsage();
usage.setSpecificUsage(new DefaultInternationalString(usageField));
usage.setUsageDate(sourceGenerationDate);
usage.setUserDeterminedLimitations(new DefaultInternationalString(usageLimitations));
usage.setUserContactInfo(new ArrayList<ResponsibleParty>(Arrays.asList(party)));
ArrayList<DefaultUsage> usages = new ArrayList<DefaultUsage>(Arrays.asList(usage));
//build categories by guessing on the filename
List<TopicCategory> categories = guessTopicCategory(categoryTypes);
AnalysisLogger.getLogger().debug("Guessed Topics: "+categories);
// Spatial Rapresentation Info
DefaultGeometricObjects geoObjs = new DefaultGeometricObjects();
geoObjs.setGeometricObjectType(GeometricObjectType.COMPLEX);
DefaultVectorSpatialRepresentation spatial = new DefaultVectorSpatialRepresentation();
spatial.setTopologyLevel(TopologyLevel.GEOMETRY_ONLY);
spatial.getGeometricObjects().add(geoObjs);
// Extent:
DefaultExtent extent = new DefaultExtent();
extent.setGeographicElements(Collections.singleton(new DefaultGeographicBoundingBox(xLL, xRU, yLL, yRU)));
extent.setDescription(new DefaultInternationalString("Bounding box"));
/*Only with Geotoolkit 4.x
DefaultTemporalExtent stext = new DefaultTemporalExtent(startDate,endDate);
stext.setStartTime(startDate);
stext.setEndTime(endDate);
extent.setTemporalElements(Arrays.asList(stext));
*/
extent.freeze();
//resolution
DefaultNominalResolution resolution = new DefaultNominalResolution();
resolution.setGroundResolution(res);
resolution.setScanningResolution(res);
DefaultResolution dres = new DefaultResolution();
dres.setDistance(res);
// layers access:
DefaultDistribution distribution = new DefaultDistribution();
DefaultDigitalTransferOptions transferOptions = new DefaultDigitalTransferOptions();
for (String uri : layerUris)
transferOptions.getOnLines().add(new DefaultOnlineResource(new URI(uri)));
distribution.getTransferOptions().add(transferOptions);
DefaultFormat [] formats = new DefaultFormat[protocols.length];
for (int i=0;i<protocols.length;i++){
DefaultFormat format = new DefaultFormat();
format.setName(new DefaultInternationalString(protocols[i]));
format.setVersion(new DefaultInternationalString("1.0.0"));
formats[i]=format;
}
distribution.setDistributionFormats(new ArrayList<DefaultFormat>(Arrays.asList(formats)));
// legal constraints
DefaultLegalConstraints constraints = new DefaultLegalConstraints();
constraints.getUseLimitations().add(new DefaultInternationalString("Licensed"));
constraints.getAccessConstraints().add(Restriction.LICENSE);
constraints.getUseConstraints().add(Restriction.LICENSE);
// quality declaration:
DefaultDataQuality processQuality = new DefaultDataQuality();
//citation
DefaultCitation sourceCitation = new DefaultCitation();
sourceCitation.setTitle(new DefaultInternationalString(title));
sourceCitation.getDates().add(new DefaultCitationDate(sourceGenerationDate, DateType.CREATION));
sourceCitation.getIdentifiers().add(new DefaultIdentifier(categoryTypes));
//source
DefaultSource source = new DefaultSource();
source.setResolution(resolution);
source.setDescription(new DefaultInternationalString(title));
source.setSourceCitation(sourceCitation);
// provenance
DefaultProcessStep preprocessStep = new DefaultProcessStep();
DefaultProcessStep processStep = new DefaultProcessStep(preprocessStep);
DefaultProcessing processing = new DefaultProcessing();
processing.setSoftwareReferences(new ArrayList<DefaultCitation>(Arrays.asList(sourceCitation)));
processStep.setDescription(new DefaultInternationalString(processdescription));
DefaultLineage processLineage = new DefaultLineage();
processLineage.setProcessSteps(new ArrayList<ProcessStep>(Arrays.asList(processStep)));
processQuality.setLineage(processLineage);
processQuality.setScope(new DefaultScope(ScopeCode.DATASET));
// fulfill identification
DefaultDataIdentification ident = new DefaultDataIdentification();
ident.setCitation(citation);
ident.setAbstract(new DefaultInternationalString(abstractField));
ident.setPurpose(new DefaultInternationalString(purpose));
ident.getResourceMaintenances().add(new DefaultMaintenanceInformation(MaintenanceFrequency.AS_NEEDED));
ident.setDescriptiveKeywords(keywordslist);
ident.setTopicCategories(categories);
ident.setResourceSpecificUsages(usages);
ident.setExtents(new ArrayList<DefaultExtent>(Arrays.asList(extent)));
ident.setSpatialRepresentationTypes(new ArrayList<SpatialRepresentationType>(Arrays.asList(SpatialRepresentationType.GRID)));
ident.setSpatialResolutions(new ArrayList<DefaultResolution>(Arrays.asList(dres)));
ident.setLanguages(new ArrayList<Locale>(Arrays.asList(Locale.ENGLISH)));
// Metadata Obj:
DefaultMetadata meta = new DefaultMetadata(party, sourceGenerationDate, ident);
meta.getSpatialRepresentationInfo().add(spatial);
meta.setDistributionInfo(distribution);
meta.getMetadataConstraints().add(constraints);
meta.getDataQualityInfo().add(processQuality);
meta.setLanguage(Locale.ENGLISH);
// System.out.println(meta);
GNClient client = new GNClient(geonetworkUrl);
client.login(geonetworkUser, geonetworkPwd);
File tmetafile = meta2File(meta);
client.insertMetadata(new GNInsertConfiguration("3", "datasets", "_none_", true), tmetafile);
tmetafile.delete();
}
public static List<TopicCategory> guessTopicCategory(String refString){
String searcher = refString.toLowerCase();
List<TopicCategory> categories = new ArrayList<TopicCategory>();

View File

@ -81,7 +81,7 @@ public class NetCDFMetadata {
private String contactInfo = "support@d4science.research-infrastructures.eu";
private String abstractField = "T: temperature (degK) from 04091217ruc.nc resident on the THREDDS instance " + threddsCatalogUrl;
private String purpose = "Maps publication";
private String author = "i-Marine";
private String author = "D4Science";
private double res = 0.5d;
private double xLL = -180;
private double xRU = 180;
@ -311,7 +311,7 @@ public class NetCDFMetadata {
HashMap<KeywordType, HashSet<String>> descriptiveKeyWords = new HashMap<KeywordType, HashSet<String>>();
HashSet<String> keySet = new HashSet<String>();
keySet.add("THREDDS");
keySet.add("i-Marine");
keySet.add("D4Science");
keySet.add("NetCDF");
if (customTopics!=null)
keySet.addAll(customTopics);

View File

@ -20,8 +20,8 @@ import org.opengis.metadata.identification.Identification;
import org.opengis.metadata.identification.Resolution;
public class FeaturesManager {
// private String geonetworkUrl = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/";
private String geonetworkUrl = "http://geoserver-last.d4science-ii.research-infrastructures.eu/geonetwork/";
private String geonetworkUrl = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/";
// private String geonetworkUrl = "http://geoserver-last.d4science-ii.research-infrastructures.eu/geonetwork/";
// private String geonetworkUrl = "http://geoserver.d4science-ii.research-infrastructures.eu/geonetwork/";
private String geonetworkUser = "admin";
private String geonetworkPwd = "admin";
@ -107,7 +107,9 @@ public class FeaturesManager {
String link = null;
for (DigitalTransferOptions option : meta.getDistributionInfo().getTransferOptions()) {
for (OnlineResource resource : option.getOnLines()) {
String tlink = resource.getLinkage().toString();
String tlink = "";
try{tlink = resource.getLinkage().toString();}catch(Exception e){}
if (tlink.toLowerCase().contains(criterion.toLowerCase())) {
link = tlink;
break;
@ -126,7 +128,11 @@ public class FeaturesManager {
for (DigitalTransferOptions option : meta.getDistributionInfo().getTransferOptions()) {
for (OnlineResource resource : option.getOnLines()) {
String layername = resource.getName();
if (layername!=null) {
String link = "";
try{
link = resource.getLinkage().toString().toLowerCase();
}catch(Exception e){}
if ((layername!=null)&&link.contains("wms")) {
innerlayername = layername;
break;
}
@ -439,6 +445,7 @@ public class FeaturesManager {
public static String treatTitleForGN(String origLayerTitle) {
String layerTitle = origLayerTitle.toLowerCase();
int idx = layerTitle.indexOf(" from [");
// int idx = layerTitle.indexOf(" "); //let's search among many layers
String layerTitle2 = layerTitle;
if (idx>0)
layerTitle2 = layerTitle.toLowerCase().substring(0, idx).trim();

View File

@ -246,6 +246,7 @@ public class GeoIntersector {
double[][] slice = new double[ysteps + 1][xsteps + 1];
List<Tuple<Double>> tuples = new ArrayList<Tuple<Double>>();
AnalysisLogger.getLogger().debug("Building the points grid according to YRes:" + yResolution + " and XRes:" + xResolution);
AnalysisLogger.getLogger().debug("Points to reassign:" + (ysteps*xsteps));
// build the tuples according to the desired resolution
for (int i = 0; i < ysteps + 1; i++) {
double y = (i * yResolution) + y1;

View File

@ -35,12 +35,46 @@ public class RegressionTestMapsComparison {
config.setParam("DatabaseDriver","org.postgresql.Driver");
// config.setParam("Layer_1","86a7ac79-866a-49c6-b5d5-602fc2d87ddd");
// config.setParam("Layer_2","86a7ac79-866a-49c6-b5d5-602fc2d87ddd");
config.setParam("Layer_1","aeabfdb5-9ddb-495e-b628-5b7d2cf1d8a2");
config.setParam("Layer_2","aeabfdb5-9ddb-495e-b628-5b7d2cf1d8a2");
//World seas : IHO vs Marine regions
// config.setParam("Layer_2","70a6d757-e607-46f7-b643-e21749f45a42");
// config.setParam("Layer_1","a2a8c130-124f-45b5-973f-c9358028a2a6");
//FAO vs FAO:
// config.setParam("Layer_1","b040894b-c5db-47fc-ba9c-d4fafcdcf620"); //goblin shark
// config.setParam("Layer_2","c9a31223-cc00-4acd-bc5b-a0c76a7f79c7"); //humbolt squid
//FAO vs AquaMaps
// config.setParam("Layer_1","b040894b-c5db-47fc-ba9c-d4fafcdcf620");
// config.setParam("Layer_2","c9a31223-cc00-4acd-bc5b-a0c76a7f79c7");
//NetCDF vs NETCDF WOA
config.setParam("Layer_1","e0dbbcc0-8364-4087-8bcb-c7d95b2f55c8"); //statistical mean oxygen
config.setParam("Layer_2","49f5a5a1-80ff-4a00-8c84-dac29bda1a23");//statistical mean phosphate
//NetCDF vs NetCDF MyOcean
// config.setParam("Layer_1","e0dbbcc0-8364-4087-8bcb-c7d95b2f55c8"); //statistical mean oxygen
// config.setParam("Layer_2","fc9ac2f4-a2bd-43d1-a361-ac67c5ceac31");//temperature
//NetCDF vs IHO
// config.setParam("Layer_1","70a6d757-e607-46f7-b643-e21749f45a42");//IHO
// config.setParam("Layer_2","fc9ac2f4-a2bd-43d1-a361-ac67c5ceac31");//temperature
//NetCDF vs NetCDF MyOcean only
// config.setParam("Layer_1","fc9ac2f4-a2bd-43d1-a361-ac67c5ceac31"); //statistical mean oxygen
// config.setParam("Layer_2","fc9ac2f4-a2bd-43d1-a361-ac67c5ceac31");//temperature
//NetCDF vs NetCDF Envri
// config.setParam("Layer_1","Etna Volcano SAR Analysis 1"); //
// config.setParam("Layer_2","Etna Volcano SAR Analysis 7");//
config.setParam("ValuesComparisonThreshold",""+0.1);
config.setParam("Z","0");
config.setGcubeScope(null);
config.setGcubeScope("/gcube");
// config.setGcubeScope(null);
return config;
}
}

View File

@ -10,6 +10,11 @@ import org.gcube.contentmanagement.graphtools.utils.HttpRequest;
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
import org.gcube.dataanalysis.geo.meta.OGCFormatter;
import ucar.ma2.ArrayByte;
import ucar.ma2.ArrayDouble;
import ucar.ma2.Index;
import ucar.ma2.IndexIterator;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
@ -20,6 +25,7 @@ import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.geom.PrecisionModel;
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence;
import com.vividsolutions.jts.geom.util.GeometryTransformer;
import com.vividsolutions.jts.operation.overlay.snap.GeometrySnapper;
public class EnvDataExplorer {
@ -206,18 +212,30 @@ public class EnvDataExplorer {
// cut the holes
List<Polygon> polysnoholes = new ArrayList<Polygon>();
for (Polygon pp : polys) {
boolean found = false;
int h = 0;
for (Polygon polnh : polysnoholes) {
if (polnh.covers(pp)) {
boolean covers = false;
try{
covers = polnh.covers(pp);
}catch(Exception e){
AnalysisLogger.getLogger().debug("Error in calculating superpositions: Snapping the geometries");
double snapTol = GeometrySnapper.computeOverlaySnapTolerance(polnh, pp);
pp = (Polygon) selfSnap(pp,snapTol);
polnh = (Polygon) selfSnap(polnh,snapTol);
AnalysisLogger.getLogger().debug("Geometries have been snapped");
covers = polnh.covers(pp);
}
if (covers) {
// System.out.println("found hole! "+pp+" vs "+polnh);
addDifference(h, polysnoholes, polnh, pp);
found = true;
} else if (pp.covers(polnh)) {
// polysnoholes.set(h, (Polygon) pp.difference(polnh));
addDifference(h, polysnoholes, pp, polnh);
found = true;
}
h++;
@ -232,6 +250,17 @@ public class EnvDataExplorer {
return p;
}
private static Geometry selfSnap(Geometry g, double snapTolerance)
{
GeometrySnapper snapper = new GeometrySnapper(g);
Geometry snapped = snapper.snapTo(g, snapTolerance);
// need to "clean" snapped geometry - use buffer(0) as a simple way to do this
Geometry fix = snapped.buffer(0);
return fix;
}
private static void addDifference(int h , List<Polygon> polysnoholes, Polygon polnh, Polygon pp){
Geometry mp = polnh.difference(pp);
@ -327,6 +356,45 @@ public class EnvDataExplorer {
}
}
public static ArrayDouble.D3 arrayByte3DArrayDouble(ArrayByte bytes){
int[] shapeD = bytes.getShape();
int zD=shapeD[0];
int yD=shapeD[1];
int xD=shapeD[2];
AnalysisLogger.getLogger().debug(xD+"X"+yD+"X"+zD+"="+(xD*yD*zD));
ArrayDouble.D3 doublea = new ArrayDouble.D3(zD, yD,xD);
IndexIterator iterator = bytes.getIndexIterator();
for (int x=0;x<xD;x++){
for (int y=0;y<yD;y++){
for (int z=0;z<zD;z++){
Byte bytex = (Byte)iterator.next();
doublea.set(z,y,x,bytex.doubleValue());
}
}
}
return doublea;
}
public static ArrayDouble.D2 arrayByte2DArrayDouble(ArrayByte bytes){
int[] shapeD = bytes.getShape();
int yD=shapeD[0];
int xD=shapeD[1];
AnalysisLogger.getLogger().debug(xD+"X"+yD+"="+(xD*yD));
ArrayDouble.D2 doublea = new ArrayDouble.D2(yD,xD);
IndexIterator iterator = bytes.getIndexIterator();
for (int x=0;x<xD;x++){
for (int y=0;y<yD;y++){
Byte bytex = (Byte)iterator.next();
doublea.set(y,x,bytex.doubleValue());
}
}
return doublea;
}
public static void main(String[] args) {
String q = "[[[-10.0011869534696,151.288335840039],[-10.0353384533966,151.27859643813],[-10.0228061679999,151.308700562],[-10.0011869534696,151.288335840039]]], e3c47901-3de5-45d2-a272-c6f7d5df1dec=[[[-8.54674625399991,150.53036499],[-8.83403205899992,150.287445068],[-9.20889866086486,150.195933942647],[-9.20555999999993,150.21039],[-9.20777999999995,150.23218],[-9.27360999999991,150.33095],[-9.38638999999995,150.37717],[-9.39873372345699,150.375441317138],[-9.37888717699991,150.41633606],[-9.64140796699991,150.411376953],[-9.68103313399996,150.684051514],[-9.79481071047286,150.758883440934],[-9.74832999999995,150.75027],[-9.73082999999991,150.74884],[-9.70784999999995,150.76262],[-9.7194399999999,150.78802],[-9.73138999999991,150.80304],[-9.74693999999994,150.82163],[-9.81916999999993,150.90026],[-9.85235999999992,150.93539],[-9.89360999999991,150.96274],[-9.98527999999993,151.03055],[-9.99693999999994,151.03943],[-10.0169399999999,151.05996],[-10.0244399999999,151.07303],[-10.0466,151.11809],[-10.0413899999999,151.13666],[-10.03014,151.14818],[-10.0194499999999,151.14875],[-10.0033999999999,151.13893],[-9.98916999999994,151.13637],[-9.94207999999991,151.18817],[-9.93666999999993,151.20053],[-9.93091343037411,151.222140060489],[-9.68598556499995,150.991424561],[-9.45813846599992,150.936889648],[-9.30954170199993,151.03604126],[-9.13122558599991,150.961669922],[-8.80926608999994,151.055862427],[-8.66848054747773,151.099704833311],[-8.63888999999995,151.10107],[-8.56673125859819,151.063276911059],[-8.52198028599992,150.922012329],[-8.54674625399991,150.53036499]],[[-9.43832999999995,150.66666],[-9.44124999999991,150.67997],[-9.42805999999996,150.73191],[-9.42055999999991,150.7462],[-9.40541999999993,150.7615],[-9.41471999999993,150.77777],[-9.43277999999992,150.80442],[-9.45638999999994,150.8283],[-9.52319999999992,150.88692],[-9.64471999999995,150.93219],[-9.65916999999996,150.93055],[-9.67082999999991,150.92163],[-9.68207999999993,150.90387],[-9.67221999999992,150.89177],[-9.67916999999994,150.87523],[-9.71805999999992,150.84692],[-9.68555999999995,150.84412],[-9.65860999999995,150.80163],[-9.66249999999991,150.76331],[-9.66332999999991,150.69135],[-9.66291999999993,150.65804],[-9.65388999999993,150.62274],[-9.62332999999995,150.51443],[-9.5836099999999,150.4905],[-9.44082999999995,150.42746],[-9.4313899999999,150.42331],[-9.41471999999993,150.41999],[-9.40110999999996,150.41999],[-9.38943999999992,150.4219],[-9.37666999999993,150.42609],[-9.35707999999994,150.43913],[-9.33770999999996,150.48044],[-9.34124999999994,150.5022],[-9.35166999999995,150.53028],[-9.37054999999992,150.57135],[-9.38499999999993,150.59802],[-9.40110999999996,150.62149],[-9.4233299999999,150.63734],[-9.43832999999995,150.66666]]], c905ab63-23c2-4587-bdd6-d6d37a56be51=[[[-8.58588343092737,151.123734225448],[-8.59127089890423,151.123748898655],[-8.58637142199996,151.125274658],[-8.58588343092737,151.123734225448]]], 8471299d-4904-4a10-ab00-c6cc5605bf3b=[[[-10.1228941076499,151.06827675758],[-10.1141699999999,151.02582],[-10.1108299999999,150.99831],[-10.1127799999999,150.98331],[-10.1127665622499,150.982996372512],[-10.1466360089999,151.011245728],[-10.1228941076499,151.06827675758]]], d0a0b923-b401-4cec-ac35-c3d8c837bffc=[[[-10.0506772730004,150.931209804608],[-10.0041699999999,150.91553],[-9.92666999999994,150.87774],[-9.83888999999993,150.8269],[-9.80718113528387,150.767019514441],[-10.0277585979999,150.912094116],[-10.0506772730004,150.931209804608]]]}}";

View File

@ -19,6 +19,7 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import ucar.ma2.Array;
import ucar.ma2.ArrayByte;
import ucar.ma2.ArrayDouble;
import ucar.ma2.ArrayFloat;
import ucar.ma2.ArrayInt;
@ -177,6 +178,8 @@ public class ThreddsDataExplorer {
data3Double = (ArrayDouble.D3) data;
else if (data instanceof ArrayLong.D3)
data3Long = (ArrayLong.D3) data;
else if (data instanceof ArrayByte.D3)
data3Double = (ArrayDouble.D3)EnvDataExplorer.arrayByte3DArrayDouble((ArrayByte)data);
else
throw new Exception("Layer data format not supported");
}
@ -189,6 +192,8 @@ public class ThreddsDataExplorer {
data2Double = (ArrayDouble.D2) data;
else if (data instanceof ArrayLong.D2)
data2Long = (ArrayLong.D2) data;
else if (data instanceof ArrayByte.D2)
data2Double = (ArrayDouble.D2)EnvDataExplorer.arrayByte2DArrayDouble((ArrayByte)data);
else
throw new Exception("Layer data format not supported");
}