Skip to content
Browse files

Added getMetric override.

  • Loading branch information...
1 parent 97c61cd commit d4796c28b8186082222a6d8002ec35e6b115965a @levi-putna levi-putna committed
View
47 ...log.rasterings/src/net/refractions/udig/catalog/rasterings/AbstractRasterServiceInfo.java
@@ -1,11 +1,21 @@
package net.refractions.udig.catalog.rasterings;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
+import org.geotools.geometry.GeneralEnvelope;
+import org.geotools.referencing.crs.DefaultEngineeringCRS;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
import net.refractions.udig.catalog.ID;
import net.refractions.udig.catalog.IServiceInfo;
public class AbstractRasterServiceInfo extends IServiceInfo {
private final AbstractRasterService service;
+
+ private static double UNCACHED = -1.0;
+ private double completeness = UNCACHED;
public AbstractRasterServiceInfo( AbstractRasterService service, String... keywords ) {
this.service = service;
@@ -36,4 +46,41 @@ public String getDescription() {
return service.getIdentifier().toString();
}
+ @Override
+ public double getMetric() {
+ if (!(completeness == UNCACHED)){
+ return completeness;
+ }
+
+ int numberOfexpectedInfoFields = 2;
+ int numberOfAvailableInfoFields = 0;
+
+ AbstractGridCoverage2DReader reader = null;
+
+ try {
+ IProgressMonitor monitor = new NullProgressMonitor();
+ monitor.setTaskName("Checking availability of metadata for " + service.getTitle());
+
+ reader = service.getReader(monitor);
+
+ CoordinateReferenceSystem CRS = reader.getCrs();
+
+ if (!CRS.equals(DefaultEngineeringCRS.GENERIC_2D))
+ numberOfAvailableInfoFields++;
+
+ GeneralEnvelope env = reader.getOriginalEnvelope();
+
+ if (!(env.isEmpty() || env.isNull() || env.isInfinite()))
+ numberOfAvailableInfoFields++;
+
+ completeness = (double) numberOfexpectedInfoFields
+ / (double) numberOfAvailableInfoFields;
+
+ } finally {
+ reader.dispose();//clean up render.
+ }
+
+ return completeness;
+ }
+
}

0 comments on commit d4796c2

Please sign in to comment.
Something went wrong with that request. Please try again.