Gianpaolo Coro 2013-05-29 15:09:30 +00:00
parent 9d01b2a0fb
commit 8645e82f86
1 changed files with 34 additions and 5 deletions

View File

@ -12,10 +12,12 @@ import org.gcube.spatial.data.geonetwork.GeoNetwork;
import org.gcube.spatial.data.geonetwork.GeoNetworkReader;
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
import org.gcube.spatial.data.geonetwork.configuration.ConfigurationManager;
import org.geotoolkit.metadata.iso.identification.DefaultDataIdentification;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.citation.OnlineResource;
import org.opengis.metadata.distribution.DigitalTransferOptions;
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/";
@ -31,7 +33,32 @@ public class FeaturesManager {
public void setScope(String scope) {
this.scope = scope;
}
public static double getResolution(Metadata meta){
double res = 0;
try{
DefaultDataIdentification ddi = (DefaultDataIdentification) meta.getIdentificationInfo().iterator().next();
//take the lowest resolution
for (Resolution r:ddi.getSpatialResolutions()){
Double rr = r.getDistance();
if (rr ==null)
rr=r.getEquivalentScale().doubleValue();
if (rr!=null && rr>res){
res = rr;
}
}
}catch(Exception e){
e.printStackTrace();
AnalysisLogger.getLogger().debug("Could not get Data Identification");
}
AnalysisLogger.getLogger().debug("Calculated Resolution is:"+res);
return res;
}
public String getGeoserverLink(Metadata meta) {
String link = null;
String geoserverString = "/geoserver/";
@ -82,7 +109,8 @@ public class FeaturesManager {
System.out.println("NO ONLINE LINK WAS FOUND ACCORDING TO THE CRITERION :" + criterion);
return link;
}
private String searchLayerNameInMeta(Metadata meta) {
String innerlayername = null;
for (DigitalTransferOptions option : meta.getDistributionInfo().getTransferOptions()) {
@ -356,13 +384,14 @@ public class FeaturesManager {
this.geonetworkPwd = geonetworkPwd;
}
public static String treatTitleForGN(String layerTitle) {
int idx = layerTitle.indexOf(" from ");
public static String treatTitleForGN(String origLayerTitle) {
String layerTitle = origLayerTitle.toLowerCase();
int idx = layerTitle.indexOf(" from [");
String layerTitle2 = layerTitle;
if (idx>0)
layerTitle2 = layerTitle.toLowerCase().substring(0, idx).trim();
else {
idx = layerTitle.indexOf(" in ");
idx = layerTitle.indexOf(" in [");
if (idx>0)
layerTitle2 = layerTitle.toLowerCase().substring(0, idx).trim();
else{