-
Notifications
You must be signed in to change notification settings - Fork 133
/
AbstractRasterServiceInfo.java
86 lines (63 loc) · 2.47 KB
/
AbstractRasterServiceInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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;
super.keywords = keywords;
}
@Override
public String getTitle() {
ID id = service.getID();
String title;
if( id.isFile() ){
title = id.toFile().getAbsolutePath();
}
else {
title = id.toString();
}
return title;
}
@Override
public String getShortTitle() {
return service.getID().toFile().getName();
}
@Override
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;
}
}