Issue #2522 removing WCS and WMS from baseline

removed dependencies on static URN constants in NativeCrsAuthority and abstract wxxm translator


Former-commit-id: 4144db8bfc [formerly f50c286820 [formerly 6f113f3c68f13ebac010bd2f8e22d3534c0a8072]]
Former-commit-id: f50c286820
Former-commit-id: 09f8fe5d95
This commit is contained in:
Brian Clements 2013-11-06 09:55:45 -06:00
parent d79da040f5
commit ae897e75a8
171 changed files with 10 additions and 23040 deletions

View file

@ -18,7 +18,7 @@
</license>
<requires>
<import feature="com.raytheon.uf.edex.registry.client.feature" version="0.0.0"/>
<import feature="com.raytheon.uf.edex.registry.client.feature" version="0.0.0"/>
</requires>
<plugin
@ -80,27 +80,13 @@
install-size="0"
version="0.0.0"/>
<plugin
id="com.raytheon.uf.edex.plugin.unitconverter"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.plugin.dataset.urn"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.ogc.common"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.plugin.obs.ogc"
download-size="0"

View file

@ -42,5 +42,4 @@ Export-Package: com.raytheon.uf.edex.ogc.common,
com.raytheon.uf.edex.ogc.common.time,
com.raytheon.uf.edex.ogc.common.util
Import-Package: com.raytheon.uf.common.localization,
com.raytheon.uf.edex.plugin.dataset.urn,
org.apache.cxf.helpers

View file

@ -12,7 +12,6 @@ package com.raytheon.uf.edex.ogc.common.spatial;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.plugin.dataset.urn.URNLookup;
/**
* TODO Add Description
@ -32,7 +31,7 @@ import com.raytheon.uf.edex.plugin.dataset.urn.URNLookup;
*/
public interface NativeCrsAuthority {
public static final String NATIVE_CRS_PREFIX = URNLookup.WXSRV_URN_PREFIX
public static final String NATIVE_CRS_PREFIX = "urn:x-wxsrv:"
+ "crs:";
public CoordinateReferenceSystem lookup(String URN) throws OgcException;

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.plugin.dataset.urn</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,8 +0,0 @@
#Tue Apr 02 10:27:06 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -1,12 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Dataset-URN
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.dataset.urn
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.springframework;bundle-version="2.5.6",
com.raytheon.uf.edex.core;bundle-version="1.12.1174",
org.apache.commons.lang;bundle-version="2.3.0",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.edex.plugin.dataset.urn

View file

@ -1,6 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
res/,\
bin/

View file

@ -1,17 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="cfNameResource" class="com.raytheon.uf.edex.plugin.dataset.urn.CFNameResource">
<property name="configFileResource">
<value>file:///${edex.home}/data/utility/edex_static/base/wxsrv/namedata/ncep_to_cf_mapping.csv</value>
</property>
</bean>
<bean id="cfNameLookup" class="com.raytheon.uf.edex.plugin.dataset.urn.CFNameLookup">
<constructor-arg>
<ref bean="cfNameResource" />
</constructor-arg>
</bean>
</beans>

View file

@ -1,165 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.dataset.urn;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Singleton to facilitate the lookup of the CF Standard name from a shortened
* name such as those in GRIB processing. Also maintains a mapping of the CF names
* to ontology individuals to facilitate dynamic ontology updates and individual
* creation.
* @author behemmi
*
*/
public class CFNameLookup {
private static CFNameLookup instance;
private IUFStatusHandler log = UFStatus.getHandler(this.getClass());
private Map<String, String> ncepToCFMapping;
protected Map<String, String> cfToNcepMapping;
private Map<String, String> cfToOntologyRelationMapping;
private Map<String, String> cfToOntologyClassMapping;
private CFNameLookup(CFNameResource resource) {
ncepToCFMapping = new HashMap<String, String>();
cfToOntologyRelationMapping = new HashMap<String, String>();
cfToOntologyClassMapping = new HashMap<String, String>();
cfToNcepMapping = new HashMap<String, String>();
try {
if (resource.getConfigFileResource() != null) {
InputStream configStream = resource.getConfigFileResource().getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(configStream));
String line = null;
while((line = in.readLine()) != null) {
if(line.startsWith("#") || line.length() == 0) {
//comment, ignore
continue;
}
//limit splitting to 2 to account for multiple tabs and trim for map insert
String[] parts = line.split("\t", 2);
if(parts != null && parts.length > 1) {
//check for an Ontology relation after the CF Name
String[] ontRelParts = parts[1].trim().split("\t", 2);
if(ontRelParts != null && ontRelParts.length > 1) {
//check for an Ontology class after the Ontoogy relation
String[] ontClassParts = ontRelParts[1].trim().split("\t", 2);
if(ontClassParts != null && ontClassParts.length > 1) {
//this line has everything, populate all the HashMaps
cfToOntologyClassMapping.put(ontRelParts[0].trim(), ontClassParts[1].trim());
cfToOntologyRelationMapping.put(ontRelParts[0].trim(), ontClassParts[0].trim());
ncepToCFMapping.put(parts[0].toUpperCase().trim(), ontRelParts[0].trim());
cfToNcepMapping.put(ontRelParts[0].trim(),
parts[0].toUpperCase().trim());
} else {
//only entries up the relation are present
cfToOntologyRelationMapping.put(ontRelParts[0].trim(), ontRelParts[1].trim());
ncepToCFMapping.put(parts[0].toUpperCase().trim(), ontRelParts[0].trim());
cfToNcepMapping.put(ontRelParts[0].trim(),
parts[0].toUpperCase().trim());
log.warn("CF Name "
+ ontRelParts[0].trim()
+ " not mapped to Ontology Class in Config");
}
} else {
//only the cf and ncep entries are on this line
ncepToCFMapping.put(parts[0].toUpperCase().trim(), parts[1].trim());
cfToNcepMapping.put(parts[1].trim(), parts[0]
.toUpperCase().trim());
log.warn("CF Name " + parts[1].trim()
+ " not mapped to Ontology Info in Config");
}
} else {
log.warn("NCEP Name " + parts[0]
+ " not mapped to CF Name in Config");
}
}
} else {
throw new IOException("Config File Resource null");
}
} catch (IOException e) {
log.error("Configured mapping to CF Names not available", e);
}
instance = this;
}
public static CFNameLookup getInstance(){
//expecting instantiation from spring so no 'new' call here
//like in the normal singleton pattern
return instance;
}
/**
* Returns the CF Name if available, defaults to the ncep name otherwise
*
* @param ncepName
* @return
*/
public String getCFFromNCEP(String ncepName) {
String cfName = ncepName;
if(ncepToCFMapping.containsKey(ncepName.toUpperCase())) {
cfName = ncepToCFMapping.get(ncepName.toUpperCase());
}
return cfName;
}
/**
* Returns the NCEP name if available, defaults to the cf name otherwise
*
* @param cfName
* @return
*/
public String getNCEPFromCF(String cfName) {
String ncepName = cfName;
if (cfToNcepMapping.containsKey(cfName)) {
ncepName = cfToNcepMapping.get(cfName).toUpperCase();
}
return ncepName;
}
/**
* Looks up the associated ontology axiom for a given CF Name, returns null
* if no entities are associated
* @param cfName
* @return
*/
public String getOntologyRelationFromCF(String cfName) {
return cfToOntologyRelationMapping.get(cfName);
}
/**
* Looks up the associated ontology class for a given CF Name, returns null
* if no entities are associated
* @param cfName
* @return
*/
public String getOntologyclassFromCF(String cfName) {
return cfToOntologyClassMapping.get(cfName);
}
}

View file

@ -1,31 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.dataset.urn;
import org.springframework.core.io.Resource;
public class CFNameResource {
/**
* Spring resource for properties file, this is preferred over a filepath
* string
*/
protected Resource configFileResource = null;
public Resource getConfigFileResource() {
return configFileResource;
}
public void setConfigFileResource(Resource configFileResource) {
this.configFileResource = configFileResource;
}
}

View file

@ -1,156 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.dataset.urn;
/**
* Lookup URNs.
*
* @author ekladstrup
* @version 1.0
*/
public class URNLookup {
public static final String WXSRV_URN_PREFIX = "urn:x-wxsrv:";
public static final String MODEL_URN_PREFIX = WXSRV_URN_PREFIX + "Dataset";
// From ucar.edu WXCM primer
public static final String FDC_AIRCRAFT_REPORT = "urn:fdc:icao:procedure:AircraftReport";
// From ucar.edu WXCM primer
public static final String ICAO_CODE_PREFIX = "urn:icao:code:weatherStation";
private static enum State {
START, ONE_SLASH, MULT_SLASH, ONE_COLON
}
/**
* Convert EDEX internal ID to external URN
*
* Single slashes are replaced by single colons. Any additional slashes
* immediately following are converted into URN escape sequences. 'foo/bar'
* -> 'foo:bar', 'foo//bar' -> 'foo:%2fbar'. Any colons in the local string
* are escaped with another colon. 'foo:bar/baz' -> 'foo::bar:baz'. Other
* non-URN characters are escaped using URN escape formatting.
*
* Dataset URN prefix is attached.
*
* @param local
* dataURI based ID
* @return
*/
public static String localToUrn(String local) {
State s = State.START;
StringBuilder sb = new StringBuilder(MODEL_URN_PREFIX).append(':');
for (int i = 0; i < local.length(); ++i) {
char curr = local.charAt(i);
switch (curr) {
case '/':
if (s.equals(State.START)) {
s = State.ONE_SLASH;
sb.append(':');
} else if (s.equals(State.ONE_SLASH)) {
s = State.MULT_SLASH;
sb.append("%2f");
} else if (s.equals(State.MULT_SLASH)) {
sb.append("%2f");
}
break;
case ':':
sb.append("::");
s = State.START;
break;
case '%':
case '?':
case '#':
case ' ':
sb.append(String.format("%%%02x", (short) curr));
s = State.START;
break;
default:
sb.append(curr);
s = State.START;
}
}
return sb.toString();
}
/**
* Convert external URN to internal EDEX ID
*
* URN escaped characters are converted to ASCII. Single colons are
* converted to slashes. Colon pairs are converted to single colons.
*
* Dataset URN prefix is assumed to be on input.
*
* @param urn
* @return dataURI based ID
*/
public static String urnToLocal(String urn) {
// add 1 since the last ":" is not included in the length
String unique = urn.substring(MODEL_URN_PREFIX.length() + 1);
State s = State.START;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < unique.length(); ++i) {
char curr = unique.charAt(i);
char next;
switch (curr) {
case ':':
if (s.equals(State.START)) {
s = State.ONE_COLON;
continue;
} else {
sb.append(':');
s = State.START;
continue;
}
case '%':
next = (char) Short.parseShort(unique.substring(i + 1, i + 3),
16);
i += 2;
break;
default:
next = curr;
break;
}
if (s.equals(State.ONE_COLON)) {
sb.append('/');
s = State.START;
}
sb.append(next);
}
return sb.toString();
}
public static String getAircraftReportURN() {
return FDC_AIRCRAFT_REPORT;
}
public static String icaoToUrn(String station) {
return ICAO_CODE_PREFIX + ":" + station;
}
/**
* Slice the icao urn and return the local part
*
* @param urn
* @return Blank string or local part if prefix is the proper icao prefix,
* null if the prefix does not match expectations
*/
public static String urnToIcao(String urn) {
if (urn.startsWith(ICAO_CODE_PREFIX)) {
// add 1 since the last ":" is not included in the length
return urn.substring(ICAO_CODE_PREFIX.length() + 1);
} else {
return null;
}
}
}

View file

@ -1,278 +0,0 @@
#This file contains a user editable mapping of names that would be seen as part of data ingest to
#more standardized CF (NetCDF Climate and Forecast) names. The first list is taken directly from
#the NetCDF Climate and Forecast (CF) Metadata Convention website and the entries that follow
#are as needed additions based on what is being seen in data. The third column is a listing
#of ontology names that map to the cf names. This allows for updates and additions to both
#the ontology and the CF list while maintaining the codes ability to generate ontology individuals.
#note that the third column is case sensitive.
#all values from http://cf-pcmdi.llnl.gov/documents/cf-standard-names/ncep-grib-code-cf-standard-name-mapping
#NCEP #CF Name #Ontology Axiom IRI #Ontology Class IRI
PRES air_pressure http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
PRMSL air_pressure_at_sea_level http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
PTEND tendency_of_air_pressure http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
ICAHT standard_atmosphere_reference_height
GP geopotential http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
HGT geopotential_height http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
DIST altitude
HSTDV height_standard_deviation
TOZNE equivalent_thickness_at_stp_of_atmosphere_o3_content
TMP air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
VTMP virtual_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
POT air_potential_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
EPOT pseudo_equivalent_potential_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
T MAX max_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
T MIN min_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
DPT dew_point_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
DEPR dew_point_depression http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
LAPR air_temperature_lapse_rate http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
VIS visibility_in_air
RDSP1 radar_spectra_1
RDSP2 radar_spectra_2
RDSP3 radar_spectra_3
PLI parcel_lifted_index
TMP A air_temperature_anomaly http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
PRESA air_pressure_anomaly http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
GP A geopotential_height_anomaly http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
WVSP1 wave_spectra_1
WVSP2 wave_spectra_2
WVSP3 wave_spectra_3
WDIR wind_from_direction http://wxsrv/ontology/weather.owl#hasWindDirection http://wxsrv/ontology/weather.owl#WindDirection
WIND wind_speed http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
U GRD eastward_wind http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
V GRD northward_wind http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
STRM atmosphere_horizontal_streamfunction
V POT atmosphere_horizontal_velocity_potential http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
MNTSF montgomery_stream_function
SGCVV vertical_air_velocity_expressed_as_tendency_of_sigma http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
V VEL vertical_air_velocity_expressed_as_tendency_of_pressure http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
DZDT upward_air_velocity http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
ABS V atmosphere_absolute_vorticity http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
ABS D atmosphere_absolute_divergence
REL V atmosphere_relative_vorticity http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
REL D divergence_of_wind http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
VUCSH eastward_wind_shear http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
VVCSH northward_wind_shear http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
DIR C direction_of_sea_water_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterDirection http://wxsrv/ontology/weather.owl#SeaWaterDirection
SP C sea_water_speed http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
UOGRD eastward_sea_water_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
VOGRD northward_sea_water_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
SPF H specific_humidity
R H relative_humidity http://wxsrv/ontology/weather.owl#hasRelativeHumidity http://wxsrv/ontology/weather.owl#RelativeHumidity
MIXR humidity_mixing_ratio
P WAT atmosphere_water_vapour_content
VAPP water_vapour_pressure
SAT D water_vapour_saturation_deficit
EVP water_evaporation_amount
C ICE atmosphere_cloud_ice_content
PRATE precipitation_flux
TSTM thunderstorm_probability
A PCP precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
NCPCP large_scale_precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
ACPCP convective_precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
SRWEQ snowfall_flux
WEASD surface_snow_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
SNO D surface_snow_thickness http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
MIXHT ocean_mixed_layer_thickness
TTHDP transient_thermocline_depth
MTHD main_thermocline_depth
MTHA main_thermocline_anomoly
T CDC cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
CDCON convective_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
L CDC low_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
M CDC medium_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
H CDC high_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
C WAT atmosphere_cloud_condensed_water_content
BLI best_lifted_index
SNO C convective_snowfall_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
SNO L large_scale_snowfall_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
WTMP sea_water_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
LAND land_area_fraction http://wxsrv/ontology/weather.owl#hasLandAreaFraction http://wxsrv/ontology/weather.owl#LandAreaFraction
DSL M sea_surface_height_above_sea_level
SFC R surface_roughness_length
ALBDO surface_albedo
TSOIL soil_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
SOIL soil_moisture_content
VEG vegetation_area_fraction
SALTY sea_water_salinity
DEN density
WATR surface_runoff_amount
ICE C sea_ice_area_fraction
ICETK sea_ice_thickness
DICED direction_of_sea_ice_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterDirection http://wxsrv/ontology/weather.owl#SeaWaterDirection
SICED sea_ice_speed http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
U ICE sea_ice_eastward_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
V ICE sea_ice_northward_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
ICE G tendency_of_sea_ice_thickness_due_to_thermodynamics
ICE D divergence_of_sea_ice_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
SNO M surface_snow_melt_amount
HTSGW significant_height_of_wind_and_swell_waves
WVDIR direction_of_wind_wave_velocity
WVHGT significant_height_of_wind_waves
WVPER wind_wave_period
SWDIR direction_of_swell_wave_velocity
SWELL significant_height_of_swell_waves
SWPER swell_wave_period
DIRPW primary_wave_direction
PERPW primary_wave_mean_period
DIRSW secondary_wave_direction
PERSW secondary_wave_mean_period
NSWRS surface_net_upward_shortwave_flux
NLWRS surface_net_upward_longwave_flux
NSWRT toa_net_upward_shortwave_flux
NLWRT toa_net_upward_longwave_flux
LWAVR net_upward_longwave_flux_in_air
SWAVR net_upward_shortwave_flux_in_air
G RAD surface_downwelling_shortwave_flux
BRTMP brightness_temperature
LWRAD wave_number_radiance
SWRAD wave_length_radiance
LHTFL surface_upward_latent_heat_flux
SHTFL surface_upward_sensible_heat_flux
BLYDP boundary_layer_dissipation
U FLX downward_eastward_momentum_flux_in_air
V FLX downward_northward_momentum_flux_in_air
WMIXE wind_mixing_energy_flux_into_ocean
IMG image_data
MSLSA standard_atmospheric_reduction_mean_sea_level_pressure
MSLMA maps_system_reduction_mean_sea_level_pressure
MSLET nam_model_reduction_mean_sea_level_pressure
LFTX surface_lifted_index
4LFTX best_four_layer_lifted_index
KX k_index
SX sweat_index
MCONV horizontal_moisture_divergence
VW SH wind_speed_shear
TSLSA standard_atmospheric_reduction_three_hour pressure_tendency
BVF2 brunt_vaisala_frequency
PVMW density_weighted_potontial_vorticity
CRAIN categorical_rain
CFRZR categorical_freezing_rain
CICEP categorical_ice_pellets
CSNOW categorical_snow
SOILW volumetric_soil_moisture_content
PEVPR potential_evaporation_rate
CWORK cloud_work_function
UGWD gravity_wave_stress_zonal_flux
VGWD gravity_wave_stress_meridonial_flux
PV potential_vorticity
COVMZ meridonail_zonal_wind_covariance
COVTZ temperature_zonal_wind_covariance
COVTM temperature_meridonail_wind_covariance
CLWMR cloud_mixing_ratio
O3MR ozone_mixing_ratio
GFLUX ground_heat_flux
CIN convective_inhibition
CAPE atmosphere_specific_convective_available_potential_energy
TKE turbulent_kinetic_energy
CONDP surface_parcel_condensation_pressure
CSUSF clear_sky_upward_solar_flux
CSDSF clear_sky_downward_solar_flux
CSULF clear_sky_upward_long_wave_flux
CSDLF clear_sky_downward_long_wave_flux
CFNSF cloud_forcing_net_solar_flux
CFNLF cloud_forcing_net_long_wave_flux
VBDSF visible_beam_downward_solar_flux
VDDSF visible_diffuse_downward_solar_flux
NBDSF near_ir_beam_downward_solar_flux
NDDSF near_ir_diffuse_downward_solar_flux
MFLX momentum_flux
LMH mass_point_model_surface
LMV velocity_point_model_surface
MLYNO model_layer_number
NLAT latitude
ELON east_longitude
LPSX log_pressure_x_gradient
LPSY log_pressure_y_gradient
HGTX height_x_gradient
HGTY height_y_gradient
VPTMP virtual_potential_temperature
HLCY storm_relative_helicity
PROB probability_from_ensemble
PROBN climate_normalized_probability_from_ensemble
POP probability_of_precipitation
CPOFP percent_of_frozen_precipitation
CPOZP probability_of_freezing_precipitation
USTM u_component_of_storm_motion
VSTM v_component_of_storm_motion
ICWAT ice_free_water_surface
DSWRF downward_short_wave_rad_flux
DLWRF downward_long_wave_rad_flux
UVI untra_violet_index
MSTAV moisture_availability
SFEXC exchange_coefficient
MIXLY surface_mixed_layers
USWRF upward_short_wave_rad_flux
ULWRF upward_long_wave_rad_flux
CDLYR amound_of_non_convective_cloud
CPRAT convective_precipitation_rate
TTDIA temperature_tendency_by_all_physics
TTRAD temperature_tendency_by_all_radiation
TTPHY temperature_tendency_by_nonradiation_physics
PREIX precipitation_index
TSD1D std_dev_irt_over_1x1_deg_area
NLGSP natural_log_of_surface_pressure
HPBL planetary_boundary_layer_height
5WAVH 5_wave_geopotential_height
CNWAT plant_canopy_surface_water
BMIXL blackadars_mixing_length_scale
AMIXL asymptotic_mixing_length_scale
PEVAP potential_evaporation
SNOHF snow_phase_change_heat_flux
MFLUX convective_cloud_mass_flux
DTRF downward_total_radiation_flux
UTRF upward_total_radiation_flux
BGRUN baseflow_groundwater_runoff
SSRUN storm_surface_runoff
03TOT total_ozone
SNOWC snow_cover
SNOWT snow_temperature
LRGHR large_scale_condensate_heat_rate
CNVHR deep_convective_heating_rate
CNVMR deep_convective_moistening_rate
SHAHR shallow_convective_heating_rate
SHAMR shallow_convectine_moistening_rate
VDFHR vertical_diffusion_heating_rate
VDFUA vertical_diffusion_zonal_acceleration
VDFVA vertical_diffusion_meridonal_acceleration
VDFMR vertical_diffusion_moistening_rate
SWHR solar_radiative_heating_rate
LWHR long_wave_radiative_heating_rate
CD drag_coefficient
FRICV friction_velocity
RI richardson_number
HLCY storm_relative_helicity
#other mapping added based on what was seen in data
GH geopotential_height http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
T temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
RH relative_humidity http://wxsrv/ontology/weather.owl#hasRelativeHumidity http://wxsrv/ontology/weather.owl#RelativeHumidity
UW horizontal_wind_vector http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
VW vertical_wind_vector http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
ICIP icing_probability http://wxsrv/ontology/weather.owl#hasIcingProbability http://wxsrv/ontology/weather.owl#IcingProbability
PVV pressure_vertical_velocity
#eta218 xml short name entries that do not already exist in the cf mapping
HELI helicity_sigma
TCC cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
TP precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
STATICCORIOLIS coriolis_parameter
MNT min_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
MXT max_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
P air_pressure http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
T air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
STATICSPACING grid_spacing
WD wind_from_direction http://wxsrv/ontology/weather.owl#hasWindDirection http://wxsrv/ontology/weather.owl#WindDirection
WS wind_speed http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
PLI parcel_lifted_index
PMSL air_pressure_at_sea_level http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
EMSP eta_mean_sea_level_pressure
CP convective_precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
PW precipitable_water
STATICTOPO tolography
SLI surface_lifted_index
AV atmosphere_absolute_vorticity http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
REFC composite_radar_reflectivity
REFD derived_radar_reflectivity
SND surface_snow_thickness http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
THP thunderstorm_probability
1 #This file contains a user editable mapping of names that would be seen as part of data ingest to
2 #more standardized CF (NetCDF Climate and Forecast) names. The first list is taken directly from
3 #the NetCDF Climate and Forecast (CF) Metadata Convention website and the entries that follow
4 #are as needed additions based on what is being seen in data. The third column is a listing
5 #of ontology names that map to the cf names. This allows for updates and additions to both
6 #the ontology and the CF list while maintaining the codes ability to generate ontology individuals.
7 #note that the third column is case sensitive.
8
9 #all values from http://cf-pcmdi.llnl.gov/documents/cf-standard-names/ncep-grib-code-cf-standard-name-mapping
10 #NCEP #CF Name #Ontology Axiom IRI #Ontology Class IRI
11 PRES air_pressure http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
12 PRMSL air_pressure_at_sea_level http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
13 PTEND tendency_of_air_pressure http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
14 ICAHT standard_atmosphere_reference_height
15 GP geopotential http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
16 HGT geopotential_height http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
17 DIST altitude
18 HSTDV height_standard_deviation
19 TOZNE equivalent_thickness_at_stp_of_atmosphere_o3_content
20 TMP air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
21 VTMP virtual_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
22 POT air_potential_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
23 EPOT pseudo_equivalent_potential_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
24 T MAX max_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
25 T MIN min_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
26 DPT dew_point_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
27 DEPR dew_point_depression http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
28 LAPR air_temperature_lapse_rate http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
29 VIS visibility_in_air
30 RDSP1 radar_spectra_1
31 RDSP2 radar_spectra_2
32 RDSP3 radar_spectra_3
33 PLI parcel_lifted_index
34 TMP A air_temperature_anomaly http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
35 PRESA air_pressure_anomaly http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
36 GP A geopotential_height_anomaly http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
37 WVSP1 wave_spectra_1
38 WVSP2 wave_spectra_2
39 WVSP3 wave_spectra_3
40 WDIR wind_from_direction http://wxsrv/ontology/weather.owl#hasWindDirection http://wxsrv/ontology/weather.owl#WindDirection
41 WIND wind_speed http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
42 U GRD eastward_wind http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
43 V GRD northward_wind http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
44 STRM atmosphere_horizontal_streamfunction
45 V POT atmosphere_horizontal_velocity_potential http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
46 MNTSF montgomery_stream_function
47 SGCVV vertical_air_velocity_expressed_as_tendency_of_sigma http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
48 V VEL vertical_air_velocity_expressed_as_tendency_of_pressure http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
49 DZDT upward_air_velocity http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
50 ABS V atmosphere_absolute_vorticity http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
51 ABS D atmosphere_absolute_divergence
52 REL V atmosphere_relative_vorticity http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
53 REL D divergence_of_wind http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
54 VUCSH eastward_wind_shear http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
55 VVCSH northward_wind_shear http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
56 DIR C direction_of_sea_water_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterDirection http://wxsrv/ontology/weather.owl#SeaWaterDirection
57 SP C sea_water_speed http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
58 UOGRD eastward_sea_water_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
59 VOGRD northward_sea_water_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
60 SPF H specific_humidity
61 R H relative_humidity http://wxsrv/ontology/weather.owl#hasRelativeHumidity http://wxsrv/ontology/weather.owl#RelativeHumidity
62 MIXR humidity_mixing_ratio
63 P WAT atmosphere_water_vapour_content
64 VAPP water_vapour_pressure
65 SAT D water_vapour_saturation_deficit
66 EVP water_evaporation_amount
67 C ICE atmosphere_cloud_ice_content
68 PRATE precipitation_flux
69 TSTM thunderstorm_probability
70 A PCP precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
71 NCPCP large_scale_precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
72 ACPCP convective_precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
73 SRWEQ snowfall_flux
74 WEASD surface_snow_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
75 SNO D surface_snow_thickness http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
76 MIXHT ocean_mixed_layer_thickness
77 TTHDP transient_thermocline_depth
78 MTHD main_thermocline_depth
79 MTHA main_thermocline_anomoly
80 T CDC cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
81 CDCON convective_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
82 L CDC low_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
83 M CDC medium_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
84 H CDC high_cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
85 C WAT atmosphere_cloud_condensed_water_content
86 BLI best_lifted_index
87 SNO C convective_snowfall_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
88 SNO L large_scale_snowfall_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
89 WTMP sea_water_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
90 LAND land_area_fraction http://wxsrv/ontology/weather.owl#hasLandAreaFraction http://wxsrv/ontology/weather.owl#LandAreaFraction
91 DSL M sea_surface_height_above_sea_level
92 SFC R surface_roughness_length
93 ALBDO surface_albedo
94 TSOIL soil_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
95 SOIL soil_moisture_content
96 VEG vegetation_area_fraction
97 SALTY sea_water_salinity
98 DEN density
99 WATR surface_runoff_amount
100 ICE C sea_ice_area_fraction
101 ICETK sea_ice_thickness
102 DICED direction_of_sea_ice_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterDirection http://wxsrv/ontology/weather.owl#SeaWaterDirection
103 SICED sea_ice_speed http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
104 U ICE sea_ice_eastward_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
105 V ICE sea_ice_northward_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
106 ICE G tendency_of_sea_ice_thickness_due_to_thermodynamics
107 ICE D divergence_of_sea_ice_velocity http://wxsrv/ontology/weather.owl#hasSeaWaterSpeed http://wxsrv/ontology/weather.owl#SeaWaterSpeed
108 SNO M surface_snow_melt_amount
109 HTSGW significant_height_of_wind_and_swell_waves
110 WVDIR direction_of_wind_wave_velocity
111 WVHGT significant_height_of_wind_waves
112 WVPER wind_wave_period
113 SWDIR direction_of_swell_wave_velocity
114 SWELL significant_height_of_swell_waves
115 SWPER swell_wave_period
116 DIRPW primary_wave_direction
117 PERPW primary_wave_mean_period
118 DIRSW secondary_wave_direction
119 PERSW secondary_wave_mean_period
120 NSWRS surface_net_upward_shortwave_flux
121 NLWRS surface_net_upward_longwave_flux
122 NSWRT toa_net_upward_shortwave_flux
123 NLWRT toa_net_upward_longwave_flux
124 LWAVR net_upward_longwave_flux_in_air
125 SWAVR net_upward_shortwave_flux_in_air
126 G RAD surface_downwelling_shortwave_flux
127 BRTMP brightness_temperature
128 LWRAD wave_number_radiance
129 SWRAD wave_length_radiance
130 LHTFL surface_upward_latent_heat_flux
131 SHTFL surface_upward_sensible_heat_flux
132 BLYDP boundary_layer_dissipation
133 U FLX downward_eastward_momentum_flux_in_air
134 V FLX downward_northward_momentum_flux_in_air
135 WMIXE wind_mixing_energy_flux_into_ocean
136 IMG image_data
137 MSLSA standard_atmospheric_reduction_mean_sea_level_pressure
138 MSLMA maps_system_reduction_mean_sea_level_pressure
139 MSLET nam_model_reduction_mean_sea_level_pressure
140 LFTX surface_lifted_index
141 4LFTX best_four_layer_lifted_index
142 KX k_index
143 SX sweat_index
144 MCONV horizontal_moisture_divergence
145 VW SH wind_speed_shear
146 TSLSA standard_atmospheric_reduction_three_hour pressure_tendency
147 BVF2 brunt_vaisala_frequency
148 PVMW density_weighted_potontial_vorticity
149 CRAIN categorical_rain
150 CFRZR categorical_freezing_rain
151 CICEP categorical_ice_pellets
152 CSNOW categorical_snow
153 SOILW volumetric_soil_moisture_content
154 PEVPR potential_evaporation_rate
155 CWORK cloud_work_function
156 UGWD gravity_wave_stress_zonal_flux
157 VGWD gravity_wave_stress_meridonial_flux
158 PV potential_vorticity
159 COVMZ meridonail_zonal_wind_covariance
160 COVTZ temperature_zonal_wind_covariance
161 COVTM temperature_meridonail_wind_covariance
162 CLWMR cloud_mixing_ratio
163 O3MR ozone_mixing_ratio
164 GFLUX ground_heat_flux
165 CIN convective_inhibition
166 CAPE atmosphere_specific_convective_available_potential_energy
167 TKE turbulent_kinetic_energy
168 CONDP surface_parcel_condensation_pressure
169 CSUSF clear_sky_upward_solar_flux
170 CSDSF clear_sky_downward_solar_flux
171 CSULF clear_sky_upward_long_wave_flux
172 CSDLF clear_sky_downward_long_wave_flux
173 CFNSF cloud_forcing_net_solar_flux
174 CFNLF cloud_forcing_net_long_wave_flux
175 VBDSF visible_beam_downward_solar_flux
176 VDDSF visible_diffuse_downward_solar_flux
177 NBDSF near_ir_beam_downward_solar_flux
178 NDDSF near_ir_diffuse_downward_solar_flux
179 MFLX momentum_flux
180 LMH mass_point_model_surface
181 LMV velocity_point_model_surface
182 MLYNO model_layer_number
183 NLAT latitude
184 ELON east_longitude
185 LPSX log_pressure_x_gradient
186 LPSY log_pressure_y_gradient
187 HGTX height_x_gradient
188 HGTY height_y_gradient
189 VPTMP virtual_potential_temperature
190 HLCY storm_relative_helicity
191 PROB probability_from_ensemble
192 PROBN climate_normalized_probability_from_ensemble
193 POP probability_of_precipitation
194 CPOFP percent_of_frozen_precipitation
195 CPOZP probability_of_freezing_precipitation
196 USTM u_component_of_storm_motion
197 VSTM v_component_of_storm_motion
198 ICWAT ice_free_water_surface
199 DSWRF downward_short_wave_rad_flux
200 DLWRF downward_long_wave_rad_flux
201 UVI untra_violet_index
202 MSTAV moisture_availability
203 SFEXC exchange_coefficient
204 MIXLY surface_mixed_layers
205 USWRF upward_short_wave_rad_flux
206 ULWRF upward_long_wave_rad_flux
207 CDLYR amound_of_non_convective_cloud
208 CPRAT convective_precipitation_rate
209 TTDIA temperature_tendency_by_all_physics
210 TTRAD temperature_tendency_by_all_radiation
211 TTPHY temperature_tendency_by_nonradiation_physics
212 PREIX precipitation_index
213 TSD1D std_dev_irt_over_1x1_deg_area
214 NLGSP natural_log_of_surface_pressure
215 HPBL planetary_boundary_layer_height
216 5WAVH 5_wave_geopotential_height
217 CNWAT plant_canopy_surface_water
218 BMIXL blackadars_mixing_length_scale
219 AMIXL asymptotic_mixing_length_scale
220 PEVAP potential_evaporation
221 SNOHF snow_phase_change_heat_flux
222 MFLUX convective_cloud_mass_flux
223 DTRF downward_total_radiation_flux
224 UTRF upward_total_radiation_flux
225 BGRUN baseflow_groundwater_runoff
226 SSRUN storm_surface_runoff
227 03TOT total_ozone
228 SNOWC snow_cover
229 SNOWT snow_temperature
230 LRGHR large_scale_condensate_heat_rate
231 CNVHR deep_convective_heating_rate
232 CNVMR deep_convective_moistening_rate
233 SHAHR shallow_convective_heating_rate
234 SHAMR shallow_convectine_moistening_rate
235 VDFHR vertical_diffusion_heating_rate
236 VDFUA vertical_diffusion_zonal_acceleration
237 VDFVA vertical_diffusion_meridonal_acceleration
238 VDFMR vertical_diffusion_moistening_rate
239 SWHR solar_radiative_heating_rate
240 LWHR long_wave_radiative_heating_rate
241 CD drag_coefficient
242 FRICV friction_velocity
243 RI richardson_number
244 HLCY storm_relative_helicity
245
246 #other mapping added based on what was seen in data
247 GH geopotential_height http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
248 T temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
249 RH relative_humidity http://wxsrv/ontology/weather.owl#hasRelativeHumidity http://wxsrv/ontology/weather.owl#RelativeHumidity
250 UW horizontal_wind_vector http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
251 VW vertical_wind_vector http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
252 ICIP icing_probability http://wxsrv/ontology/weather.owl#hasIcingProbability http://wxsrv/ontology/weather.owl#IcingProbability
253 PVV pressure_vertical_velocity
254
255 #eta218 xml short name entries that do not already exist in the cf mapping
256 HELI helicity_sigma
257 TCC cloud_area_fraction http://wxsrv/ontology/weather.owl#hasCloudAreaFraction http://wxsrv/ontology/weather.owl#CloudAreaFraction
258 TP precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
259 STATICCORIOLIS coriolis_parameter
260 MNT min_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
261 MXT max_air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
262 P air_pressure http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
263 T air_temperature http://wxsrv/ontology/weather.owl#hasTemperature http://wxsrv/ontology/weather.owl#Temperature
264 STATICSPACING grid_spacing
265 WD wind_from_direction http://wxsrv/ontology/weather.owl#hasWindDirection http://wxsrv/ontology/weather.owl#WindDirection
266 WS wind_speed http://wxsrv/ontology/weather.owl#hasWindSpeed http://wxsrv/ontology/weather.owl#WindSpeed
267 PLI parcel_lifted_index
268 PMSL air_pressure_at_sea_level http://wxsrv/ontology/weather.owl#hasBarometricPressure http://wxsrv/ontology/weather.owl#BarometricPressure
269 EMSP eta_mean_sea_level_pressure
270 CP convective_precipitation_amount http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
271 PW precipitable_water
272 STATICTOPO tolography
273 SLI surface_lifted_index
274 AV atmosphere_absolute_vorticity http://wxsrv/ontology/weather.owl#hasWindShear http://wxsrv/ontology/weather.owl#WindShear
275 REFC composite_radar_reflectivity
276 REFD derived_radar_reflectivity
277 SND surface_snow_thickness http://wxsrv/ontology/weather.owl#hasPrecipitationAmount http://wxsrv/ontology/weather.owl#PrecipitationAmount
278 THP thunderstorm_probability

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.plugin.grib.ogc</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,8 +0,0 @@
#Thu Jun 07 13:59:55 CDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -1,38 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ogc
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.grib.ogc
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Require-Bundle: org.springframework;bundle-version="2.5.6",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0",
javax.persistence;bundle-version="1.0.0",
org.apache.commons.lang;bundle-version="2.3.0",
com.raytheon.uf.edex.database;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
org.hibernate;bundle-version="1.0.0",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.edex.wms;bundle-version="1.0.0",
com.raytheon.uf.edex.wcs;bundle-version="1.0.0",
com.raytheon.uf.edex.core;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
org.apache.camel;bundle-version="1.0.0",
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0",
org.apache.commons.collections;bundle-version="3.2.0",
com.raytheon.uf.edex.plugin.dataset.urn;bundle-version="1.0.0",
ucar.nc2;bundle-version="1.0.0",
com.raytheon.uf.edex.plugin.unitconverter;bundle-version="1.0.0",
com.raytheon.uf.common.spatial;bundle-version="1.0.0",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0",
com.raytheon.uf.common.parameter;bundle-version="1.0.0",
com.raytheon.uf.edex.plugin.grid;bundle-version="1.0.0",
com.raytheon.uf.common.style;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.edex.plugin.grib.ogc

View file

@ -1,2 +0,0 @@
com.raytheon.uf.edex.plugin.grib.ogc.GribDimension
com.raytheon.uf.edex.plugin.grib.ogc.GribLayer

View file

@ -1,5 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
res/

View file

@ -1,102 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="gribDecoder" class="com.raytheon.edex.plugin.grib.GribDecoder" />
<bean id="ingest-grib" class="org.apache.camel.component.jms.JmsComponent">
<constructor-arg ref="jmsIngestGribConfig" />
<property name="taskExecutor" ref="gribThreadPool" />
</bean>
<bean id="jmsIngestGribConfig" class="org.apache.camel.component.jms.JmsConfiguration"
factory-bean="jmsConfig" factory-method="copy">
</bean>
<bean id="gribThreadPool"
class="com.raytheon.uf.edex.esb.camel.spring.JmsThreadPoolTaskExecutor">
<property name="corePoolSize" value="${grib-decode.count.threads}" />
<property name="maxPoolSize" value="${grib-decode.count.threads}" />
</bean>
<bean id="largeFileChecker" class="com.raytheon.edex.plugin.grib.GribLargeFileChecker" />
<bean id="gribSplitter" class="com.raytheon.edex.plugin.grib.GribSplitter">
<constructor-arg value="${edex.home}/data/tmp/"/>
</bean>
<bean id="useLatestAggregationStrategy" class="org.apache.camel.processor.aggregate.UseLatestAggregationStrategy" />
<bean id="largeFileLockRelease" class="com.raytheon.edex.plugin.grib.GribLockRelease" />
<bean id="gribDecodeCamelRegistered" factory-bean="contextManager"
factory-method="register" depends-on="persistCamelRegistered">
<constructor-arg ref="grib-decode"/>
</bean>
<bean id="gribPostProcessor"
class="com.raytheon.edex.plugin.grib.decoderpostprocessors.GribPostProcessor"
factory-method="getInstance" />
<bean id="gribTableLookup" class="com.raytheon.edex.util.grib.GribTableLookup"
factory-method="getInstance" depends-on="gridRegistered" />
<bean id="gribModelLookup"
class="com.raytheon.edex.plugin.grib.util.GribModelLookup"
factory-method="getInstance" />
<bean id="gribSpatialCache"
class="com.raytheon.edex.plugin.grib.spatial.GribSpatialCache"
factory-method="getInstance" depends-on="gridcoveragelookup"/>
<camelContext id="grib-decode" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler"
autoStartup="false">
<endpoint id="gribJmsEndpoint" uri="ingest-grib:queue:Ingest.Grib?concurrentConsumers=${grib-decode.count.threads}&amp;destinationResolver=#qpidDurableResolver" />
<!-- Begin Grib Decode Route -->
<route id="gribIngestRoute">
<from ref="gribJmsEndpoint" />
<setHeader headerName="pluginName">
<constant>grid</constant>
</setHeader>
<!-- strategyRef is needed because of camel bug https://issues.apache.org/activemq/browse/CAMEL-3333,
without the strategy it uses the original message in the multicast and it loses the largeFileLock header -->
<split strategyRef="useLatestAggregationStrategy">
<method bean="gribSplitter" method="split" />
<choice>
<when>
<simple>${header.CamelSplitSize} == 1</simple>
<doTry>
<pipeline>
<bean ref="stringToFile" />
<bean ref="largeFileChecker" />
<bean ref="gribDecoder" />
<bean ref="gribSplitter" method="clean" />
<!-- send for processing -->
<bean ref="gribPostProcessor" method="process" />
<multicast parallelProcessing="false">
<to uri="direct-vm:persistIndexAlert" />
<to uri="direct-vm:gribOgc" />
</multicast>
</pipeline>
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:grib?level=ERROR"/>
</doCatch>
<doFinally>
<bean ref="largeFileLockRelease" />
</doFinally>
</doTry>
</when>
<otherwise>
<to uri="ingest-grib:queue:Ingest.Grib" />
</otherwise>
</choice>
</split>
</route>
</camelContext>
</beans>

View file

@ -1,44 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean class="com.raytheon.uf.edex.ogc.common.util.AddonPropsPostProcessor">
<constructor-arg>
<map value-type="java.lang.Class">
<entry key="gridProperties">
<map>
<entry key="dao" value="com.raytheon.uf.edex.plugin.grib.ogc.GridNotifyDao" />
</map>
</entry>
</map>
</constructor-arg>
</bean>
<bean id="gribCamelRegistered" factory-bean="contextManager"
factory-method="register" depends-on="persistCamelRegistered">
<constructor-arg ref="grid-ogc-camel"/>
</bean>
<camelContext id="grid-ogc-camel" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler"
autoStartup="true">
<!-- Begin Grib Routes -->
<route id="gribIngestRoute">
<from uri="direct-vm:gribOgc" />
<bean ref="gribLayerCollector" method="add"/>
</route>
<route id="gridPurgeExpired">
<from uri="jms-generic:topic:Purge.expired.grid?destinationResolver=#qpidDurableResolver" />
<bean ref="gribLayerCollector" method="purgeExpired"/>
</route>
<route id="gridPurgeAll">
<from uri="jms-generic:topic:Purge.all.grid?destinationResolver=#qpidDurableResolver" />
<bean ref="gribLayerCollector" method="purgeAll"/>
</route>
</camelContext>
</beans>

View file

@ -1,42 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="gribLayerCollector" class="com.raytheon.uf.edex.plugin.grib.ogc.GribLayerCollector" >
<constructor-arg ref="layerStore" />
</bean>
<bean id="gridWcsLayerTransformer" class="com.raytheon.uf.edex.ogc.common.db.LayerTransformer">
<constructor-arg value="grid"/>
<constructor-arg ref="gribLayerCollector"/>
</bean>
<bean id="gridWmsLayerTransformer" class="com.raytheon.uf.edex.ogc.common.db.LayerTransformer">
<constructor-arg value="grid"/>
<constructor-arg>
<bean class="com.raytheon.uf.edex.plugin.grib.ogc.GridWmsLayerCache">
<constructor-arg ref="gribLayerCollector"/>
</bean>
</constructor-arg>
</bean>
<bean id="gribWmsSource" class="com.raytheon.uf.edex.plugin.grib.ogc.GribWmsSource">
<constructor-arg ref="gridProperties"/>
<constructor-arg ref="gridWmsLayerTransformer"/>
</bean>
<bean id="gribWcsSource" class="com.raytheon.uf.edex.plugin.grib.ogc.GribWcsSource">
<constructor-arg ref="gridProperties"/>
<constructor-arg ref="gridWcsLayerTransformer"/>
<constructor-arg ref="gribLayerCollector"/>
</bean>
<bean id="gridNativeCrsAuth" class="com.raytheon.uf.edex.plugin.grib.ogc.GribNativeCrsAuthority"/>
<bean id="gridVerticalEnabler" class="com.raytheon.uf.edex.plugin.grib.ogc.GridVerticalEnabler"/>
<bean id="gridFieldAdapter" class="com.raytheon.uf.edex.plugin.grib.ogc.GridFieldAdapter"/>
</beans>

View file

@ -1,150 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.StringUtils;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer;
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
import com.raytheon.uf.edex.ogc.common.level.LevelDimUtil;
import com.raytheon.uf.edex.ogc.common.time.ForecastTimeUtil;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public class GribDimension extends SimpleDimension {
private static final long serialVersionUID = 1232298678216203380L;
public static final String REFTIME_DIM = "REFTIME";
public static final String FORECAST_OFFSET_DIM = "FORECAST_OFFSET";
public static final String PARAM_DIM = "PARAMETER";
private transient DataTime defaultTime = null;
protected transient IUFStatusHandler log = UFStatus.getHandler(this
.getClass());
@XmlElement
@DynamicSerializeElement
protected Set<String> values;
public GribDimension() {
}
public GribDimension(String name, String units) {
this.name = name;
this.units = units;
this.values = new TreeSet<String>();
}
/**
* @param otherDim
*/
public GribDimension(GribDimension other) {
super(other);
this.values = new TreeSet<String>(other.values);
}
public void setValues(Set<String> values) {
this.values = values;
}
@Override
public Set<String> getValues() {
return values;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.ogc.common.db.SimpleDimension#getDefaultValue()
*/
@Override
public String getDefaultValue(SimpleLayer<?> layer) {
String rval = null;
if (GribDimension.REFTIME_DIM.equals(name)) {
DataTime time = getDefaultTime(layer);
rval = LayerTransformer.format(time.getRefTime());
} else if (GribDimension.FORECAST_OFFSET_DIM.equals(name)) {
DataTime time = getDefaultTime(layer);
rval = time.getFcstTime() + "S";
} else if (name.startsWith(LevelDimUtil.LEVEL_DIM_PREFIX)) {
rval = getLevel(true);
} else {
rval = getString(true);
}
return rval;
}
private String getLevel(boolean lowest) {
TreeMap<Double, String> sorted = new TreeMap<Double, String>();
if (this.getValues().isEmpty()) {
return null;
}
for (String val : this.getValues()) {
String level1 = StringUtils.split(val, '_')[0];
sorted.put(Double.parseDouble(level1), val);
}
Double key = lowest ? sorted.firstKey() : sorted.lastKey();
return sorted.get(key);
}
protected DataTime getDefaultTime(SimpleLayer<?> layer) {
if (defaultTime == null){
try {
SortedSet<DataTime> times = new ForecastTimeUtil()
.getDataTimes(layer, layer.getDefaultTime(),
new HashMap<String, String>(0));
defaultTime = times.last();
} catch (OgcException e) {
log.error("Problem getting default times", e);
return new DataTime(layer.getDefaultTime());
}
}
return defaultTime;
}
/**
* Copy contents of from into to
*
* @param to
* @param from
*/
public static void copy(Collection<GribDimension> to,
Collection<GribDimension> from) {
for (GribDimension d : from) {
to.add(new GribDimension(d));
}
}
}

View file

@ -1,180 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.Date;
import java.util.TreeSet;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public abstract class GribLayer extends SimpleLayer<GribDimension> {
private static final long serialVersionUID = 6934503885157257766L;
@XmlElement
@DynamicSerializeElement
protected String coverageName;
@XmlElement
@DynamicSerializeElement
protected String crsWkt;
@XmlElement
@DynamicSerializeElement
protected double nativeMinX;
@XmlElement
@DynamicSerializeElement
protected double nativeMinY;
@XmlElement
@DynamicSerializeElement
protected double nativeMaxX;
@XmlElement
@DynamicSerializeElement
protected double nativeMaxY;
@XmlElement
@DynamicSerializeElement
protected boolean vertical = true;
public GribLayer() {
}
public GribLayer(GribLayer other) {
super(other);
this.times = new TreeSet<Date>(other.getTimes());
this.coverageName = other.getCoverageName();
this.crsWkt = other.getCrsWkt();
this.nativeMaxX = other.nativeMaxX;
this.nativeMaxY = other.nativeMaxY;
this.nativeMinX = other.nativeMinX;
this.nativeMinY = other.nativeMinY;
this.vertical = other.vertical;
}
/**
* @return the coverageName
*/
public String getCoverageName() {
return coverageName;
}
/**
* @param coverageName
* the coverageName to set
*/
public void setCoverageName(String coverageName) {
this.coverageName = coverageName;
}
/**
* @return the crsWkt
*/
public String getCrsWkt() {
return crsWkt;
}
/**
* @param crsWkt
* the crsWkt to set
*/
public void setCrsWkt(String crsWkt) {
this.crsWkt = crsWkt;
}
/**
* @return the nativeMinX
*/
public double getNativeMinX() {
return nativeMinX;
}
/**
* @param nativeMinX
* the nativeMinX to set
*/
public void setNativeMinX(double nativeMinX) {
this.nativeMinX = nativeMinX;
}
/**
* @return the nativeMinY
*/
public double getNativeMinY() {
return nativeMinY;
}
/**
* @param nativeMinY
* the nativeMinY to set
*/
public void setNativeMinY(double nativeMinY) {
this.nativeMinY = nativeMinY;
}
/**
* @return the nativeMaxX
*/
public double getNativeMaxX() {
return nativeMaxX;
}
/**
* @param nativeMaxX
* the nativeMaxX to set
*/
public void setNativeMaxX(double nativeMaxX) {
this.nativeMaxX = nativeMaxX;
}
/**
* @return the nativeMaxY
*/
public double getNativeMaxY() {
return nativeMaxY;
}
/**
* @param nativeMaxY
* the nativeMaxY to set
*/
public void setNativeMaxY(double nativeMaxY) {
this.nativeMaxY = nativeMaxY;
}
/**
* @return the vertical
*/
public boolean isVertical() {
return vertical;
}
/**
* @param vertical
* the vertical to set
*/
public void setVertical(boolean vertical) {
this.vertical = vertical;
}
}

View file

@ -1,221 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.Set;
import java.util.TreeSet;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.parameter.Parameter;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.ogc.common.OgcLayer;
import com.raytheon.uf.edex.ogc.common.db.DefaultLayerCollector;
import com.raytheon.uf.edex.ogc.common.db.ILayerStore;
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer;
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
import com.raytheon.uf.edex.ogc.common.level.LevelDimUtil;
import com.raytheon.uf.edex.ogc.common.spatial.AltUtil;
import com.vividsolutions.jts.geom.Envelope;
public class GribLayerCollector extends
DefaultLayerCollector<GribDimension, GridCompositeLayer, GridRecord> {
public GribLayerCollector(ILayerStore store) {
super(GridCompositeLayer.class, GridRecord.class, store);
}
@Override
protected void addToDims(GridCompositeLayer layer, GridRecord rec) {
DataTime dt = rec.getDataTime();
GridInfoRecord info = rec.getInfo();
Level level = info.getLevel();
Set<? extends SimpleDimension> dims = layer.getDimensions();
for (SimpleDimension d : dims) {
String name = d.getName();
Set<String> values = d.getValues();
if (GribDimension.REFTIME_DIM.equals(name)) {
values.add(LayerTransformer.format(dt.getRefTime()));
} else if (GribDimension.FORECAST_OFFSET_DIM.equals(name)) {
values.add(dt.getFcstTime() + "S");
} else if (name.startsWith(LevelDimUtil.LEVEL_DIM_PREFIX)) {
values.add(LevelDimUtil.formatLevelValue(level));
} else if (GribDimension.PARAM_DIM.equals(name)) {
values.add(getParameter(rec));
} else {
log.warn("Unknown grib dimension: " + name);
}
}
}
/**
* Get parameter string from record
*
* @param rec
* @return
*/
private String getParameter(GridRecord rec) {
String fieldName = rec.getInfo().getParameter().getAbbreviation();
return GribRecordFinder.dbToOgcParameter(fieldName);
}
@Override
protected void addToTimes(GridCompositeLayer layer, GridRecord rec) {
String parameter = getParameter(rec);
layer.addTime(parameter, rec.getDataTime().getValidTime().getTime());
}
@Override
protected boolean initializeLayer(GridCompositeLayer layer, GridRecord rec) {
GridInfoRecord info = rec.getInfo();
Level level = info.getLevel();
Parameter parameter = info.getParameter();
if (parameter.getAbbreviation().startsWith("static")) {
return false;
}
Unit<?> unit = level.getMasterLevel().getUnit();
if (unit == null) {
layer.setVertical(false);
}
try {
AltUtil.convert(SI.METER, unit, 1);
} catch (Exception e) {
layer.setVertical(false);
}
GridCoverage cov = info.getLocation();
if (cov == null) {
log.warn("Recieved record without coverage!");
return false;
}
layer.setCoverageName(cov.getName());
String crsWkt = cov.getCrsWKT();
if (crsWkt == null) {
crsWkt = cov.getCrs().toWKT();
}
layer.setCrsWkt(crsWkt);
layer.setNx(cov.getNx());
layer.setNy(cov.getNy());
layer.setTargetCrsCode("CRS:84");
try {
Envelope env = getProperBounds(layer, cov, info);
layer.setTargetMinx(env.getMinX());
layer.setTargetMiny(env.getMinY());
layer.setTargetMaxx(env.getMaxX());
layer.setTargetMaxy(env.getMaxY());
layer.setCrs84Bounds(JTS.toGeometry(env));
} catch (Exception e) {
log.error("Unable to get crs84 bounds", e);
return false;
}
String levelUnit = level.getMasterLevel().getUnitString();
MasterLevel master = level.getMasterLevel();
TreeSet<GribDimension> dims = new TreeSet<GribDimension>();
dims.add(new GribDimension(GribDimension.REFTIME_DIM, "ISO8601"));
dims.add(new GribDimension(GribDimension.FORECAST_OFFSET_DIM, "ISO8601"));
String levelName = LevelDimUtil.LEVEL_DIM_PREFIX + master.getName();
dims.add(new GribDimension(levelName, levelUnit));
dims.add(new GribDimension(GribDimension.PARAM_DIM, parameter.getUnit()
.toString()));
layer.addDimensions(getParameter(rec), dims);
return true;
}
protected ReferencedEnvelope getProperBounds(GribLayer layer,
GridCoverage cov, GridInfoRecord info) throws FactoryException,
MismatchedDimensionException, TransformException {
String dataset = info.getDatasetId();
// the gemglobal and gfs global grids are already in a crs:84
// projection,
// so there is no transformation needed.
if (dataset.equals("GEMGlobal") || dataset.equals("GFS230")
|| dataset.equals("GlobalWave")) {
return new ReferencedEnvelope(-180.0, 180.0, -90.0, 90.0,
cov.getCrs());
}
// the polygon is not projected properly, must get native bounds and
// reproject into crs:84
CoordinateReferenceSystem nativeCrs = cov.getCrs();
Envelope env = JTS.transform(cov.getGeometry(),
MapUtil.getTransformFromLatLon(nativeCrs))
.getEnvelopeInternal();
ReferencedEnvelope nativeEnv = new ReferencedEnvelope(env.getMinX(),
env.getMaxX(), env.getMinY(), env.getMaxY(), nativeCrs);
layer.setNativeMinX(env.getMinX());
layer.setNativeMinY(env.getMinY());
layer.setNativeMaxX(env.getMaxX());
layer.setNativeMaxY(env.getMaxY());
ReferencedEnvelope crs84Env = nativeEnv.transform(
MapUtil.LATLON_PROJECTION, true);
// This is to fix when non-polar coverages cross poles or opposite
// meridian
// This will completely break polar coverages
double minx = crs84Env.getMinX();
double miny = crs84Env.getMinY();
double maxx = crs84Env.getMaxX();
double maxy = crs84Env.getMaxY();
if (maxx > 180 || minx < -180) {
// coverage crosses opposite meridian, advertise all the way around
minx = -180;
maxx = 180;
}
if (maxy > 90) {
// coverage crosses north pole, truncate
maxy = 90;
}
if (miny < -90) {
// coverage crosses south pole, truncate
miny = -90;
}
return new ReferencedEnvelope(minx, maxx, miny, maxy,
crs84Env.getCoordinateReferenceSystem());
}
@Override
public String getLayerName(GridRecord rec) {
return createLayerName(rec);
}
public static String createLayerName(GridRecord rec) {
GridInfoRecord info = rec.getInfo();
GridCoverage cov = info.getLocation();
String levelName = info.getLevel().getMasterLevel().getName();
return info.getDatasetId() + OgcLayer.keySeparator + cov.getName()
+ OgcLayer.keySeparator + levelName;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.db.LayerCollector#copy(com.raytheon.uf
* .edex.ogc.common.db.SimpleLayer)
*/
@Override
protected GridCompositeLayer copy(GridCompositeLayer orig) {
return new GridCompositeLayer(orig);
}
}

View file

@ -1,108 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.List;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.operation.Projection;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.OgcException.Code;
import com.raytheon.uf.edex.ogc.common.spatial.NativeCrsAuthority;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 6, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GribNativeCrsAuthority implements NativeCrsAuthority {
public static final String ID = "grib";
private final CoreDao covDao = new CoreDao(
DaoConfig.forClass(GridCoverage.class));
private final IUFStatusHandler log = UFStatus.getHandler(this.getClass());
/* (non-Javadoc)
* @see com.raytheon.uf.edex.ogc.common.spatial.NativeCrsAuthority#lookup(java.lang.String)
*/
@Override
public CoordinateReferenceSystem lookup(String urn) throws OgcException {
if ( urn == null){
return null;
}
String local = urn.substring(NATIVE_CRS_PREFIX.length());
String[] parts = local.split(":");
try {
List<?> res = covDao.queryBySingleCriteria("name", parts[0]);
if (res == null || res.isEmpty()) {
return null;
}
GridCoverage cov = (GridCoverage) res.get(0);
return cov.getCrs();
} catch (DataAccessLayerException e) {
log.error("Unable to lookup coverage", e);
throw new OgcException(Code.InternalServerError, e);
}
}
/**
* @param cov
* @return Native CRS URN for coverage
*/
public static String createURN(GridCoverage cov) {
String name = cov.getName();
// TODO assumption that all native grid systems are projected
ProjectedCRS crs = (ProjectedCRS) cov.getCrs();
return createURN(name, crs);
}
/**
* @param coverageName
* @param crs
* @return Native CRS URN for coverage
*/
public static String createURN(String coverageName, ProjectedCRS crs) {
Projection conv = crs.getConversionFromBase();
ParameterValueGroup params = conv.getParameterValues();
String projName = params.getDescriptor().getName().getCode();
return NATIVE_CRS_PREFIX + coverageName + ":" + projName;
}
/* (non-Javadoc)
* @see com.raytheon.uf.edex.ogc.common.spatial.NativeCrsAuthority#getId()
*/
@Override
public String getId() {
return ID;
}
}

View file

@ -1,402 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Conjunction;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Restrictions;
import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.database.plugin.PluginDao;
import com.raytheon.uf.edex.database.plugin.PluginFactory;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.OgcException.Code;
import com.raytheon.uf.edex.ogc.common.OgcLayer;
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer;
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
import com.raytheon.uf.edex.ogc.common.level.LevelDimUtil;
import com.raytheon.uf.edex.ogc.common.time.ForecastTimeUtil;
import com.raytheon.uf.edex.plugin.dataset.urn.CFNameLookup;
/**
*
* @author bclement
* @version 1.0
*/
public class GribRecordFinder {
public static final String INFO_ALIAS = "info_alias";
public static final String LEVEL_ALIAS = "level_alias";
public static final String MASTER_LEVEL_ALIAS = "master_level_alias";
public static final String COV_ALIAS = "cov_alias";
public static final String INFO = "info";
public static final String LEVEL = "info_alias.level";
public static final String LEVLE_ONE = LEVEL_ALIAS + ".levelonevalue";
public static final String LEVLE_TWO = LEVEL_ALIAS + ".leveltwovalue";
public static final String MASTER_LEVEL = LEVEL_ALIAS + ".masterLevel";
public static final String LEVEL_UNIT = MASTER_LEVEL_ALIAS + ".unitString";
public static final String LEVEL_NAME = MASTER_LEVEL_ALIAS + ".name";
public static final String DS_NAME = INFO_ALIAS + ".datasetId";
public static final String COVERAGE = INFO_ALIAS + ".location";
public static final String COVERAGE_NAME = COV_ALIAS + ".name";
public static final String PARAM = INFO_ALIAS + ".parameter";
public static final String PARAM_ALIAS = "param_alias";
public static final String PARAM_ABBV = PARAM_ALIAS + ".abbreviation";
public static final String REF_TIME = "dataTime.refTime";
public static final String FCST_TIME = "dataTime.fcstTime";
public static class Comp implements Comparator<GridRecord> {
/*
* (non-Javadoc)
*
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(GridRecord left, GridRecord right) {
Date rightRef = right.getDataTime().getRefTime();
Date leftRef = left.getDataTime().getRefTime();
int rval = rightRef.compareTo(leftRef);
if (rval == 0) {
GridInfoRecord leftInfo = left.getInfo();
GridInfoRecord rightInfo = right.getInfo();
// FIXME this doesn't take units into account
Level leftLevel = leftInfo.getLevel();
Level rightLevel = rightInfo.getLevel();
rval = (int) (leftLevel.getLevelonevalue() - rightLevel
.getLevelonevalue());
if (rval == 0) {
if (leftInfo.getEnsembleId() != null) {
if (rightInfo.getEnsembleId() != null) {
rval = leftInfo.getEnsembleId().compareTo(
rightInfo.getEnsembleId());
} else {
rval = 1;
}
} else {
if (rightInfo.getEnsembleId() != null) {
rval = -1;
} else {
rval = 0;
}
}
}
}
return rval;
}
}
public static List<GridRecord> findWms(
LayerTransformer<GribDimension, GridParamLayer> transformer,
String key, String layerName, Date time,
Map<String, String> dimensions) throws OgcException {
GridParamLayer l = getLayer(transformer, layerName);
SortedSet<DataTime> times = new ForecastTimeUtil().getDataTimes(l,
time, dimensions);
return findInternal(l, transformer, key, times, dimensions,
parseWmsId(layerName));
}
public static List<GridRecord> findWms(
LayerTransformer<GribDimension, GridParamLayer> transformer,
String key, String layerName, String time,
Map<String, String> dimensions) throws OgcException {
GridParamLayer l = getLayer(transformer, layerName);
SortedSet<DataTime> times = new ForecastTimeUtil().getDataTimes(l,
time, dimensions);
return findInternal(l, transformer, key, times, dimensions,
parseWmsId(layerName));
}
protected static List<GridRecord> findInternal(GridParamLayer l,
LayerTransformer<GribDimension, GridParamLayer> transformer,
String key, SortedSet<DataTime> times,
Map<String, String> dimensions, Criterion idCrit)
throws OgcException {
Criterion levelCrit = getLevel(dimensions, l);
String param = ogcToDbParameter(l.getParameter());
// TODO ensure consistency in which level gets returned
// TODO add support for more dimensions
return query(key, times, param, idCrit, levelCrit);
}
public static GridParamLayer getLayer(
LayerTransformer<GribDimension, GridParamLayer> transformer,
String layerName) throws OgcException {
GridParamLayer rval;
try {
rval = transformer.find(layerName);
} catch (OgcException e) {
throw new OgcException(Code.InternalServerError, e);
}
if (rval == null) {
throw new OgcException(Code.LayerNotDefined);
}
return rval;
}
protected static String getIntDim(Map<String, String> dimensions,
String key, GribLayer layer) throws OgcException {
String rval = getDim(dimensions, key, layer);
if (rval != null) {
try {
Integer i = Integer.parseInt(rval);
rval = i.toString();
} catch (Exception e) {
throw new OgcException(Code.InvalidDimensionValue, key
+ " must be a bare integer");
}
}
return rval;
}
protected static String getDim(Map<String, String> dimensions, String key,
GribLayer layer) {
String rval = dimensions.get(key);
if (rval == null) {
SimpleDimension dim = layer.getDimension(key);
rval = dim.getDefaultValue(layer);
}
return rval;
}
/**
* @param dimensions
* @param l
* @return null if level value not in dimensions and not in layer
* @throws OgcException
*/
protected static Criterion getLevel(Map<String, String> dimensions,
GribLayer layer) throws OgcException {
String dimName = null;
// find level dimension in request
for (String dim : dimensions.keySet()) {
String lower = dim.toLowerCase();
if (lower.startsWith(LevelDimUtil.LEVEL_DIM_PREFIX.toLowerCase())) {
dimName = dim;
break;
}
}
SimpleDimension dim;
String value;
if (dimName == null) {
return null;
} else {
dim = layer.getDimension(dimName);
if (dim == null) {
return null;
}
value = dimensions.get(dimName);
}
// undo any case changes
dimName = dim.getName();
return parseLevel(dimName, value, dim.getUnits());
}
@SuppressWarnings("unchecked")
protected static List<GridRecord> query(String key,
SortedSet<DataTime> times, String param, Criterion idCrit,
Criterion levelCrit) throws OgcException {
Session sess = null;
try {
PluginDao dao = PluginFactory.getInstance().getPluginDao(key);
SessionFactory sessFact = dao.getSessionFactory();
sess = sessFact.openSession();
Criteria criteria = sess.createCriteria(GridRecord.class);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
Disjunction or = Restrictions.disjunction();
Criterion paramCrit = Restrictions.eq(PARAM_ABBV, param);
for (DataTime dt : times) {
Conjunction and = Restrictions.conjunction();
and.add(idCrit).add(paramCrit);
if (levelCrit != null) {
and.add(levelCrit);
}
and.add(getTimeCrit(dt));
or.add(and);
}
criteria.add(or);
modCriteria(criteria);
List<GridRecord> res = (List<GridRecord>) criteria.list();
return res;
} catch (Exception e) {
throw new OgcException(Code.InternalServerError);
} finally {
if (sess != null) {
sess.close();
}
}
}
/**
* @param dt
* @return
*/
private static Criterion getTimeCrit(DataTime dt) {
return Restrictions.and(Restrictions.eq(FCST_TIME, dt.getFcstTime()),
Restrictions.eq(REF_TIME, dt.getRefTime()));
}
/**
* @param dimName
* @param value
* @param defaultUnits
* @return
* @throws OgcException
*/
public static Criterion parseLevel(String dimName, String value,
String defaultUnits) throws OgcException {
Level level = LevelDimUtil.parseLevel(dimName, value, defaultUnits);
if (level == null) {
return Restrictions.eq(LEVEL_NAME,
dimName.substring(LevelDimUtil.LEVEL_DIM_PREFIX.length()));
}
Criterion nameEq = Restrictions.eq(LEVEL_NAME, level.getMasterLevel()
.getName());
Conjunction and = Restrictions.conjunction();
and.add(nameEq);
and.add(Restrictions.eq(LEVLE_ONE, level.getLevelonevalue()));
and.add(Restrictions.eq(LEVLE_TWO, level.getLeveltwovalue()));
String units = level.getMasterLevel().getUnitString();
if (units != null) {
and.add(Restrictions.eq(LEVEL_UNIT, units));
} else {
and.add(Restrictions.isNull(LEVEL_UNIT));
}
return and;
}
/**
* @param id
* @return
* @throws OgcException
*/
public static Criterion parseWcsId(String id) throws OgcException {
String[] parts = id.split(OgcLayer.keySeparator);
String model;
String coverage;
String level;
if (parts.length < 3) {
throw new OgcException(Code.InvalidFormat, "Invalid id format");
} else {
level = parts[2];
coverage = parts[1];
model = parts[0];
}
Conjunction and = Restrictions.conjunction();
and.add(Restrictions.eq(DS_NAME, model));
and.add(Restrictions.eq(COVERAGE_NAME, coverage));
and.add(Restrictions.eq(LEVEL_NAME, level));
return and;
}
/**
* @param id
* @return
* @throws OgcException
*/
public static Criterion parseWmsId(String id) throws OgcException {
String[] parts = id.split(OgcLayer.keySeparator);
String model;
String coverage;
String level;
String param;
if (parts.length < 4) {
throw new OgcException(Code.InvalidFormat, "Invalid id format");
} else {
level = parts[3];
coverage = parts[1];
model = parts[0];
param = ogcToDbParameter(parts[2]);
}
Conjunction and = Restrictions.conjunction();
and.add(Restrictions.eq(DS_NAME, model));
and.add(Restrictions.eq(COVERAGE_NAME, coverage));
and.add(Restrictions.eq(LEVEL_NAME, level));
and.add(Restrictions.eq(PARAM_ABBV, param));
return and;
}
/**
* Add grid aliases to criteria
*
* @param criteria
* @return
*/
public static Criteria modCriteria(Criteria criteria) {
criteria = criteria.createAlias(INFO, INFO_ALIAS);
criteria = criteria.createAlias(PARAM, PARAM_ALIAS);
criteria = criteria.createAlias(LEVEL, LEVEL_ALIAS);
criteria = criteria.createAlias(MASTER_LEVEL, MASTER_LEVEL_ALIAS);
return criteria.createAlias(COVERAGE, COV_ALIAS);
}
/**
* Convert OGC parameter name to name stored in database
*
* @param parameter
* @return
*/
public static String ogcToDbParameter(String parameter) {
return CFNameLookup.getInstance().getNCEPFromCF(parameter);
}
/**
* Convert parameter name stored in database to OGC name
*
* @param parameter
* @return
*/
public static String dbToOgcParameter(String parameter) {
return CFNameLookup.getInstance().getCFFromNCEP(parameter);
}
}

View file

@ -1,459 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import javax.measure.unit.Unit;
import javax.xml.bind.DatatypeConverter;
import org.apache.commons.collections.map.LRUMap;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.hibernate.Criteria;
import org.hibernate.criterion.Conjunction;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Disjunction;
import org.hibernate.criterion.Restrictions;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.ProjectedCRS;
import com.raytheon.uf.common.dataplugin.PluginProperties;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer;
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
import com.raytheon.uf.edex.ogc.common.level.LevelDimUtil;
import com.raytheon.uf.edex.ogc.common.spatial.AltUtil;
import com.raytheon.uf.edex.ogc.common.spatial.Composite3DBoundingBox;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate.Reference;
import com.raytheon.uf.edex.plugin.unitconverter.UnitLookup;
import com.raytheon.uf.edex.wcs.WcsException;
import com.raytheon.uf.edex.wcs.WcsException.Code;
import com.raytheon.uf.edex.wcs.reg.CoverageTransform;
import com.raytheon.uf.edex.wcs.reg.DefaultWcsSource;
import com.raytheon.uf.edex.wcs.reg.RangeAxis;
import com.raytheon.uf.edex.wcs.reg.RangeField;
/**
* TODO Add Description
*
* @author jelkins
* @version 1.0
*/
public class GribWcsSource extends
DefaultWcsSource<GribDimension, GribLayer, GridRecord> {
private CoverageTransform<GribDimension, GribLayer> _cTransform;
private static final String PARAM_KEY = GribDimension.PARAM_DIM;
/**
* @param props
* @param layerTable
*/
public GribWcsSource(PluginProperties props,
LayerTransformer<GribDimension, GribLayer> transformer,
GribLayerCollector collector) {
super(props, transformer);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getCoverageTransform()
*/
@Override
public CoverageTransform<GribDimension, GribLayer> getCoverageTransform() {
if (_cTransform == null) {
_cTransform = new CoverageTransform<GribDimension, GribLayer>(
transformer.getKey()) {
@Override
protected List<RangeField> getRangeFields(GribLayer layer) {
List<RangeField> rval = new ArrayList<RangeField>();
SimpleDimension params = layer
.getDimension(GribDimension.PARAM_DIM);
for (String name : params.getValues()) {
rval.add(new RangeField(name, null));
}
SimpleDimension refDim = layer
.getDimension(GribDimension.REFTIME_DIM);
rval.add(convert(refDim));
return rval;
}
protected RangeField convert(SimpleDimension dim) {
String name = dim.getName();
Set<String> fromVals = dim.getValues();
String units = dim.getUnits();
RangeField rf = new RangeField(name, null);
List<RangeAxis> axis = new ArrayList<RangeAxis>(1);
if (units == null) {
// use dim name as axis label
units = name;
}
axis.add(new RangeAxis(units, fromVals));
rf.setAxis(axis);
return rf;
}
@SuppressWarnings("unchecked")
private final Map<String, Unit<?>> cache = Collections
.synchronizedMap(new LRUMap(3));
private Unit<?> getUnit(String str) {
Unit<?> rval = cache.get(str);
if (rval == null) {
rval = Unit.valueOf(str);
cache.put(str, rval);
}
return rval;
}
@Override
protected VerticalCoordinate getVertical(GribLayer layer)
throws WcsException {
if (!layer.isVertical()) {
return null;
}
List<GribDimension> levels = LayerTransformer
.getDimsByPrefix(layer,
LevelDimUtil.LEVEL_DIM_PREFIX);
if (levels.isEmpty()) {
log.error("attempted to get vertical component of empty layer");
throw new WcsException(Code.InternalServerError);
}
// TODO get sample that represents majority
SimpleDimension sample = levels.get(0);
Unit<?> targetUnits = getUnit(sample.getUnits());
String levelName = sample.getName().substring(
LevelDimUtil.LEVEL_DIM_PREFIX.length());
Reference targetRef = VerticalLevelLookup
.getReference(levelName);
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (SimpleDimension l : levels) {
String unitStr = l.getUnits();
Unit<?> unit = cache.get(unitStr);
if (unit == null) {
unit = Unit.valueOf(unitStr);
cache.put(unitStr, unit);
}
levelName = sample.getName().substring(
LevelDimUtil.LEVEL_DIM_PREFIX.length());
Reference ref = VerticalLevelLookup
.getReference(levelName);
for ( String val : l.getValues()){
VerticalCoordinate vert = parseLevelValue(val,
unit, ref);
VerticalCoordinate convert = AltUtil.convert(
targetUnits, targetRef, vert);
min = Math.min(min, convert.getMin());
max = Math.max(max, convert.getMax());
}
}
return new VerticalCoordinate(min, max, targetUnits,
targetRef);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.CoverageTransform#getBboxes(
* com.raytheon.uf.edex.ogc.common.db.SimpleLayer)
*/
@Override
protected List<Composite3DBoundingBox> getBboxes(GribLayer layer)
throws WcsException {
List<Composite3DBoundingBox> rval = new ArrayList<Composite3DBoundingBox>(
2);
VerticalCoordinate vert = getVertical(layer);
ReferencedEnvelope crs84Horiz = getHorizontal(layer);
rval.add(new Composite3DBoundingBox(crs84Horiz, vert));
try {
GribLayer griblayer = (GribLayer) layer;
CoordinateReferenceSystem crs = CRS.parseWKT(griblayer
.getCrsWkt());
ReferencedEnvelope nativeHoriz = new ReferencedEnvelope(
griblayer.getNativeMinX(),
griblayer.getNativeMaxX(),
griblayer.getNativeMinY(),
griblayer.getNativeMaxY(), crs);
String native2DCrsUrn = GribNativeCrsAuthority
.createURN(griblayer.getCoverageName(),
(ProjectedCRS) crs);
rval.add(new Composite3DBoundingBox(nativeHoriz,
native2DCrsUrn, vert));
} catch (FactoryException e) {
log.error("Unable to determine native BBOX", e);
}
return rval;
}
};
}
return _cTransform;
}
private void addToMap(Map<String, Set<String>> map, String key, String item) {
Set<String> list = map.get(key);
if (list == null) {
list = new TreeSet<String>();
map.put(key, list);
}
list.add(item);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#parseFields(java.util.List)
*/
@Override
protected Map<String, Set<String>> parseFields(List<RangeField> fields)
throws WcsException {
if (fields == null) {
return new HashMap<String, Set<String>>(0);
}
Map<String, Set<String>> rval = new HashMap<String, Set<String>>(
fields.size());
for (RangeField rf : fields) {
String key = rf.getIdentifier().toLowerCase();
if (rf.getAxis() == null || rf.getAxis().isEmpty()) {
addToMap(rval, PARAM_KEY, rf.getIdentifier());
continue;
}
for (RangeAxis ra : rf.getAxis()) {
Set<String> keys = ra.getKeys();
if (keys != null && !keys.isEmpty()) {
rval.put(key, keys);
break;
}
}
}
return rval;
}
/**
* @param val
* @return
* @throws WcsException
*/
private VerticalCoordinate parseLevelValue(String val, Unit<?> unit,
Reference ref) throws WcsException {
Matcher m = LevelDimUtil.levelPattern.matcher(val);
if (m.matches()) {
double val1 = Double.parseDouble(m.group(1));
if (m.group(3) == null) {
return new VerticalCoordinate(val1, unit, ref);
} else {
double val2 = Double.parseDouble(m.group(3));
return new VerticalCoordinate(val1, val2, unit, ref);
}
}
throw new WcsException(Code.InvalidParameterValue,
"Invalid level field value: " + val);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getScalarField()
*/
@Override
protected String getScalarField() {
return GribRecordFinder.PARAM_ABBV;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getFilterClause(java.lang
* .String, com.raytheon.uf.common.time.DataTime, java.util.Map)
*/
@Override
protected Conjunction getFilterClause(String id, DataTime time,
Map<String, Set<String>> fields) throws WcsException {
Conjunction and = Restrictions.conjunction();
try {
and.add(GribRecordFinder.parseWcsId(id));
} catch (OgcException e) {
throw new WcsException(e);
}
for (Entry<String, Set<String>> e : fields.entrySet()) {
if (e.getKey().equalsIgnoreCase(GribDimension.REFTIME_DIM)) {
Set<String> values = e.getValue();
if (values == null || values.isEmpty()) {
continue;
}
if (values.size() == 1) {
Calendar cal = DatatypeConverter.parseDateTime(values
.iterator().next());
and.add(Restrictions.eq(GribRecordFinder.REF_TIME,
cal.getTime()));
continue;
}
Disjunction or = Restrictions.disjunction();
Iterator<String> iter = values.iterator();
while (iter.hasNext()) {
String val = iter.next();
Calendar cal = DatatypeConverter.parseDateTime(val);
or.add(Restrictions.eq(GribRecordFinder.REF_TIME,
cal.getTime()));
}
and.add(or);
}
}
addIfNotNull(and, parseTime(time));
and.add(Restrictions.not(Restrictions.like(GribRecordFinder.PARAM_ABBV,
"static%")));
return and;
}
/**
* Add criteria to conjunction if not null
*
* @param and
* @param crit
*/
private void addIfNotNull(Conjunction and, Criterion crit) {
if (crit != null) {
and.add(crit);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getScalarValue(com.raytheon
* .uf.common.dataplugin.PluginDataObject)
*/
@Override
protected String getScalarValue(GridRecord record) throws WcsException {
return GribRecordFinder.dbToOgcParameter(new GridFieldAdapter()
.getCoverageField(record));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getAltitude(com.raytheon
* .uf.common.dataplugin.PluginDataObject)
*/
@Override
protected VerticalCoordinate getAltitude(GridRecord record)
throws WcsException {
return new GridVerticalEnabler().getVerticalCoordinate(record);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getScalarUnit(com.raytheon
* .uf.common.dataplugin.PluginDataObject)
*/
@Override
protected Unit<?> getScalarUnit(GridRecord record) {
return record.getInfo().getParameter().getUnit();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#isUpPositive(com.raytheon
* .uf.common.dataplugin.PluginDataObject)
*/
@Override
protected boolean isUpPositive(GridRecord record) {
MasterLevel masterLevel = record.getInfo().getLevel()
.getMasterLevel();
return !"DEC".equalsIgnoreCase(masterLevel.getType());
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#modCriteria(org.hibernate
* .Criteria)
*/
@Override
protected Criteria modCriteria(Criteria criteria) {
return GribRecordFinder.modCriteria(criteria);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getScalarKey()
*/
@Override
protected String getScalarKey() {
return PARAM_KEY;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getUcarUnit(com.raytheon
* .uf.common.dataplugin.PluginDataObject)
*/
@Override
protected ucar.units.Unit getUcarUnit(GridRecord record) {
Unit<?> parameterUnitObject = record.getInfo().getParameter().getUnit();
return UnitLookup.getInstance().getUcarFromJsr(parameterUnitObject);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getScalarCrit(java.lang
* .String)
*/
@Override
protected Criterion getScalarCrit(String value) {
return super.getScalarCrit(GribRecordFinder.ogcToDbParameter(value));
}
}

View file

@ -1,224 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.Date;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
/**
* Grid layer that sorts dimensions by parameter
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 27, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GridCompositeLayer extends GribLayer {
private static final long serialVersionUID = 6178813246077412635L;
@XmlElement
@DynamicSerializeElement
protected HashMap<String, TreeSet<GribDimension>> dimensions = new HashMap<String, TreeSet<GribDimension>>();
@XmlElement
@DynamicSerializeElement
protected HashMap<String, TreeSet<Date>> timeMap = new HashMap<String, TreeSet<Date>>();
/**
*
*/
public GridCompositeLayer() {
super();
}
/**
* @param other
*/
public GridCompositeLayer(GridCompositeLayer other) {
super(other);
this.dimensions = new HashMap<String, TreeSet<GribDimension>>(
other.dimensions.size());
for (Entry<String, TreeSet<GribDimension>> e : other.dimensions
.entrySet()) {
TreeSet<GribDimension> set = new TreeSet<GribDimension>();
GribDimension.copy(set, e.getValue());
this.dimensions.put(e.getKey(), set);
}
this.timeMap = new HashMap<String, TreeSet<Date>>(other.timeMap.size());
for (Entry<String, TreeSet<Date>> e : other.timeMap.entrySet()) {
this.timeMap.put(e.getKey(), new TreeSet<Date>(e.getValue()));
}
}
@Override
public Set<GribDimension> getDimensions() {
HashMap<String, GribDimension> byDim = new HashMap<String, GribDimension>();
for (Entry<String, TreeSet<GribDimension>> e : dimensions.entrySet()) {
for (GribDimension dim : e.getValue()) {
GribDimension aggregate = byDim.get(dim.getName());
if (aggregate == null) {
byDim.put(dim.getName(), dim);
continue;
}
aggregate.getValues().addAll(dim.getValues());
}
}
return new TreeSet<GribDimension>(byDim.values());
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.ogc.common.db.SimpleLayer#getTimes()
*/
@Override
public TreeSet<Date> getTimes() {
TreeSet<Date> rval = new TreeSet<Date>();
for (Entry<String, TreeSet<Date>> e : timeMap.entrySet()) {
rval.addAll(e.getValue());
}
return rval;
}
/**
* Add time for parameter
*
* @param parameter
* @param time
*/
public void addTime(String parameter, Date time) {
TreeSet<Date> set = timeMap.get(parameter);
if (set == null) {
set = new TreeSet<Date>();
timeMap.put(parameter, set);
}
set.add(time);
}
/**
* @param parameter
* @return empty list if parameter has no times
*/
public TreeSet<Date> getTimes(String parameter) {
TreeSet<Date> treeSet = timeMap.get(parameter);
if (treeSet == null) {
return new TreeSet<Date>();
} else {
return new TreeSet<Date>(treeSet);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.db.SimpleLayer#updateDates(com.raytheon
* .uf.edex.ogc.common.db.SimpleLayer)
*/
@Override
public void updateDates(SimpleLayer<GribDimension> other) {
if (!(other instanceof GridCompositeLayer)) {
return;
}
GridCompositeLayer shiny = (GridCompositeLayer) other;
for (Entry<String, TreeSet<Date>> e : shiny.timeMap.entrySet()) {
TreeSet<Date> thisSet = this.timeMap.get(e.getKey());
if (thisSet == null) {
this.timeMap.put(e.getKey(), new TreeSet<Date>(e.getValue()));
} else {
thisSet.addAll(e.getValue());
}
}
}
/**
* @param parameter
* @return empty set if no dimensions for parameter
*/
public TreeSet<GribDimension> getDimensions(String parameter) {
TreeSet<GribDimension> rval = dimensions.get(parameter);
if (rval == null) {
return new TreeSet<GribDimension>();
}
return rval;
}
/**
* @param parameter
* @param dims
*/
public void addDimensions(String parameter, TreeSet<GribDimension> dims) {
dimensions.put(parameter, dims);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.db.SimpleLayer#updateDims(com.raytheon
* .uf.edex.ogc.common.db.SimpleLayer)
*/
@Override
public void updateDims(SimpleLayer<GribDimension> other) {
if (!(other instanceof GridCompositeLayer)) {
return;
}
GridCompositeLayer shiny = (GridCompositeLayer) other;
for (String key : shiny.dimensions.keySet()) {
TreeSet<GribDimension> otherDims = shiny.dimensions.get(key);
TreeSet<GribDimension> thisDims = dimensions.get(key);
if (thisDims == null) {
thisDims = new TreeSet<GribDimension>();
GribDimension.copy(thisDims, otherDims);
dimensions.put(key, thisDims);
} else {
updateDimLists(thisDims, otherDims);
}
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.db.SimpleLayer#getDimension(java.lang
* .String)
*/
@Override
public GribDimension getDimension(String dimension) {
// TODO slow
return getDimMap(getDimensions()).get(dimension);
}
/**
* @return set of parameter names for composite layer
*/
public Set<String> getParameters() {
return dimensions.keySet();
}
}

View file

@ -1,58 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.edex.plugin.dataset.urn.CFNameLookup;
import com.raytheon.uf.edex.wcs.reg.IFieldAdapted;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 5, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GridFieldAdapter implements IFieldAdapted<GridRecord> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.reg.FieldAdapted#getCoverageField(java.lang.
* Object)
*/
@Override
public String getCoverageField(GridRecord record) {
CFNameLookup lookup = CFNameLookup.getInstance();
String abbr = record.getInfo().getParameter().getAbbreviation();
return lookup.getCFFromNCEP(abbr);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.reg.FieldAdapted#getSupportedClass()
*/
@Override
public Class<GridRecord> getSupportedClass() {
return GridRecord.class;
}
}

View file

@ -1,76 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
import com.raytheon.uf.edex.database.plugin.PurgeResults;
import com.raytheon.uf.edex.ogc.common.db.PurgeNotification;
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
/**
* Dao with purge notification for grid
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 6, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GridNotifyDao extends GridDao {
private final PurgeNotification notify;
/**
* @throws PluginException
*/
public GridNotifyDao() throws PluginException {
this(GridConstants.GRID);
}
/**
* @param pluginName
* @throws PluginException
*/
public GridNotifyDao(String pluginName) throws PluginException {
super(pluginName);
this.notify = new PurgeNotification(pluginName);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.plugin.grid.dao.GridDao#purgeExpiredData()
*/
@Override
public void purgeExpiredData() throws PluginException {
PurgeResults res = super.purgeExpiredDataWithResults();
notify.purgeExpiredData(res);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.plugin.grid.dao.GridDao#purgeAllData()
*/
@Override
public void purgeAllData() throws PluginException {
super.purgeAllData();
notify.purgeAllData();
}
}

View file

@ -1,116 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Grid layer that has dimensions for a single parameter
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 27, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GridParamLayer extends GribLayer {
private static final long serialVersionUID = -5614814725742630980L;
@XmlElement
@DynamicSerializeElement
protected TreeSet<GribDimension> dimensions;
@XmlElement
@DynamicSerializeElement
protected String parameter;
/**
*
*/
public GridParamLayer() {
super();
dimensions = new TreeSet<GribDimension>();
}
/**
* @param other
*/
public GridParamLayer(GridParamLayer other) {
super(other);
this.parameter = other.parameter;
this.dimensions = new TreeSet<GribDimension>();
GribDimension.copy(this.dimensions, other.dimensions);
}
/**
* @param other
*/
public GridParamLayer(String parameter, GridCompositeLayer other) {
super(other);
this.parameter = parameter;
this.times = new TreeSet<Date>(other.getTimes(parameter));
TreeSet<GribDimension> otherDims = other.getDimensions(parameter);
this.dimensions = new TreeSet<GribDimension>();
for (GribDimension dim : otherDims) {
if (dim.getName().equalsIgnoreCase(GribDimension.PARAM_DIM)) {
continue;
}
this.dimensions.add(new GribDimension(dim));
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.plugin.grib.ogc.GribLayer#getDimensions()
*/
@Override
public Set<GribDimension> getDimensions() {
return dimensions;
}
/**
* @return the parameter
*/
public String getParameter() {
return parameter;
}
/**
* @param parameter
* the parameter to set
*/
public void setParameter(String parameter) {
this.parameter = parameter;
}
/**
* @param dimensions
* the dimensions to set
*/
public void setDimensions(TreeSet<GribDimension> dimensions) {
this.dimensions = dimensions;
}
}

View file

@ -1,101 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate.Reference;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalEnabled;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 30, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GridVerticalEnabler implements VerticalEnabled<GridRecord> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.spatial.VerticalEnabled#getVerticalCoordinate
* (java.lang.Object)
*/
@Override
public VerticalCoordinate getVerticalCoordinate(GridRecord rec) {
if (rec.getInfo() == null) {
return null;
}
Level level = rec.getInfo().getLevel();
if (level == null) {
return null;
}
double l1 = level.getLevelonevalue();
double l2 = level.getLeveltwovalue();
MasterLevel master = level.getMasterLevel();
VerticalCoordinate.Reference ref;
if (master.getUnit() == null) {
ref = Reference.UNKNOWN;
} else if (SI.PASCAL.isCompatible(master.getUnit())) {
ref = Reference.PRESSURE_LEVEL;
} else if ("FHAG".equalsIgnoreCase(master.getName())) {
ref = Reference.ABOVE_GROUND;
} else if (SI.METER.isCompatible(master.getUnit())) {
ref = Reference.ABOVE_MSL;
} else {
ref = Reference.UNKNOWN;
}
if (l2 == Level.INVALID_VALUE) {
return new VerticalCoordinate(l1, master.getUnit(), ref);
} else {
return new VerticalCoordinate(l1, l2, master.getUnit(), ref);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.spatial.VerticalEnabled#getSupportedClass
* ()
*/
@Override
public Class<GridRecord> getSupportedClass() {
return GridRecord.class;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.ogc.common.spatial.VerticalEnabled#
* getDefaultVerticalUnit()
*/
@Override
public Unit<?> getDefaultVerticalUnit() {
return null;
}
}

View file

@ -1,117 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.OgcLayer;
import com.raytheon.uf.edex.ogc.common.db.ILayerCache;
/**
* Layer cache adapter to split composite levels into parameter levels
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 26, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class GridWmsLayerCache implements ILayerCache<GribDimension, GribLayer> {
private final ILayerCache<GribDimension, GridCompositeLayer> cache;
/**
* @param cache
*/
public GridWmsLayerCache(ILayerCache<GribDimension, GridCompositeLayer> cache) {
this.cache = cache;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.ogc.common.db.LayerCache#getLayers()
*/
@Override
public List<GribLayer> getLayers() throws OgcException {
List<GridCompositeLayer> origLayers = cache.getLayers();
List<GribLayer> rval = new ArrayList<GribLayer>(origLayers.size());
for (GridCompositeLayer orig : origLayers) {
String[] parts = StringUtils.split(orig.getName(),
OgcLayer.keySeparator);
for (String param : orig.getParameters()) {
rval.add(getParamLayer(orig, parts, param));
}
}
return rval;
}
/**
* @param orig
* @param name
* @param param
* @return
*/
private GridParamLayer getParamLayer(GridCompositeLayer orig, String name,
String param) {
GridParamLayer paramLayer = new GridParamLayer(param, orig);
paramLayer.setName(name);
return paramLayer;
}
/**
* @param orig
* @param parts
* @param param
* @return
*/
private GribLayer getParamLayer(GridCompositeLayer orig, String[] parts,
String param) {
LinkedList<String> partList = new LinkedList<String>(
Arrays.asList(parts));
partList.add(parts.length - 1, param);
return getParamLayer(orig,
StringUtils.join(partList, OgcLayer.keySeparator), param);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.db.LayerCache#getLayer(java.lang.String)
*/
@Override
public GribLayer getLayer(String name) throws OgcException {
String[] parts = StringUtils.split(name,
OgcLayer.keySeparator);
LinkedList<String> partList = new LinkedList<String>(
Arrays.asList(parts));
String param = partList.remove(parts.length - 2);
GridCompositeLayer layer = cache.getLayer(StringUtils.join(partList,
OgcLayer.keySeparator));
if (layer == null) {
return null;
}
return getParamLayer(layer, name, param);
}
}

View file

@ -1,45 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.grib.ogc;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate.Reference;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 26, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class VerticalLevelLookup {
public static Reference getReference(String masterLevel) {
if ("FH".equalsIgnoreCase(masterLevel)) {
return Reference.ABOVE_MSL;
}
if ("MB".equalsIgnoreCase(masterLevel)) {
return Reference.PRESSURE_LEVEL;
}
if ("FHAG".equalsIgnoreCase(masterLevel)) {
return Reference.ABOVE_GROUND;
}
return Reference.UNKNOWN;
}
}

View file

@ -1,241 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<styleRuleLibrary>
<styleRule>
<layerRegex>.*/DpT/SFC.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>90</upperMaximum>
<upperMinimum>-60</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/DpT/MB.*</layerRegex>
<levelRange level="level1" unit="hPa">
<upper>1050</upper>
<lower>500</lower>
</levelRange>
<mapRange type="log">
<upperMaximum>308.15</upperMaximum>
<lowerMaximum>278.15</lowerMaximum>
<upperMinimum>213.15</upperMinimum>
<lowerMinimum>213.15</lowerMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/DpT/MB.*</layerRegex>
<levelRange level="level1" unit="hPa">
<upper>500</upper>
<lower>250</lower>
</levelRange>
<mapRange type="log">
<upperMaximum>278.15</upperMaximum>
<lowerMaximum>233.15</lowerMaximum>
<upperMinimum>213.15</upperMinimum>
<lowerMinimum>173.15</lowerMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/WGS/SFC.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>36.0111111</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/T/SFC.*</layerRegex>
<mapRange type="linear">
<!-- 115F in Kelvin -->
<upperMaximum>319.261111</upperMaximum>
<!-- -40F in Kelvin -->
<upperMinimum>233.15</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/T/MB.*</layerRegex>
<levelRange level="level1" unit="hPa">
<upper>1050</upper>
<lower>500</lower>
</levelRange>
<mapRange type="log" >
<upperMaximum>318.15</upperMaximum>
<upperMinimum>233.15</upperMinimum>
</mapRange>
<!--
<mapRange type="linear" >
<upperMaximum>319.261111</upperMaximum>
<upperMinimum>233.15</upperMinimum>
</mapRange>
-->
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<increment>10</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/AV/[^/]*.*</layerRegex>
<mapRange type="linear" >
<!-- units in /s -->
<upperMaximum>0.00030</upperMaximum>
<upperMinimum>-0.00005</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/BLI/[^/]*.*</layerRegex>
<mapRange type="linear" >
<!-- units in C -->
<upperMaximum>15</upperMaximum>
<upperMinimum>-15</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/CAPE/SFC.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>5000</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
</styleRule>
<styleRule>
<layerRegex>.*/TCC/SFC.*</layerRegex>
<mapRange type="linear" >
<upperMaximum></upperMaximum>
<upperMinimum></upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<values>25 50 75</values>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/WS/MB.*</layerRegex>
<levelRange level="level1" unit="hPa">
<upper>1050</upper>
<lower>850</lower>
</levelRange>
<mapRange type="linear" >
<upperMaximum>75</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<increment>10</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/WS/MB.*</layerRegex>
<levelRange level="level1" unit="hPa">
<upper>850</upper>
<lower>200</lower>
</levelRange>
<mapRange type="linear" >
<upperMaximum>0</upperMaximum>
<upperMinimum>0</upperMinimum>
<lowerMaximum>200</lowerMaximum>
<lowerMinimum>75</lowerMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<increment>20</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/WS/SFC.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>75</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<increment>10</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/HTSGW/SFC.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>20</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<increment>5</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/ICIP/.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>1</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/gridded data</colorMapName>
<colorbarLabeling>
<increment>0.1</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/ICI/.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>5</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/icing_severity</colorMapName>
<colorbarLabeling>
<increment>1</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/SLDP/.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>1</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/icing_sld</colorMapName>
<colorbarLabeling>
<increment>0.25</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*/TPFI/.*</layerRegex>
<mapRange type="linear" >
<upperMaximum>1</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
<colorMapName>Grid/aviation_turbulence_index</colorMapName>
<colorbarLabeling>
<increment>0.25</increment>
</colorbarLabeling>
</styleRule>
<styleRule>
<layerRegex>.*</layerRegex>
<colorMapName>Grid/gridded data</colorMapName>
<mapRange type="linear" replaceable="true" >
<upperMaximum>255</upperMaximum>
<upperMinimum>0</upperMinimum>
</mapRange>
</styleRule>
</styleRuleLibrary>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.plugin.unitconverter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,8 +0,0 @@
#Thu May 09 11:58:40 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -1,12 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Unitconverter
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.unitconverter
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: ucar.nc2;bundle-version="1.0.0",
javax.measure;bundle-version="1.0.0",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.edex.plugin.unitconverter

View file

@ -1,4 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -1,199 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.plugin.unitconverter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import javax.measure.unit.UnitFormat;
import ucar.units.NoSuchUnitException;
import ucar.units.PrefixDBException;
import ucar.units.SpecificationException;
import ucar.units.UnitDBException;
import ucar.units.UnitFormatManager;
import ucar.units.UnitParseException;
import ucar.units.UnitSystemException;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 9, 2013 ekladstrup Initial creation
*
* </pre>
*
* @author ekladstrup
* @version 1.0
*/
public class UnitLookup {
private final IUFStatusHandler log = UFStatus.getHandler(this.getClass());
protected static UnitLookup instance = null;
protected Map<javax.measure.unit.Unit<?>, ucar.units.Unit> jsrToUcarMap = new HashMap<javax.measure.unit.Unit<?>, ucar.units.Unit>();
protected Map<ucar.units.Unit, javax.measure.unit.Unit<?>> ucarToJsrMap = new HashMap<ucar.units.Unit, javax.measure.unit.Unit<?>>();
protected UnitLookup() {
init();
}
protected void init() {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext[] searchHierarchy = pm
.getLocalSearchHierarchy(LocalizationType.EDEX_STATIC);
LocalizationFile unitFile = null;
for (LocalizationContext ctx : searchHierarchy) {
LocalizationFile localizationFile = pm.getLocalizationFile(ctx,
"wxsrv" + IPathManager.SEPARATOR + "units"
+ IPathManager.SEPARATOR + "unitMapping.tsv");
if (localizationFile.exists() && unitFile == null) {
unitFile = localizationFile;
}
}
File file = unitFile.getFile();
BufferedReader reader = null;
try {
if (file.exists() && file.canRead()) {
reader = new BufferedReader(new FileReader(file));
String line = reader.readLine();
while (line != null) {
if (!line.startsWith("#") && !line.trim().isEmpty()) {
String[] unitStrings = line.split("\t");
String jsrUnitString = unitStrings[0];
String udunitString = unitStrings[1];
try {
if (jsrUnitString != null
&& !jsrUnitString.isEmpty()
&& udunitString != null
&& !udunitString.isEmpty()) {
javax.measure.unit.Unit<?> jsrUnit = (javax.measure.unit.Unit<?>) UnitFormat
.getUCUMInstance().parseObject(
jsrUnitString);
ucar.units.Unit udunit = UnitFormatManager
.instance().parse(udunitString);
jsrToUcarMap.put(jsrUnit, udunit);
ucarToJsrMap.put(udunit, jsrUnit);
}
} catch (ParseException e) {
log.warn("Unable to parse javax unit string \""
+ jsrUnitString + "\"");
} catch (NoSuchUnitException e) {
log.warn("Unable to parse ucar unit string \""
+ udunitString + "\"");
} catch (UnitParseException e) {
log.warn("Unable to parse ucar unit string \""
+ udunitString + "\"");
} catch (SpecificationException e) {
log.warn("Unable to parse ucar unit string \""
+ udunitString + "\"");
} catch (UnitDBException e) {
log.warn("Unable to parse ucar unit string \""
+ udunitString + "\"");
} catch (PrefixDBException e) {
log.warn("Unable to parse ucar unit string \""
+ udunitString + "\"");
} catch (UnitSystemException e) {
log.warn("Unable to parse ucar unit string \""
+ udunitString + "\"");
}
}
line = reader.readLine();
}
} else {
log.error("Unable to open unit mapping file "
+ file.getAbsolutePath());
}
} catch (FileNotFoundException e1) {
// file not found even after file.exists() check
log.error(
"unit mapping file not found at " + file.getAbsolutePath(),
e1);
} catch (IOException e1) {
// failed to read file even after file.canRead() check
log.error(
"Unable to read unit mapping file "
+ file.getAbsolutePath(), e1);
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {
}
}
}
}
public static UnitLookup getInstance() {
if (instance == null) {
synchronized (UnitLookup.class) {
if (instance == null) {
instance = new UnitLookup();
}
}
}
return instance;
}
/**
* From a ucar unit return the jsr unit, or null if not found
*
* @param ucarUnit
* @return a jsr unit or null if not found
*/
public javax.measure.unit.Unit<?> getJsrFromUcar(ucar.units.Unit ucarUnit) {
return ucarToJsrMap.get(ucarUnit);
}
/**
* From a jsr unit return the ucar unit or null if not found
*
* @param jsrUnit
* @return
*/
public ucar.units.Unit getUcarFromJsr(javax.measure.unit.Unit<?> jsrUnit) {
return jsrToUcarMap.get(jsrUnit);
}
}

View file

@ -1,16 +0,0 @@
# jsr ucar
#tab separated
Pa*s^-1 kg.m-1.s-3
mm*s^-1 0.0010 m.s-1
mm 0.0010 m
Pa Pa
s^-1 s-1
m m
K K
K*s^-1 K.s-1
m*s^-1 m.s-1
degree_angle 0.017453292519943295 rad
s s
J*kg^-1 m2.s-2
% 0.01
kg*m^-2 kg.m-2
Can't render this file because it has a wrong number of fields in line 2.

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.wcs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,8 +0,0 @@
#Thu Feb 16 10:57:42 CST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -1,36 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Wcs
Bundle-SymbolicName: com.raytheon.uf.edex.wcs
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0",
net.opengis;bundle-version="1.0.2",
org.geotools;bundle-version="2.6.4",
com.raytheon.edex.common;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0",
org.apache.commons.codec;bundle-version="1.4.0",
org.apache.commons.pool;bundle-version="1.3.0",
ogc.tools.gml;bundle-version="1.0.2",
org.apache.commons.lang;bundle-version="2.3.0",
org.apache.camel;bundle-version="1.0.0",
org.apache.commons.cxf;bundle-version="1.0.0",
javax.persistence;bundle-version="1.0.0",
com.raytheon.uf.common.nc4;bundle-version="1.0.0",
com.raytheon.uf.edex.plugin.dataset.urn;bundle-version="1.0.0",
ucar.nc2;bundle-version="1.0.0",
org.apache.commons.collections;bundle-version="3.2.0",
com.raytheon.uf.edex.plugin.unitconverter;bundle-version="1.0.0",
com.raytheon.uf.common.spatial;bundle-version="1.0.0",
org.eclipse.jetty;bundle-version="7.6.9",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.edex.log;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.edex.wcs,
com.raytheon.uf.edex.wcs.format,
com.raytheon.uf.edex.wcs.provider,
com.raytheon.uf.edex.wcs.querystore,
com.raytheon.uf.edex.wcs.reg,
com.raytheon.uf.edex.wcs.request,
com.raytheon.uf.edex.wcs.soap1_1_2

View file

@ -1,135 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wcs="http://www.opengis.net/wcs/1.1" xmlns:wcs-soap="http://www.opengis.net/wcs/soap/1.1"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ows="http://www.opengis.net/ows/1.1" targetNamespace="http://wcs.edex.uf.raytheon.com"
xmlns:tns="http://wcs.edex.uf.raytheon.com" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- ============================================================== -->
<!-- WCS request/response types -->
<!-- ============================================================== -->
<wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema targetNamespace="http://www.opengis.net/wcs/1.1" xmlns:wcs="http://www.opengis.net/wcs/1.1" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
elementFormDefault="qualified" version="1.1.2">
<xsd:include schemaLocation="http://schemas.opengis.net/wcs/1.1/wcsAll.xsd" />
</xsd:schema>
</wsdl:types>
<!-- ============================================================== -->
<!-- WCS request messages -->
<!-- ============================================================== -->
<wsdl:message name="GetCapabilitiesRequest">
<wsdl:part name="Body" element="wcs:GetCapabilities" />
</wsdl:message>
<wsdl:message name="DescribeCoverageRequest">
<wsdl:part name="Body" element="wcs:DescribeCoverage" />
</wsdl:message>
<wsdl:message name="GetCoverageRequest">
<wsdl:part name="Body" element="wcs:GetCoverage" />
</wsdl:message>
<!-- ============================================================== -->
<!-- WCS response messages -->
<!-- ============================================================== -->
<wsdl:message name="GetCapabilitiesResponse">
<wsdl:part name="Body" element="wcs:Capabilities" />
</wsdl:message>
<wsdl:message name="DescribeCoverageResponse">
<wsdl:part name="Body" element="wcs:CoverageDescriptions" />
</wsdl:message>
<wsdl:message name="GetCoverageResponse">
<wsdl:part name="response" element="wcs:Coverages" />
<wsdl:part name="coverageData" type="xsd:base64Binary" />
</wsdl:message>
<wsdl:message name="ServiceExceptionReport">
<wsdl:part name="Body" element="ows:ExceptionReport" />
</wsdl:message>
<!-- ============================================================== -->
<!-- WCS port -->
<!-- ============================================================== -->
<wsdl:portType name="WcsPortType">
<wsdl:operation name="GetCapabilitiesOperation">
<wsdl:input message="tns:GetCapabilitiesRequest" />
<wsdl:output message="tns:GetCapabilitiesResponse" />
<wsdl:fault name="ServiceExceptionReport"
message="tns:ServiceExceptionReport" />
</wsdl:operation>
<wsdl:operation name="DescribeCoverageOperation">
<wsdl:input message="tns:DescribeCoverageRequest" />
<wsdl:output message="tns:DescribeCoverageResponse" />
<wsdl:fault name="ServiceExceptionReport"
message="tns:ServiceExceptionReport" />
</wsdl:operation>
<wsdl:operation name="GetCoverageOperation">
<wsdl:input message="tns:GetCoverageRequest" />
<wsdl:output message="tns:GetCoverageResponse" />
<wsdl:fault name="ServiceExceptionReport"
message="tns:ServiceExceptionReport" />
</wsdl:operation>
</wsdl:portType>
<!-- ============================ Bindings Section ================================ -->
<!-- ============================================================== -->
<!-- WCS binding -->
<!-- ============================================================== -->
<wsdl:binding name="WcsSoapBinding" type="tns:WcsPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetCapabilitiesOperation">
<soap:operation />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ServiceExceptionReport">
<soap:fault name="ServiceExceptionReport"
use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="DescribeCoverageOperation">
<soap:operation />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ServiceExceptionReport">
<soap:fault name="ServiceExceptionReport"
use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="GetCoverageOperation">
<soap:operation />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<mime:multipartRelated>
<mime:part>
<soap:body parts="response" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="coverageData" type="application/octet-stream"/>
</mime:part>
</mime:multipartRelated>
</wsdl:output>
<wsdl:fault name="ServiceExceptionReport">
<soap:fault name="ServiceExceptionReport"
use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<!-- ============================ Service Section ================================ -->
<wsdl:service name="wcs">
<wsdl:port name="Wcs" binding="tns:WcsSoapBinding">
<soap:address location="http://0.0.0.0:8086/wcs1.1.2"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

View file

@ -1,8 +0,0 @@
source.. = src/
bin.includes = .project,\
.classpath,\
META-INF/,\
build.properties,\
.settings/,\
.,\
res/

View file

@ -1,19 +0,0 @@
@startuml
node "EDEX Data Plug-in Adapter" {
() "Ingest Endpoint" as ingest
[Plug-in Data Decoder] as decoder
[Plug-in Layer Metadata Collector] as collector
}
database "PostgreSQL" {
frame "MetaData" {
[Layer Metadata] as layer
}
}
ingest -> decoder
decoder -> collector
collector -> layer
@enduml

View file

@ -1,42 +0,0 @@
@startuml
package "EDEX WCS Component" {
[WCS HTTP Endpoint] as wcshttp
[WCS SOAP Endpoint] as wcssoap
() "HTTP/REST/JETTY" -- wcshttp
() "HTTP/SOAP/CXF" -- wcssoap
[WCS 1.1.2 Provider] as wcs112
() "WCS Source" as isrc
}
node "EDEX Data Plug-in Adapter" {
[Plug-in WCS Source] as psrc
}
database "PostgreSQL" {
frame "MetaData" {
[Coverage Metadata] as layer
}
}
database "PyPies" {
frame "Data" {
[Data Record] as record
}
}
wcshttp -- wcs112
wcssoap -- wcs112
wcs112 -- isrc
isrc -left- psrc
psrc <-up- record
psrc <-up- layer
@enduml

View file

@ -1,53 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="wcsCoverageStore" class="com.raytheon.uf.edex.ogc.common.BasicFileStore" >
<constructor-arg value="wcsCoverageStore" />
</bean>
<bean id="netcdfWcsFormatter" class="com.raytheon.uf.edex.wcs.format.NetCdfFormatter">
<constructor-arg ref="wcsCoverageStore" />
</bean>
<bean id="wcsJaxbManager" class="com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager">
<constructor-arg>
<list>
<value>net.opengis.wcs.v_1_1_2.ObjectFactory</value>
<value>net.opengis.ows.v_1_1_0.ObjectFactory</value>
<value>net.opengis.gml.v_3_1_1.ObjectFactory</value>
<value>net.opengis.wms.v_1_3_0.ObjectFactory</value>
</list>
</constructor-arg>
</bean>
<bean id="wcsQueryStore" class="com.raytheon.uf.edex.wcs.querystore.WcsQueryStore">
<constructor-arg ref="wcsJaxbManager"/>
</bean>
<bean id="wcsProvider" class="com.raytheon.uf.edex.wcs.provider.OgcWcsProvider">
<constructor-arg ref="wcsJaxbManager"/>
<!-- these need to be kept in sync with services -->
<property name="restPort" value="8085" />
<property name="covStorePath" value="coverage" />
</bean>
<bean id="wcsStoreEndpoint" class="com.raytheon.uf.edex.wcs.CoverageStoreEndpoint">
<constructor-arg ref="wcsCoverageStore"/>
</bean>
<bean id="defactoEnabler" class="com.raytheon.uf.edex.wcs.request.DefactoEnabler"/>
<camelContext id="wcs-camel" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
<route id="WcsStoreRest">
<from uri="jetty:http://0.0.0.0:8085/coverage" />
<bean ref="wcsStoreEndpoint" />
</route>
</camelContext>
</beans>

View file

@ -1,35 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="wcsHandler" class="com.raytheon.uf.edex.wcs.WcsHttpHandler">
<constructor-arg ref="wcsProvider"/>
</bean>
<bean id="wcsHttpPool" class="com.raytheon.uf.edex.ogc.common.http.SingleHttpPool">
<constructor-arg ref="wcsHandler" />
</bean>
<bean id="wcserv" class="com.raytheon.uf.edex.ogc.common.http.OgcHttpEndpoint">
<constructor-arg ref="wcsHttpPool" />
</bean>
<bean id="defactoEnabler" class="com.raytheon.uf.edex.wcs.request.DefactoEnabler"/>
<camelContext id="wcs-rest-camel" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="errorHandler">
<route id="WcsRest">
<from uri="jetty:http://0.0.0.0:8085/wcs" />
<bean ref="wcserv" />
</route>
<route id="WcsRestDefacto">
<from uri="jetty:http://0.0.0.0:8085/dfo-wcs" />
<bean ref="defactoEnabler" />
<bean ref="wcserv" />
</route>
</camelContext>
</beans>

View file

@ -1,10 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="wcsWsdlInterceptor"
class="com.raytheon.uf.edex.ogc.common.soap.CustomWsdlInterceptor">
<constructor-arg value="META-INF/wsdl/wcswx.wsdl" />
</bean>
</beans>

View file

@ -1,28 +0,0 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="wcsSoapServiceImpl" class="com.raytheon.uf.edex.wcs.soap1_1_2.WcsImpl">
<constructor-arg ref="wcsProvider"/>
</bean>
<bean id="wcsWsdlInterceptor"
class="com.raytheon.uf.edex.ogc.common.soap.CustomWsdlInterceptor">
<constructor-arg value="META-INF/wsdl/wcs.wsdl" />
</bean>
<bean id="wcsSoapService" class="com.raytheon.uf.edex.ogc.common.soap.JaxWsConfigServerFactoryBean"
init-method="create">
<property name="serviceClass"
value="com.raytheon.uf.edex.wcs.soap1_1_2.IWcsPortType" />
<property name="address" value="http://0.0.0.0:8086/wcs1.1.2" />
<property name="serviceBean" ref="wcsSoapServiceImpl" />
<property name="mtomEnabled" value="true"/>
<property name="inInterceptors">
<list>
<ref bean="wcsWsdlInterceptor" />
</list>
</property>
</bean>
</beans>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.wcs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,8 +0,0 @@
#Thu Feb 16 10:57:42 CST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -1,130 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.OutputStream;
import java.security.InvalidParameterException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.cxf.helpers.IOUtils;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.ogc.common.BasicFileStore;
import com.raytheon.uf.edex.wcs.format.NetCdfFormatter;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 25, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoverageStoreEndpoint implements Processor {
private final BasicFileStore store;
private final IUFStatusHandler log = UFStatus.getHandler(this.getClass());
public static final String ID_HEADER = "id";
/**
* @param store
*/
public CoverageStoreEndpoint(BasicFileStore store) {
this.store = store;
}
/*
* (non-Javadoc)
*
* @see org.apache.camel.Processor#process(org.apache.camel.Exchange)
*/
@Override
public void process(Exchange ex) throws Exception {
HttpServletResponse response = ex.getIn().getBody(
HttpServletResponse.class);
Map<String, Object> headers = ex.getIn().getHeaders();
OutputStream out = null;
try {
String id = (String) headers.get(ID_HEADER);
File cov = getCoverage(id);
response.setContentType(NetCdfFormatter.CONTENT_TYPE);
out = response.getOutputStream();
sendFile(out, cov);
out.flush();
store.remove(id);
} catch (InvalidParameterException e) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
} catch (FileNotFoundException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (Exception e) {
log.error("Problem retrieving file from store", e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} finally {
if (out != null) {
out.close();
}
}
}
/**
* Retrieve file from store
*
* @param id
* @return
* @throws FileNotFoundException
* if file is not in store
*/
private File getCoverage(String id) throws FileNotFoundException {
File rval = store.getFile(id);
if (rval == null) {
throw new FileNotFoundException("No file in store with id: " + id);
}
return rval;
}
/**
* Stream file to out
*
* @param out
* @param f
* @throws Exception
*/
private void sendFile(OutputStream out, File f) throws Exception {
FileInputStream in = null;
try {
in = new FileInputStream(f);
IOUtils.copy(in, out);
} finally {
if (in != null) {
in.close();
}
}
}
}

View file

@ -1,102 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs;
import java.util.Map;
import net.opengis.wcs.v_1_1_2.CoveragesType;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 19, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoveragesHolder {
protected CoveragesType metadata;
protected Map<String, byte[]> data;
protected String contentType;
/**
* @param metadata
* @param data
*/
public CoveragesHolder(CoveragesType metadata, Map<String, byte[]> data) {
super();
this.metadata = metadata;
this.data = data;
}
/**
*
*/
public CoveragesHolder() {
// TODO Auto-generated constructor stub
}
/**
* @return the metadata
*/
public CoveragesType getMetadata() {
return metadata;
}
/**
* @param metadata
* the metadata to set
*/
public void setMetadata(CoveragesType metadata) {
this.metadata = metadata;
}
/**
* @return the data
*/
public Map<String, byte[]> getData() {
return data;
}
/**
* @param data
* the data to set
*/
public void setData(Map<String, byte[]> data) {
this.data = data;
}
/**
* @return the contentType
*/
public String getContentType() {
return contentType;
}
/**
* @param contentType
* the contentType to set
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
}

View file

@ -1,124 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import org.apache.commons.lang.BooleanUtils;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* WCS configuration
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 9, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class WcsConfig {
public static final String FORCE_KM_BBOX = "force.km.altitude";
private static final IUFStatusHandler log = UFStatus
.getHandler(WcsConfig.class);
private static Properties props = null;
static {
LocalizationFile confFile = findConfigFile();
if (confFile == null) {
log.warn("Unable to find custom id mapping properties");
props = new Properties();
} else {
props = loadConfig(confFile);
}
}
/**
* Find configuration file in localization
*
* @return null if not found
*/
private static LocalizationFile findConfigFile() {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext[] searchHierarchy = pm
.getLocalSearchHierarchy(LocalizationType.EDEX_STATIC);
for (LocalizationContext ctx : searchHierarchy) {
LocalizationFile localizationFile = pm.getLocalizationFile(ctx,
"wcs" + IPathManager.SEPARATOR + "wcsConfig.properties");
if (localizationFile.exists()) {
return localizationFile;
}
}
return null;
}
/**
* Load map from config
*
* @param idMapFile
* @return
*/
private static Properties loadConfig(LocalizationFile idMapFile) {
Properties props = new Properties();
File file = idMapFile.getFile();
try {
props.load(new FileInputStream(file));
} catch (Exception e) {
log.error("Unable to load WCS config: " + file, e);
}
return props;
}
/**
* Get property from config
*
* @param key
* @return null if property not set
*/
public static String getProperty(String key) {
if (props == null) {
return null;
}
return props.getProperty(key);
}
/**
* Return boolean value of property
*
* @param key
* @return false if property not set
*/
public static boolean isProperty(String key) {
if (props == null) {
return false;
}
return BooleanUtils.toBoolean(props.getProperty(key));
}
}

View file

@ -1,105 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* TODO Add Description
*
* @author ekladstrup
* @version 1.0
*/
@DynamicSerialize
public class WcsCoverageThriftReponse implements ISerializableObject {
@DynamicSerializeElement
private IDataRecord dataRecord;
@DynamicSerializeElement
private String crsString;
@DynamicSerializeElement
private String timeString;
@DynamicSerializeElement
private String envelopeString;
/**
* @return the dataRecord
*/
public IDataRecord getDataRecord() {
return dataRecord;
}
/**
* @param dataRecord
* the dataRecord to set
*/
public void setDataRecord(IDataRecord dataRecord) {
this.dataRecord = dataRecord;
}
/**
* @return the crsString
*/
public String getCrsString() {
return crsString;
}
/**
* @param crsString
* the crsString to set
*/
public void setCrsString(String crsString) {
this.crsString = crsString;
}
/**
* @return the timeString
*/
public String getTimeString() {
return timeString;
}
/**
* @param timeString
* the timeString to set
*/
public void setTimeString(String timeString) {
this.timeString = timeString;
}
/**
* @return the envelopeString
*/
public String getEnvelopeString() {
return envelopeString;
}
/**
* @param envelopeString
* the envelopeString to set
*/
public void setEnvelopeString(String envelopeString) {
this.envelopeString = envelopeString;
}
}

View file

@ -1,93 +0,0 @@
/*****************************************************************************************
* COPYRIGHT (c), 2006, RAYTHEON COMPANY
* ALL RIGHTS RESERVED, An Unpublished Work
*
* RAYTHEON PROPRIETARY
* If the end user is not the U.S. Government or any agency thereof, use
* or disclosure of data contained in this source code file is subject to
* the proprietary restrictions set forth in the Master Rights File.
*
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
* If the end user is the U.S. Government or any agency thereof, this source
* code is provided to the U.S. Government with Government Purpose Rights.
* Use or disclosure of data contained in this source code file is subject to
* the "Government Purpose Rights" restriction in the Master Rights File.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* Use or disclosure of data contained in this source code file is subject to
* the export restrictions set forth in the Master Rights File.
******************************************************************************************/
package com.raytheon.uf.edex.wcs;
import com.raytheon.uf.edex.ogc.common.OgcException;
/**
* TODO - Class comment here
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
*
* </pre>
*
* @author
* @version 1
*/
public class WcsException extends Exception {
public enum Code {
InvalidFormat, InvalidCRS, LayerNotDefined, StyleNotDefined, LayerNotQueryable, InvalidPoint, CurrentUpdateSequence, InvalidUpdateSequence, MissingDimensionValue, InvalidDimensionValue, OperationNotSupported, MissingParameterValue, InvalidParameterValue, NoApplicableCode, UnsupportedCombination, NotEnoughStorage, InvalidRequest, InternalServerError
}
private static final long serialVersionUID = 8797482743733419169L;
protected Code code;
public WcsException(OgcException ogc) {
this(decode(ogc.getCode().toString()), ogc.getMessage());
}
private static Code decode(String code) {
Code rval;
try {
rval = Code.valueOf(code);
} catch (Throwable t) {
rval = Code.NoApplicableCode;
}
return rval;
}
public WcsException(Code code) {
super();
this.code = code;
}
public WcsException(Code code, String message) {
super(message);
this.code = code;
}
public WcsException(Code code, Throwable cause) {
super(cause);
this.code = code;
}
public WcsException(Code code, String message, Throwable cause) {
super(message, cause);
this.code = code;
}
public Code getCode() {
return code;
}
public void setCode(Code code) {
this.code = code;
}
}

View file

@ -1,445 +0,0 @@
/*****************************************************************************************
* COPYRIGHT (c), 2006, RAYTHEON COMPANY
* ALL RIGHTS RESERVED, An Unpublished Work
*
* RAYTHEON PROPRIETARY
* If the end user is not the U.S. Government or any agency thereof, use
* or disclosure of data contained in this source code file is subject to
* the proprietary restrictions set forth in the Master Rights File.
*
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
* If the end user is the U.S. Government or any agency thereof, this source
* code is provided to the U.S. Government with Government Purpose Rights.
* Use or disclosure of data contained in this source code file is subject to
* the "Government Purpose Rights" restriction in the Master Rights File.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* Use or disclosure of data contained in this source code file is subject to
* the export restrictions set forth in the Master Rights File.
******************************************************************************************/
package com.raytheon.uf.edex.wcs;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.DatatypeConverter;
import net.opengis.ows.v_1_1_0.BoundingBoxType;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.OgcOperationInfo;
import com.raytheon.uf.edex.ogc.common.OgcResponse;
import com.raytheon.uf.edex.ogc.common.OgcServiceInfo;
import com.raytheon.uf.edex.ogc.common.http.MimeType;
import com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler;
import com.raytheon.uf.edex.ogc.common.http.OgcHttpRequest;
import com.raytheon.uf.edex.ogc.common.output.IOgcHttpResponse;
import com.raytheon.uf.edex.ogc.common.output.OgcResponseOutput;
import com.raytheon.uf.edex.ogc.common.output.ServletOgcResponse;
import com.raytheon.uf.edex.wcs.WcsException.Code;
import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType;
import com.raytheon.uf.edex.wcs.reg.RangeField;
import com.raytheon.uf.edex.wcs.reg.RangeParseException;
import com.raytheon.uf.edex.wcs.request.DefactoEnabler;
import com.raytheon.uf.edex.wcs.request.DescCoverageRequest;
import com.raytheon.uf.edex.wcs.request.GetCapRequest;
import com.raytheon.uf.edex.wcs.request.GetCoverageRequest;
import com.raytheon.uf.edex.wcs.request.GetDataRequest;
import com.raytheon.uf.edex.wcs.request.WcsRequest;
import com.raytheon.uf.edex.wcs.request.WcsRequest.Type;
/**
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
*
* </pre>
*
* @author
* @version 1
*/
public class WcsHttpHandler extends OgcHttpHandler {
protected WcsProvider provider;
public static final String REQUEST_HEADER = "request";
public static final String VERSION_HEADER = "version";
public static final String FORMAT_HEADER = "format";
public static final String UPDATESEQ_HEADER = "updatesequence";
public static final String BBOX_HEADER = "boundingbox";
public static final String MIME_HEADER = "Content-Type";
protected static final String CAP_PARAM = "getcapabilities";
protected static final String GET_PARAM = "getcoverage";
protected static final String DESC_PARAM = "describecoverage";
protected static final String GET_DATA_PARAM = "getdata";
protected static final String IDENTIFIERS = "identifiers";
protected static final String IDENTIFIER = "identifier";
protected static final String DOMAIN_SUBSET = "domainsubset";
protected static final String OUTPUT = "output";
protected static final String GROUP = "group";
protected static final String DATASET = "dataset";
protected static final String RANGE_SUBSET = "rangesubset";
protected static final String LAYER = "layer";
protected static final String TIME_SEQUENCE = "timesequence";
protected static final String STORE = "store";
protected static final String GRID_BASE_CRS = "gridbasecrs";
protected static final String GRID_TYPE = "gridtype";
protected static final String GRID_ORIGIN = "gridorigin";
protected static final String GRID_OFFSETS = "gridoffsets";
private final IUFStatusHandler log = UFStatus.getHandler(this.getClass());
public WcsHttpHandler(WcsProvider provider) {
this.provider = provider;
}
@Override
public void handle(OgcHttpRequest request) {
try {
handleInternal(request);
} catch (Exception e) {
log.error("Unable to handle request", e);
}
}
protected void handleInternal(OgcHttpRequest ogcRequest) throws Exception {
IOgcHttpResponse response = new ServletOgcResponse(
ogcRequest.getResponse());
HttpServletRequest httpRequest = ogcRequest.getRequest();
Map<String, Object> headers = ogcRequest.getHeaders();
OgcResponse rval = null;
OgcServiceInfo<WcsOpType> serviceInfo = getServiceInfo(httpRequest);
WcsRequest request;
if (ogcRequest.isPost()) {
InputStream is = httpRequest.getInputStream();
request = provider.getRequest(is);
} else {
request = getRequestFromHeaders(headers);
}
// Validate exception format parameter
rval = validateExceptionFormat(request);
if (rval != null) {
sendResponse(response, rval);
}
switch (request.getType()) {
case DescribeCoverage:
rval = provider.describeCoverageType(serviceInfo,
(DescCoverageRequest) request);
break;
case GetCapabilities:
rval = provider.getCapabilities(serviceInfo,
(GetCapRequest) request);
break;
case GetCoverage:
// get coverage does it's own output
GetCoverageRequest gcr = (GetCoverageRequest) request;
if (DefactoEnabler.HEADER_VALUE.equals(headers
.get(DefactoEnabler.HEADER_KEY))) {
gcr.setDefacto(true);
}
provider.getCoverage(serviceInfo, gcr, response);
return;
case ERROR:
rval = (OgcResponse) request.getRequest();
break;
default:
rval = provider.getError(new WcsException(
Code.OperationNotSupported, request.getType()
+ " not supported"), null);
break;
}
sendResponse(response, rval);
}
/**
* @param request
* @return
*/
private OgcResponse validateExceptionFormat(WcsRequest request) {
if (!request.getExceptionFormat().equalsIgnoreParams(
OgcResponse.TEXT_HTML_MIME)
&& !request.getExceptionFormat().equalsIgnoreParams(
OgcResponse.TEXT_XML_MIME)) {
return provider.getError(
new WcsException(Code.InvalidParameterValue,
"exceptions parameter invalid"),
OgcResponse.TEXT_XML_MIME);
}
return null;
}
private OgcServiceInfo<WcsOpType> getServiceInfo(HttpServletRequest request) {
// FIXME get address from spring
int port = request.getServerPort();
String base = "http://" + request.getServerName();
if (port != 80) {
base += ":" + port;
}
base += request.getPathInfo() + "?service=wcs";
OgcServiceInfo<WcsOpType> rval = new OgcServiceInfo<WcsOpType>(base);
rval.addOperationInfo(getOp(base, base, WcsOpType.GetCapabilities,
request.getServerName()));
rval.addOperationInfo(getOp(base, base, WcsOpType.DescribeCoverage,
request.getServerName()));
rval.addOperationInfo(getOp(base, base, WcsOpType.GetCoverage,
request.getServerName()));
return rval;
}
protected OgcOperationInfo<WcsOpType> getOp(String get, String post,
WcsOpType type, String host) {
OgcOperationInfo<WcsOpType> rval = new OgcOperationInfo<WcsOpType>(type);
rval.setHttpBaseHostname(host);
// FIXME get version from provider
rval.setHttpGetRes(get);
rval.setHttpPostRes(post);
rval.addVersion("1.1.2");
rval.addAcceptVersions("1.1.2");
rval.addService("WCS");
rval.addFormat("text/xml");
rval.setPostEncoding("XML");
return rval;
}
protected WcsRequest getRequestFromHeaders(Map<String, Object> headers)
throws OgcException {
WcsRequest rval = null;
Object obj = headers.get(REQUEST_HEADER);
MimeType exceptionFormat = OgcResponse.TEXT_XML_MIME;
if (obj instanceof String) {
exceptionFormat = getMimeType(headers, EXCEP_FORMAT_HEADER);
if (exceptionFormat == null) {
exceptionFormat = OgcResponse.TEXT_XML_MIME;
}
String req = (String) obj;
if (req.equalsIgnoreCase(CAP_PARAM)) {
rval = new GetCapRequest();
} else if (req.equalsIgnoreCase(DESC_PARAM)) {
rval = buildDescCoverageRequest(headers);
} else if (req.equalsIgnoreCase(GET_PARAM)) {
try {
rval = buildGetCoverageRequest(headers);
} catch (RangeParseException e) {
log.error(e.getLocalizedMessage(), e);
rval = new WcsRequest(Type.ERROR);
String msg = "Invalid range parameter";
WcsException ex = new WcsException(
Code.InvalidParameterValue, msg);
rval.setRequest(provider.getError(ex, exceptionFormat));
}
} else if (req.equalsIgnoreCase(GET_DATA_PARAM)) {
rval = buildGetDataRequest(headers);
}
}
if (rval == null) {
OgcResponse error = provider.getError(new WcsException(
Code.InvalidRequest, "Unable to decode request"),
exceptionFormat);
rval = new WcsRequest(Type.ERROR);
rval.setRequest(error);
}
rval.setExceptionFormat(exceptionFormat);
return rval;
}
private WcsRequest buildGetDataRequest(Map<String, Object> headers) {
GetDataRequest rval = new GetDataRequest();
String groupName = getHeader(GROUP, headers);
if (groupName != null) {
rval.setGroup(groupName);
}
String datasetName = getHeader(DATASET, headers);
if (datasetName != null) {
rval.setDataset(datasetName);
}
return rval;
}
private WcsRequest buildGetCoverageRequest(Map<String, Object> headers)
throws RangeParseException {
GetCoverageRequest rval = new GetCoverageRequest();
String identifier = getHeader(IDENTIFIER, headers);
rval.setIdentifier(identifier);
String format = getHeader(FORMAT_HEADER, headers);
rval.setFormat(format);
String timeSequence = getHeader(TIME_SEQUENCE, headers);
if (timeSequence != null) {
rval.setTimeSequence(parseTime(timeSequence));
}
String rangesubset = getHeader(RANGE_SUBSET, headers);
if (rangesubset != null) {
rval.setFields(RangeField.getRanges(rangesubset));
}
String bbox = getHeader(BBOX_HEADER, headers);
if (bbox != null) {
try {
rval.setBbox(parseBbox(bbox));
} catch (OgcException e) {
throw new RangeParseException(e.getMessage());
}
}
return rval;
}
protected DataTime parseTime(String timeStr) {
// TODO handle multi-times and periods in ISO 8601
Calendar cal = DatatypeConverter.parseDateTime(timeStr);
return new DataTime(cal);
}
private WcsRequest buildDescCoverageRequest(Map<String, Object> headers) {
DescCoverageRequest rval = new DescCoverageRequest();
String outputformat = getHeader(OUTPUT, headers);
if (outputformat != null) {
rval.setOutputformat(outputformat);
}
String[] identifiers = getHeaderArr(IDENTIFIERS, headers);
if (identifiers != null) {
rval.setIdentifiers(Arrays.asList(identifiers));
}
return rval;
}
protected BoundingBoxType parseBbox(String bbox) throws RangeParseException {
String[] parts = bbox.split(",");
BoundingBoxType rval = null;
if (parts.length == 5 || parts.length == 7) {
rval = new BoundingBoxType();
try {
final int pivot = parts.length / 2;
List<Double> mins = new ArrayList<Double>(pivot);
for (int i = 0; i < pivot; ++i) {
mins.add(Double.parseDouble(parts[i]));
}
List<Double> maxs = new ArrayList<Double>(pivot);
for (int i = pivot; i < pivot * 2; ++i) {
maxs.add(Double.parseDouble(parts[i]));
}
rval.setLowerCorner(mins);
rval.setUpperCorner(maxs);
rval.setCrs(parts[parts.length - 1]);
} catch (NumberFormatException e) {
throw new RangeParseException("Unable to parse bounding box");
}
} else {
throw new RangeParseException("Invalid bounding box format");
}
return rval;
}
protected String[] getHeaderArr(String name, Map<String, Object> headers) {
String[] rval;
String value = getHeader(name, headers);
if (value != null) {
rval = value.split(",");
} else {
rval = new String[0];
}
return rval;
}
protected String getHeader(String name, Map<String, Object> headers) {
Object obj = headers.get(name);
String rval = null;
if (obj != null && obj instanceof String) {
rval = (String) obj;
}
return rval;
}
protected void sendResponse(IOgcHttpResponse httpRes,
OgcResponse response) throws Exception {
OgcResponseOutput.output(response, httpRes);
}
protected String getLayerLevel(String rangesubset) {
String layerValue = "0";
if (rangesubset != null) {
int datasetIndex = rangesubset.indexOf(DATASET);
if (datasetIndex > -1) {
int layerIndex = rangesubset.indexOf(LAYER, datasetIndex);
if (layerIndex > -1) {
int layerStartIndex = rangesubset.indexOf("[", layerIndex);
if (layerStartIndex > -1) {
int layerEndIndex = rangesubset.indexOf("]",
layerStartIndex);
layerValue = rangesubset.substring(layerStartIndex + 1,
layerEndIndex);
}
}
}
}
return layerValue;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler#handleError(com.raytheon
* .uf.edex.ogc.common.OgcException, java.lang.String)
*/
@Override
protected OgcResponse handleError(OgcException e, MimeType exceptionFormat) {
return provider.getError(new WcsException(e), exceptionFormat);
}
}

View file

@ -1,123 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs;
import java.util.LinkedList;
import java.util.List;
public class WcsOperationInfo {
public enum Type {
GetCapabilities, GetCoverage, DescribeCoverage
}
protected Type type;
protected String httpPostRes;
protected String httpGetRes;
protected List<String> formats = new LinkedList<String>();
/**
*
*/
public WcsOperationInfo(Type type) {
this.type = type;
}
public WcsOperationInfo(Type type, String httpPostRes, String httpGetRes) {
this(type);
this.httpGetRes = httpGetRes;
this.httpPostRes = httpPostRes;
}
public void addFormat(String format) {
formats.add(format);
}
public boolean hasHttpPost() {
return httpPostRes != null;
}
public boolean hasHttpGet() {
return httpGetRes != null;
}
/**
* @return the httpPostRes
*/
public String getHttpPostRes() {
return httpPostRes;
}
/**
* @param httpPostRes
* the httpPostRes to set
*/
public void setHttpPostRes(String httpPostRes) {
this.httpPostRes = httpPostRes;
}
/**
* @return the httpGetRes
*/
public String getHttpGetRes() {
return httpGetRes;
}
/**
* @param httpGetRes
* the httpGetRes to set
*/
public void setHttpGetRes(String httpGetRes) {
this.httpGetRes = httpGetRes;
}
/**
* @return the type
*/
public Type getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(Type type) {
this.type = type;
}
/**
* @return the formats
*/
public List<String> getFormats() {
return formats;
}
/**
* @param formats
* the formats to set
*/
public void setFormats(List<String> formats) {
this.formats = formats;
}
}

View file

@ -1,66 +0,0 @@
/*****************************************************************************************
* COPYRIGHT (c), 2006, RAYTHEON COMPANY
* ALL RIGHTS RESERVED, An Unpublished Work
*
* RAYTHEON PROPRIETARY
* If the end user is not the U.S. Government or any agency thereof, use
* or disclosure of data contained in this source code file is subject to
* the proprietary restrictions set forth in the Master Rights File.
*
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
* If the end user is the U.S. Government or any agency thereof, this source
* code is provided to the U.S. Government with Government Purpose Rights.
* Use or disclosure of data contained in this source code file is subject to
* the "Government Purpose Rights" restriction in the Master Rights File.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* Use or disclosure of data contained in this source code file is subject to
* the export restrictions set forth in the Master Rights File.
******************************************************************************************/
package com.raytheon.uf.edex.wcs;
import java.io.InputStream;
import com.raytheon.uf.edex.ogc.common.OgcResponse;
import com.raytheon.uf.edex.ogc.common.OgcServiceInfo;
import com.raytheon.uf.edex.ogc.common.http.MimeType;
import com.raytheon.uf.edex.ogc.common.output.IOgcHttpResponse;
import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType;
import com.raytheon.uf.edex.wcs.request.DescCoverageRequest;
import com.raytheon.uf.edex.wcs.request.GetCapRequest;
import com.raytheon.uf.edex.wcs.request.GetCoverageRequest;
import com.raytheon.uf.edex.wcs.request.WcsRequest;
/**
* TODO - Class comment here
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
*
* </pre>
*
* @author
* @version 1
*/
public interface WcsProvider {
public OgcResponse getCapabilities(OgcServiceInfo<WcsOpType> serviceinfo,
GetCapRequest request);
public OgcResponse describeCoverageType(
OgcServiceInfo<WcsOpType> serviceinfo, DescCoverageRequest request);
public void getCoverage(OgcServiceInfo<WcsOpType> serviceinfo,
GetCoverageRequest request, IOgcHttpResponse response);
public WcsRequest getRequest(InputStream in);
public OgcResponse getError(WcsException e, MimeType exceptionFormat);
}

View file

@ -1,72 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs;
import java.util.LinkedList;
import java.util.List;
public class WcsServiceInfo {
protected String onlineResource;
protected List<WcsOperationInfo> operations = new LinkedList<WcsOperationInfo>();
/**
*
*/
public WcsServiceInfo(String onlineResouce) {
this.onlineResource = onlineResouce;
}
public void addOperationInfo(WcsOperationInfo info) {
operations.add(info);
}
/**
* @return the onlineResource
*/
public String getOnlineResource() {
return onlineResource;
}
/**
* @param onlineResource
* the onlineResource to set
*/
public void setOnlineResource(String onlineResource) {
this.onlineResource = onlineResource;
}
/**
* @return the operations
*/
public List<WcsOperationInfo> getOperations() {
return operations;
}
/**
* @param operations
* the operations to set
*/
public void setOperations(List<WcsOperationInfo> operations) {
this.operations = operations;
}
}

View file

@ -1,63 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.format;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.nc4.NcVariable;
import com.raytheon.uf.common.nc4.NcVariable.ByteVariable;
import com.raytheon.uf.common.nc4.NetcdfException;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class ByteNcWriter extends NcWriter<ByteVariable> {
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.format.NcWriter#getVarClass()
*/
@Override
public Class<ByteVariable> getVarClass() {
return ByteVariable.class;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.NcWriter#write(com.raytheon.uf.common
* .nc4.NcVariable, com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
public void write(NcVariable var, int[] start, IDataRecord irecord)
throws NetcdfException {
ByteDataRecord record = (ByteDataRecord) irecord;
ByteVariable variable = (ByteVariable) var;
int[] shape = getShape(record);
variable.putVar(start, shape, record.getByteData());
}
}

View file

@ -1,231 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.format;
import java.io.IOException;
import java.nio.channels.WritableByteChannel;
import ucar.ma2.Array;
import ucar.ma2.InvalidRangeException;
import ucar.ma2.Section;
import ucar.ma2.StructureDataIterator;
import ucar.nc2.NetcdfFile;
import ucar.nc2.ParsedSectionSpec;
import ucar.nc2.Structure;
import ucar.nc2.Variable;
import ucar.nc2.iosp.IOServiceProvider;
import ucar.nc2.util.CancelTask;
import ucar.unidata.io.RandomAccessFile;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
/**
*
* @author bclement
* @version 1.0
*/
public class DataRecordIOSP implements IOServiceProvider {
protected IDataRecord dataRecord;
public DataRecordIOSP(IDataRecord dataRecord) {
this.dataRecord = dataRecord;
}
/*
* (non-Javadoc)
*
* @see
* ucar.nc2.iosp.IOServiceProvider#isValidFile(ucar.unidata.io.RandomAccessFile
* )
*/
@Override
public boolean isValidFile(RandomAccessFile arg0) throws IOException {
System.out.println();
return false;
}
/*
* (non-Javadoc)
*
* @see
* ucar.nc2.iosp.IOServiceProvider#open(ucar.unidata.io.RandomAccessFile,
* ucar.nc2.NetcdfFile, ucar.nc2.util.CancelTask)
*/
@Override
public void open(RandomAccessFile arg0, NetcdfFile arg1, CancelTask arg2)
throws IOException {
System.out.println();
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#readData(ucar.nc2.Variable,
* ucar.ma2.Section)
*/
@Override
public Array readData(Variable arg0, Section arg1) throws IOException,
InvalidRangeException {
System.out.println();
return null;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#close()
*/
@Override
public void close() throws IOException {
System.out.println();
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#getDetailInfo()
*/
@Override
public String getDetailInfo() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#getFileTypeDescription()
*/
@Override
public String getFileTypeDescription() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#getFileTypeId()
*/
@Override
public String getFileTypeId() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#getFileTypeVersion()
*/
@Override
public String getFileTypeVersion() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see
* ucar.nc2.iosp.IOServiceProvider#getStructureIterator(ucar.nc2.Structure,
* int)
*/
@Override
public StructureDataIterator getStructureIterator(Structure arg0, int arg1)
throws IOException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see
* ucar.nc2.iosp.IOServiceProvider#readSection(ucar.nc2.ParsedSectionSpec)
*/
@Override
public Array readSection(ParsedSectionSpec arg0) throws IOException,
InvalidRangeException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#readToByteChannel(ucar.nc2.Variable,
* ucar.ma2.Section, java.nio.channels.WritableByteChannel)
*/
@Override
public long readToByteChannel(Variable arg0, Section arg1,
WritableByteChannel arg2) throws IOException, InvalidRangeException {
// TODO Auto-generated method stub
return 0;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#sendIospMessage(java.lang.Object)
*/
@Override
public Object sendIospMessage(Object arg0) {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#sync()
*/
@Override
public boolean sync() throws IOException {
// TODO Auto-generated method stub
return false;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#syncExtend()
*/
@Override
public boolean syncExtend() throws IOException {
// TODO Auto-generated method stub
return false;
}
/*
* (non-Javadoc)
*
* @see ucar.nc2.iosp.IOServiceProvider#toStringDebug(java.lang.Object)
*/
@Override
public String toStringDebug(Object arg0) {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -1,62 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.format;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.nc4.NcVariable;
import com.raytheon.uf.common.nc4.NcVariable.FloatVariable;
import com.raytheon.uf.common.nc4.NetcdfException;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class FloatNcWriter extends NcWriter<FloatVariable> {
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.format.NcWriter#getVarClass()
*/
@Override
public Class<FloatVariable> getVarClass() {
return FloatVariable.class;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.NcWriter#write(com.raytheon.uf.common
* .nc4.NcVariable, com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
public void write(NcVariable var, int[] start, IDataRecord irecord)
throws NetcdfException {
FloatDataRecord record = (FloatDataRecord) irecord;
FloatVariable variable = (FloatVariable) var;
int[] shape = getShape(record);
variable.putVar(start, shape, record.getFloatData());
}
}

View file

@ -1,63 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.format;
import java.io.File;
import java.io.InputStream;
import com.raytheon.uf.edex.wcs.reg.Coverage;
/**
*
* @author bclement
* @version 1.0
*/
public interface IWcsDataFormatter {
/**
*
* @return
*/
public String getIdentifier();
/**
* get coverage identifier
* @param format
* @return
*/
public boolean matchesFormat(String format);
/**
* Format coverage
* @param coverage
* @return
* @throws Exception
*/
public InputStream format(Coverage coverage) throws Exception;
/**
* Store coverage
* @param coverage
* @return
* @throws Exception
*/
public File store(Coverage coverage) throws Exception;
}

View file

@ -1,62 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.format;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.nc4.NcVariable;
import com.raytheon.uf.common.nc4.NcVariable.IntVariable;
import com.raytheon.uf.common.nc4.NetcdfException;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class IntNcWriter extends NcWriter<IntVariable> {
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.format.NcWriter#getVarClass()
*/
@Override
public Class<IntVariable> getVarClass() {
return IntVariable.class;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.NcWriter#write(com.raytheon.uf.common
* .nc4.NcVariable, com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
public void write(NcVariable var, int[] start, IDataRecord irecord)
throws NetcdfException {
IntegerDataRecord record = (IntegerDataRecord) irecord;
IntVariable variable = (IntVariable) var;
int[] shape = getShape(record);
variable.putVar(start, shape, record.getIntData());
}
}

View file

@ -1,86 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.format;
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
import com.raytheon.uf.common.nc4.NcVariable;
import com.raytheon.uf.common.nc4.NetcdfException;
/**
* Abstraction for data type specific writing from data record to netcdf file
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public abstract class NcWriter<T extends NcVariable> {
public abstract Class<T> getVarClass();
/**
* Write data record to variable
*
* @param var
* @param irecord
* @throws NetcdfException
*/
public abstract void write(NcVariable var, int[] start, IDataRecord irecord)
throws NetcdfException;
/**
* Converts the dimensions of the record to netcdf shape. This will be
* reverse from the data record sizes;
*
* @param record
* @return
*/
protected int[] getShape(IDataRecord record) {
long[] sizes = record.getSizes();
return new int[] { 1, 1, (int) sizes[1], (int) sizes[0] };
}
/**
* Factory method for ncwriters
*
* @param record
* @return
* @throws Exception
* if the data record's data type is not supported by the netcdf
* library
*/
public static NcWriter<? extends NcVariable> create(IDataRecord record)
throws Exception {
if (record instanceof ByteDataRecord) {
return new ByteNcWriter();
} else if (record instanceof ShortDataRecord) {
return new ShortNcWriter();
} else if (record instanceof IntegerDataRecord) {
return new IntNcWriter();
} else if (record instanceof FloatDataRecord) {
return new FloatNcWriter();
} else {
throw new Exception("Unsupported data record type: "
+ record.getClass());
}
}
}

View file

@ -1,652 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.format;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.geotools.coverage.grid.GridEnvelope2D;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.coverage.grid.InvalidGridGeometryException;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.parameter.Parameter;
import org.geotools.referencing.CRS;
import org.geotools.referencing.operation.transform.ConcatenatedTransform;
import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.metadata.spatial.PixelOrientation;
import org.opengis.parameter.GeneralParameterValue;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.GeographicCRS;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.cs.CartesianCS;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.Projection;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.nc4.NcDimension;
import com.raytheon.uf.common.nc4.NcDimension.DoubleDimension;
import com.raytheon.uf.common.nc4.NcVariable;
import com.raytheon.uf.common.nc4.NcVariable.ByteVariable;
import com.raytheon.uf.common.nc4.Netcdf;
import com.raytheon.uf.common.nc4.NetcdfException;
import com.raytheon.uf.common.nc4.cf.CfConstants;
import com.raytheon.uf.common.nc4.cf.CfDimensions;
import com.raytheon.uf.common.nc4.cf.CfGridMapper;
import com.raytheon.uf.common.nc4.cf.CfHorizontalDims;
import com.raytheon.uf.common.nc4.cf.CfNetcdf;
import com.raytheon.uf.common.spatial.reprojection.ReferencedDataRecord;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.ogc.common.BasicFileStore;
import com.raytheon.uf.edex.wcs.WcsException;
import com.raytheon.uf.edex.wcs.WcsException.Code;
import com.raytheon.uf.edex.wcs.reg.Coverage;
import com.raytheon.uf.edex.wcs.reg.CoverageDimensions;
import com.raytheon.uf.edex.wcs.reg.CoverageField;
import com.raytheon.uf.edex.wcs.reg.CoverageTAxis;
import com.raytheon.uf.edex.wcs.reg.CoverageXYAxis;
import com.raytheon.uf.edex.wcs.reg.CoverageZAxis;
import com.raytheon.uf.edex.wcs.reg.TemporalCube;
import com.raytheon.uf.edex.wcs.reg.VerticalSlice;
/**
*
* @author bclement
* @version 1.0
*/
public class NetCdfFormatter implements IWcsDataFormatter {
public static final String CONTENT_TYPE = "application/netcdf4";
private final IUFStatusHandler log = UFStatus.getHandler(this.getClass());
private final BasicFileStore store;
private static final AtomicLong STORAGE_ID = new AtomicLong();
public NetCdfFormatter(BasicFileStore store) {
this.store = store;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.format.WcsDataFormatter#getIdentifier()
*/
@Override
public String getIdentifier() {
return CONTENT_TYPE;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.WcsDataFormatter#format(com.raytheon.
* uf.common.datastorage.records.IDataRecord, java.io.OutputStream, boolean)
*/
@Override
public InputStream format(Coverage coverage) throws Exception {
final File file = store(coverage);
// if the constructor throws, the file will be leaked
return new FileInputStream(file) {
@Override
public void close() throws IOException {
try {
super.close();
} finally {
if (file != null) {
file.delete();
}
}
}
};
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.WcsDataFormatter#store(com.raytheon.uf
* .edex.wcs.reg.Coverage)
*/
@Override
public File store(Coverage coverage) throws Exception {
String id = createStoreId(coverage);
File file = store.reserveFile(id);
CfNetcdf ncfile = new CfNetcdf(file.getAbsolutePath(),
Netcdf.NETCDF4_CLASSIC_MODE);
try {
ncfile.putStringAttribute(CfConstants.COVERAGE_ID_ATTR,
coverage.getName());
List<CoverageField> fields = coverage.getFields();
DimMapping dmap = defineDims(ncfile, fields);
List<NcVariable> vars = new ArrayList<NcVariable>(fields.size());
for (CoverageField field : fields) {
vars.add(define(ncfile, dmap.fieldMap.get(field.getName()),
field));
}
ncfile.endFileDefinition();
for (DimWriter w : dmap.writers) {
w.write();
}
Iterator<NcVariable> iter = vars.iterator();
for (CoverageField field : fields) {
NcVariable var = iter.next();
write(field, var);
}
} finally {
ncfile.close();
}
return file;
}
/**
* Write 4D cube in field to variable
*
* @param field
* @param var
* @throws Exception
*/
private void write(CoverageField field, NcVariable var) throws Exception {
List<TemporalCube> timeCube = field.getTimeCube();
TemporalCube firstCube = timeCube.get(0);
VerticalSlice firstSlice = firstCube.getSlices().get(0);
ReferencedDataRecord firstRecord = firstSlice.getRecord().get(true);
NcWriter<? extends NcVariable> writer = NcWriter.create(firstRecord
.getRecord());
Iterator<TemporalCube> cubeIter = timeCube.iterator();
for (int i = 0; cubeIter.hasNext(); ++i) {
TemporalCube cube = cubeIter.next();
Iterator<VerticalSlice> sliceIter = cube.getSlices().iterator();
for (int j = 0; sliceIter.hasNext(); ++j) {
VerticalSlice slice = sliceIter.next();
writer.write(var, new int[] { i, j, 0, 0 }, slice.getRecord()
.get(false).getRecord());
}
}
}
/**
* Define variable for field
*
* @param ncfile
* @param dims
* @param field
* @return
* @throws Exception
*/
private NcVariable define(CfNetcdf ncfile,
CfDimensions<DoubleDimension> dims, CoverageField field)
throws Exception {
List<TemporalCube> timeCube = field.getTimeCube();
TemporalCube firstCube = timeCube.get(0);
VerticalSlice firstSlice = firstCube.getSlices().get(0);
ReferencedDataRecord firstRecord = firstSlice.getRecord().get(true);
NcWriter<? extends NcVariable> writer = NcWriter.create(firstRecord
.getRecord());
NcVariable variable = ncfile.defineVar(field.getName(), dims.toArray(),
writer.getVarClass());
variable.putStringAttribute(CfConstants.STANDARD_NAME_ATTR,
field.getStandardName());
variable.putStringAttribute(CfConstants.LONG_NAME_ATTR,
field.getStandardName());
variable.putStringAttribute(CfConstants.UNITS_ATTR, field.getUnits());
variable.putNumberAttribute(CfConstants.MISSING_VAL_ATTR,
new Number[] { field.getPaddingValue() });
CfHorizontalDims<DoubleDimension> xyDims = dims.getXyDims();
if (xyDims.isMapped()) {
variable.putStringAttribute(CfConstants.GRID_MAP_NAME_ATTR,
xyDims.getGridMapping());
variable.putStringAttribute(CfConstants.COORDS_ATTR,
xyDims.getCoords());
}
return variable;
}
/**
* Interface to postpone writing to dimensions until after definition phase
*/
private static interface DimWriter {
public void write() throws NetcdfException;
}
/**
* Wrapper for multi-part return
*/
private static class DimMapping {
public final Map<String, CfDimensions<DoubleDimension>> fieldMap;
public final List<DimWriter> writers;
public DimMapping(Map<String, CfDimensions<DoubleDimension>> fieldMap,
List<DimWriter> writers) {
this.fieldMap = fieldMap;
this.writers = writers;
}
}
/**
* Define dimensions for fields.
*
* @param ncfile
* @param fields
* @return
* @throws Exception
*/
private DimMapping defineDims(CfNetcdf ncfile, List<CoverageField> fields)
throws Exception {
Map<CoverageXYAxis, CfHorizontalDims<DoubleDimension>> horizMap = new HashMap<CoverageXYAxis, CfHorizontalDims<DoubleDimension>>();
Map<CoverageZAxis, DoubleDimension> vertMap = new HashMap<CoverageZAxis, DoubleDimension>();
Map<CoverageTAxis, DoubleDimension> timeMap = new HashMap<CoverageTAxis, DoubleDimension>();
Map<String, CfDimensions<DoubleDimension>> fieldMap = new HashMap<String, CfDimensions<DoubleDimension>>();
List<DimWriter> writers = new ArrayList<NetCdfFormatter.DimWriter>();
for (CoverageField field : fields) {
CoverageDimensions dims = field.getDimensions();
CoverageXYAxis xyAxis = dims.getXyAxis();
CfHorizontalDims<DoubleDimension> horiz = horizMap.get(xyAxis);
if (horiz == null) {
horiz = defineXY(ncfile, xyAxis, writers, horizMap.size());
horizMap.put(xyAxis, horiz);
}
CoverageZAxis zAxis = dims.getZAxis();
DoubleDimension vert = vertMap.get(zAxis);
if (vert == null) {
vert = defineZ(ncfile, zAxis, writers, vertMap.size());
vertMap.put(zAxis, vert);
}
CoverageTAxis tAxis = dims.getTAxis();
DoubleDimension time = timeMap.get(tAxis);
if (time == null) {
time = defineT(ncfile, tAxis, writers, timeMap.size());
timeMap.put(tAxis, time);
}
fieldMap.put(field.getName(),
new CfDimensions<NcDimension.DoubleDimension>(horiz, vert,
time));
}
return new DimMapping(fieldMap, writers);
}
/**
* Define horizontal dimensions
*
* @param ncfile
* @param xyAxis
* @param writers
* @param count
* @return
* @throws Exception
*/
private CfHorizontalDims<DoubleDimension> defineXY(CfNetcdf ncfile,
CoverageXYAxis xyAxis, List<DimWriter> writers, int count)
throws Exception {
double[][] lonLatAxis = getLonLatAxis(xyAxis.getGridGeometry());
final double[] lonValue = lonLatAxis[0];
final double[] latValue = lonLatAxis[1];
final DoubleDimension lon = ncfile.defineXDim("lon" + count,
"longitude", lonValue.length, CfConstants.LON_UNITS,
DoubleDimension.class);
final DoubleDimension lat = ncfile.defineYDim("lat" + count,
"latitude", latValue.length, CfConstants.LAT_UNITS,
DoubleDimension.class);
writers.add(new DimWriter() {
@Override
public void write() throws NetcdfException {
lon.putDim(lonValue);
lat.putDim(latValue);
}
});
ReferencedEnvelope env = xyAxis.getEnvelope();
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
if (crs instanceof GeographicCRS) {
return new CfHorizontalDims<NcDimension.DoubleDimension>(lon, lat);
} else if (crs instanceof ProjectedCRS) {
return defineMappedXY(ncfile, xyAxis, writers, count, lon, lat);
} else {
log.error("Unsupport CRS object type: " + crs.getClass(),
new Exception());
throw new WcsException(Code.InternalServerError);
}
}
/**
* Define non geographic horizontal dimensions
*
* @param ncfile
* @param xyAxis
* @param writers
* @param count
* @param lon
* @param lat
* @return
* @throws NetcdfException
* @throws TransformException
* @throws FactoryException
* @throws MismatchedDimensionException
* @throws InvalidGridGeometryException
*/
private CfHorizontalDims<NcDimension.DoubleDimension> defineMappedXY(
CfNetcdf ncfile, CoverageXYAxis xyAxis, List<DimWriter> writers,
int count, DoubleDimension lon, DoubleDimension lat)
throws Exception {
ReferencedEnvelope env = xyAxis.getEnvelope();
ProjectedCRS crs = (ProjectedCRS) env.getCoordinateReferenceSystem();
CartesianCS cs = crs.getCoordinateSystem();
CoordinateSystemAxis xAxis = cs.getAxis(0);
CoordinateSystemAxis yAxis = cs.getAxis(1);
GridGeometry2D geom = xyAxis.getGridGeometry();
GridEnvelope2D gridEnv = geom.getGridRange2D();
final DoubleDimension x = ncfile.defineXDim("x" + count,
CfConstants.X_STD_NAME, gridEnv.width, xAxis.getUnit()
.toString(), DoubleDimension.class);
final DoubleDimension y = ncfile.defineYDim("y" + count,
CfConstants.Y_STD_NAME, gridEnv.height, yAxis.getUnit()
.toString(), DoubleDimension.class);
double[][] xyVals = getXYAxis(geom, crs);
final double[] xVals = xyVals[0];
final double[] yVals = xyVals[1];
writers.add(new DimWriter() {
@Override
public void write() throws NetcdfException {
x.putDim(xVals);
y.putDim(yVals);
}
});
Projection conv = crs.getConversionFromBase();
ParameterValueGroup params = conv.getParameterValues();
String projName = params.getDescriptor().getName().getCode();
Map<String, List<NumberedValue>> paramMap = getParamMap(params);
NcVariable projVar = defineProjVar(ncfile, projName, paramMap, count);
String coords = StringUtils.join(
new String[] { lat.getName(), lon.getName() }, " ");
return new CfHorizontalDims<NcDimension.DoubleDimension>(x, y, coords,
projVar.getName());
}
protected static class NumberedValue implements Comparable<NumberedValue> {
public int number;
public Object value;
public NumberedValue(int number, Object value) {
this.number = number;
this.value = value;
}
@Override
public int compareTo(NumberedValue o) {
return number - o.number;
}
}
/**
* Map parameter base names to values
*
* @param params
* @return
*/
protected Map<String, List<NumberedValue>> getParamMap(
ParameterValueGroup params) {
final Pattern PARAM_PATTERN = Pattern.compile("^(.*)(_([0-9]+))$");
Map<String, List<NumberedValue>> paramMap = new HashMap<String, List<NumberedValue>>();
for (GeneralParameterValue v : params.values()) {
Parameter<?> p = (Parameter<?>) v;
String paramName = p.getDescriptor().getName().getCode().trim();
Matcher m = PARAM_PATTERN.matcher(paramName);
int number = 0;
if (m.matches()) {
paramName = m.group(1);
number = Integer.parseInt(m.group(3));
}
paramName = CfGridMapper.getMappingAttributeName(paramName);
List<NumberedValue> values = paramMap.get(paramName);
if (values == null) {
values = new ArrayList<NumberedValue>(2);
paramMap.put(paramName, values);
}
values.add(new NumberedValue(number, p.getValue()));
}
return paramMap;
}
/**
* Define grid projection mapping variable
*
* @param ncfile
* @param projName
* @param paramMap
* @param count
* @return
* @throws NetcdfException
*/
private NcVariable defineProjVar(CfNetcdf ncfile, String projName,
Map<String, List<NumberedValue>> paramMap, int count)
throws NetcdfException {
ByteVariable projVar = ncfile.defineVar(projName + count,
new NcDimension[0], ByteVariable.class);
projVar.putStringAttribute(CfConstants.GRID_MAP_NAME_ATTR, projName);
for (Entry<String, List<NumberedValue>> e : paramMap.entrySet()) {
List<NumberedValue> list = e.getValue();
Collections.sort(list);
if (list.get(0).value instanceof Number) {
Number[] vals = new Number[list.size()];
Iterator<NumberedValue> iter = list.iterator();
for (int i = 0; iter.hasNext(); ++i) {
vals[i] = (Number) iter.next().value;
}
projVar.putNumberAttribute(e.getKey(), vals);
} else {
String[] vals = new String[list.size()];
Iterator<NumberedValue> iter = list.iterator();
for (int i = 0; iter.hasNext(); ++i) {
vals[i] = iter.next().value.toString();
}
projVar.putStringsAttribute(e.getKey(), vals);
}
}
return projVar;
}
/**
* Define vertical dimension
*
* @param ncfile
* @param zAxis
* @param writers
* @param count
* @return
* @throws NetcdfException
*/
private DoubleDimension defineZ(CfNetcdf ncfile, final CoverageZAxis zAxis,
List<DimWriter> writers, int count) throws NetcdfException {
final DoubleDimension z = ncfile.defineZDim("level" + count,
"height level", zAxis.getValue().length, zAxis.getUnits(),
zAxis.isUpIsPositive(), DoubleDimension.class);
writers.add(new DimWriter() {
@Override
public void write() throws NetcdfException {
z.putDim(zAxis.getValue());
}
});
return z;
}
/**
* Define temporal dimension
*
* @param ncfile
* @param tAxis
* @param writers
* @param count
* @return
* @throws NetcdfException
*/
private DoubleDimension defineT(CfNetcdf ncfile, CoverageTAxis tAxis,
List<DimWriter> writers, int count) throws NetcdfException {
final DoubleDimension t = ncfile.defineTimeDim("time" + count, "time",
tAxis.getTimes().length, CfConstants.UNIX_TIME_UNITS,
DoubleDimension.class);
final double[] values = getTimes(tAxis.getTimes());
writers.add(new DimWriter() {
@Override
public void write() throws NetcdfException {
t.putDim(values);
}
});
return t;
}
/**
* Convert times to UNIX timestamps with milliseconds as decimal
*
* @param times
* @return
*/
private double[] getTimes(Date[] times) {
double[] rval = new double[times.length];
for (int i = 0; i < rval.length; ++i) {
rval[i] = times[i].getTime() / 1000;
}
return rval;
}
/**
* Convert geometry to CRS84.
*
* @param geom
* @return array of size 2. Index 0 contains longitude, index 1 contains
* latitude. Not guaranteed to be the same length.
* @throws InvalidGridGeometryException
* @throws FactoryException
* @throws MismatchedDimensionException
* @throws TransformException
*/
private double[][] getLonLatAxis(GridGeometry2D geom)
throws InvalidGridGeometryException, FactoryException,
MismatchedDimensionException, TransformException {
return getXYAxis(geom, MapUtil.LATLON_PROJECTION);
}
/**
* Convert geometry to Target CRS.
*
* @param geom
* @param targetCRS
* @return
* @throws InvalidGridGeometryException
* @throws FactoryException
* @throws MismatchedDimensionException
* @throws TransformException
*/
private double[][] getXYAxis(GridGeometry2D geom,
CoordinateReferenceSystem targetCRS)
throws InvalidGridGeometryException, FactoryException,
MismatchedDimensionException, TransformException {
double[][] rval = new double[2][];
GridEnvelope2D gridEnv = geom.getGridRange2D();
MathTransform gridToCRS = geom
.getGridToCRS(PixelOrientation.UPPER_LEFT);
CoordinateReferenceSystem origCrs = geom.getCoordinateReferenceSystem();
MathTransform toTarget = CRS
.findMathTransform(origCrs, targetCRS, true);
MathTransform transform = ConcatenatedTransform.create(gridToCRS,
toTarget);
rval[0] = new double[gridEnv.width];
rval[1] = new double[gridEnv.height];
int maxLen = Math.max(gridEnv.width, gridEnv.height);
int xIndex = 0;
int yIndex = 0;
for (int i = 0; i < maxLen; ++i) {
DirectPosition2D point = new DirectPosition2D(xIndex, yIndex);
DirectPosition2D target = new DirectPosition2D();
transform.transform(point, target);
rval[0][xIndex] = target.getX();
rval[1][yIndex] = target.getY();
xIndex = Math.min(++xIndex, gridEnv.width - 1);
yIndex = Math.min(++yIndex, gridEnv.height - 1);
}
return rval;
}
/**
* Create unique id for file store
*
* @param coverage
* @return
*/
private String createStoreId(Coverage coverage) {
String name = coverage.getName();
String rval;
do {
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(name).append(System.currentTimeMillis());
builder.append(STORAGE_ID.incrementAndGet());
String hash = Integer.toHexString(builder.toHashCode());
rval = name + hash + ".nc";
} while (store.getFile(rval) != null);
return rval;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.WcsDataFormatter#matchesFormat(java.lang
* .String)
*/
@Override
public boolean matchesFormat(String format) {
return format.toLowerCase().contains("netcdf");
}
}

View file

@ -1,62 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.format;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
import com.raytheon.uf.common.nc4.NcVariable;
import com.raytheon.uf.common.nc4.NcVariable.ShortVariable;
import com.raytheon.uf.common.nc4.NetcdfException;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class ShortNcWriter extends NcWriter<ShortVariable> {
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.edex.wcs.format.NcWriter#getVarClass()
*/
@Override
public Class<ShortVariable> getVarClass() {
return ShortVariable.class;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.wcs.format.NcWriter#write(com.raytheon.uf.common
* .nc4.NcVariable, com.raytheon.uf.common.datastorage.records.IDataRecord)
*/
@Override
public void write(NcVariable var, int[] start, IDataRecord irecord)
throws NetcdfException {
ShortDataRecord record = (ShortDataRecord) irecord;
ShortVariable variable = (ShortVariable) var;
int[] shape = getShape(record);
variable.putVar(start, shape, record.getShortData());
}
}

View file

@ -1,272 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.provider;
import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getAsLangString;
import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getKeywords;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.JAXBElement;
import net.opengis.ows.v_1_1_0.AddressType;
import net.opengis.ows.v_1_1_0.CodeType;
import net.opengis.ows.v_1_1_0.ContactType;
import net.opengis.ows.v_1_1_0.KeywordsType;
import net.opengis.ows.v_1_1_0.LanguageStringType;
import net.opengis.ows.v_1_1_0.OnlineResourceType;
import net.opengis.ows.v_1_1_0.ResponsiblePartySubsetType;
import net.opengis.ows.v_1_1_0.ServiceIdentification;
import net.opengis.ows.v_1_1_0.ServiceProvider;
import net.opengis.ows.v_1_1_0.WGS84BoundingBoxType;
import net.opengis.wcs.v_1_1_2.Capabilities;
import net.opengis.wcs.v_1_1_2.Contents;
import net.opengis.wcs.v_1_1_2.CoverageSummaryType;
import net.opengis.wcs.v_1_1_2.ObjectFactory;
import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox;
import com.raytheon.uf.edex.ogc.common.OgcNamespace;
import com.raytheon.uf.edex.ogc.common.OgcServiceInfo;
import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType;
import com.raytheon.uf.edex.wcs.reg.CoverageDescription;
/**
*
* @author bclement
* @version 1.0
*/
public class CapabilitiesBuilder {
protected String version = "1.1.2";
protected String OWS_NS = OgcNamespace.OWS110;
protected String WCS_NS = OgcNamespace.WCS112;
protected String updateSequence = "1";
protected String SERV_TYPE = "WCS";
protected static final String wcsName = "WCS";
protected String SERV_TITLE = "EDEX WCS";
protected static final String svcTitle = "EDEX Coverage Server";
protected OperationsDescriber opDesc = new OperationsDescriber();
protected ObjectFactory wcsFactory = new ObjectFactory();
protected List<String> formats;
protected net.opengis.ows.v_1_1_0.ObjectFactory owsFactory = new net.opengis.ows.v_1_1_0.ObjectFactory();
public CapabilitiesBuilder(List<String> formats) {
this.formats = formats;
}
public Capabilities getCapabilities(OgcServiceInfo<WcsOpType> serviceinfo,
List<CoverageDescription> coverages) {
Capabilities capabilities = new Capabilities();
capabilities.setVersion(version);
// capabilities.setUpdateSequence(updateSequence);
// capabilities
// .setServiceIdentification(getServiceIdentification(serviceinfo));
// capabilities.setServiceProvider(getServiceProvider(serviceinfo));
capabilities.setOperationsMetadata(opDesc.getOpData(serviceinfo));
capabilities.setContents(getContents(coverages));
return capabilities;
}
protected Contents getContents(List<CoverageDescription> coverages) {
Contents rval = new Contents();
List<CoverageSummaryType> cstList = new ArrayList<CoverageSummaryType>();
for (CoverageDescription coverage : coverages) {
cstList.add(getCoverageSummaryType(coverage));
}
rval.setSupportedFormat(formats);
rval.setCoverageSummary(cstList);
return rval;
}
protected List<JAXBElement<WGS84BoundingBoxType>> getBboxes(
OgcGeoBoundingBox bbox) {
if (bbox == null) {
return new ArrayList<JAXBElement<WGS84BoundingBoxType>>(0);
}
List<JAXBElement<WGS84BoundingBoxType>> rval = new ArrayList<JAXBElement<WGS84BoundingBoxType>>(
1);
WGS84BoundingBoxType to = owsFactory.createWGS84BoundingBoxType();
to.setLowerCorner(Arrays.asList(bbox.getMinx(), bbox.getMiny()));
to.setUpperCorner(Arrays.asList(bbox.getMaxx(), bbox.getMaxy()));
to.setDimensions(BigInteger.valueOf(2));
to.setCrs("urn:ogc:def:crs:OGC:2:84");
rval.add(owsFactory.createWGS84BoundingBox(to));
return rval;
}
protected CoverageSummaryType getCoverageSummaryType(CoverageDescription cov) {
CoverageSummaryType cst = new CoverageSummaryType();
cst.setTitle(getAsLangString(cov.getTitle()));
cst.setAbstract(getAsLangString(cov.getAbstractStr()));
if (cov.getKeywords() != null) {
cst.setKeywords(getKeywords(cov.getKeywords()));
}
List<JAXBElement<?>> jaxbList = new ArrayList<JAXBElement<?>>();
jaxbList.addAll(getBboxes(cov.getCrs84Bbox()));
if (cov.getCrs() != null && cov.getCrs().size() > 0) {
for (String crs : cov.getCrs()) {
jaxbList.add(wcsFactory.createCoverageSummaryTypeSupportedCRS(crs));
}
}
if (cov.getIdentifier() != null) {
jaxbList.add(wcsFactory.createIdentifier(cov.getIdentifier()));
}
cst.setContent(jaxbList);
return cst;
}
// the following methods are for optional metadata that aren't currently
// used
protected ResponsiblePartySubsetType getResponsibleParty() {
ResponsiblePartySubsetType rval = new ResponsiblePartySubsetType();
rval.setIndividualName("Individual Name");
rval.setPositionName("TBD");
CodeType ct = new CodeType();
ct.setCodeSpace("role");
ct.setValue("TBD");
rval.setRole(ct);
// Contact Information
ContactType contact = new ContactType();
AddressType address = new AddressType();
address.setAdministrativeArea("TBD");
List<String> addressPointList = new ArrayList<String>();
addressPointList.add("TBD");
address.setDeliveryPoint(addressPointList);
address.setCity("TBD");
address.setCountry("TBD");
List<String> emailList = new ArrayList<String>();
emailList.add("TBD");
address.setElectronicMailAddress(emailList);
address.setPostalCode("TBD");
contact.setAddress(address);
contact.setContactInstructions("TBD");
rval.setContactInfo(contact);
return rval;
}
protected OnlineResourceType getOLR(OgcServiceInfo<WcsOpType> serviceinfo) {
OnlineResourceType rval = new OnlineResourceType();
if (serviceinfo != null && serviceinfo.getOnlineResource() != null) {
rval.setHref(serviceinfo.getOnlineResource());
}
rval.setActuate("TBD");
rval.setArcrole("TBD");
rval.setRole("TBD");
rval.setShow("TBD");
rval.setTitle("TBD");
rval.setType("TBD");
return rval;
}
protected ServiceIdentification getServiceIdentification(
OgcServiceInfo<WcsOpType> serviceinfo) {
ServiceIdentification rval = new ServiceIdentification();
// Abstract
List<LanguageStringType> lstList = new ArrayList<LanguageStringType>();
LanguageStringType lst = new LanguageStringType();
lst.setLang(WcsJaxbUtils.DEFAULT_LANGUAGE);
lst.setValue("TBD");
rval.setAbstract(lstList);
// Constraints
List<String> constraints = new ArrayList<String>();
constraints.add("NONE");
rval.setAccessConstraints(constraints);
// Fees
rval.setFees("fees");
// Key Words
List<KeywordsType> keyWordTypeList = new ArrayList<KeywordsType>();
KeywordsType kt = new KeywordsType();
lstList = new ArrayList<LanguageStringType>();
lst = new LanguageStringType();
lst.setLang(WcsJaxbUtils.DEFAULT_LANGUAGE);
lst.setValue("keyword");
lstList.add(lst);
kt.setKeyword(lstList);
keyWordTypeList.add(kt);
rval.setKeywords(keyWordTypeList);
// Profile
List<String> profileList = new ArrayList<String>();
profileList.add("TBD");
profileList.add("TBD");
rval.setProfile(profileList);
// Service Type
CodeType codeType = new CodeType();
codeType.setCodeSpace("codetype");
rval.setServiceType(codeType);
// Service Type Version
List<String> serviceTypeVersion = new ArrayList<String>();
serviceTypeVersion.add("servicetypeversion");
rval.setServiceTypeVersion(serviceTypeVersion);
// Title
lstList = new ArrayList<LanguageStringType>();
lst = new LanguageStringType();
lst.setLang(WcsJaxbUtils.DEFAULT_LANGUAGE);
lst.setValue(SERV_TITLE);
lstList.add(lst);
rval.setTitle(lstList);
return rval;
}
protected ServiceProvider getServiceProvider(
OgcServiceInfo<WcsOpType> serviceInfo) {
ServiceProvider rval = new ServiceProvider();
rval.setProviderName(wcsName);
rval.setServiceContact(getResponsibleParty());
rval.setProviderSite(getOLR(serviceInfo));
return rval;
}
}

View file

@ -1,148 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.provider;
import java.io.File;
import java.io.FileInputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Mapping of custom identifiers to internally generated URNs
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 31, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CustomIdMap {
private static final Map<String, String> externalToInternal;
private static final Map<String, String> internalToExternal;
private static final IUFStatusHandler log = UFStatus
.getHandler(CustomIdMap.class);
static {
LocalizationFile idMapFile = findConfigFile();
Map<String, String> map;
if (idMapFile == null) {
log.warn("Unable to find custom id mapping properties");
map = new HashMap<String, String>(0);
} else {
map = loadConfig(idMapFile);
}
externalToInternal = Collections.unmodifiableMap(map);
internalToExternal = Collections.unmodifiableMap(reverseMap(map));
}
/**
* Find configuration file in localization
*
* @return null if not found
*/
private static LocalizationFile findConfigFile() {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext[] searchHierarchy = pm
.getLocalSearchHierarchy(LocalizationType.EDEX_STATIC);
for (LocalizationContext ctx : searchHierarchy) {
LocalizationFile localizationFile = pm.getLocalizationFile(ctx,
"wcs" + IPathManager.SEPARATOR
+ "wcsIdentifier.properties");
if (localizationFile.exists()) {
return localizationFile;
}
}
return null;
}
/**
* Load map from config
*
* @param idMapFile
* @return
*/
private static Map<String, String> loadConfig(LocalizationFile idMapFile) {
Properties props = new Properties();
File file = idMapFile.getFile();
try {
props.load(new FileInputStream(file));
} catch (Exception e) {
log.error("Unable to load WCS id map: " + file, e);
return new HashMap<String, String>(0);
}
// TODO validate entries
Map<String, String> rval = new HashMap<String, String>(props.size());
for (Entry<Object, Object> e : props.entrySet()) {
rval.put(e.getKey().toString(), e.getValue().toString());
}
return rval;
}
/**
* Return a map of values to keys.
*
* @param map
* @return
*/
private static Map<String, String> reverseMap(Map<String, String> map) {
Map<String, String> rval = new HashMap<String, String>(map.size());
for (Entry<String, String> e : map.entrySet()) {
rval.put(e.getValue(), e.getKey());
}
return rval;
}
/**
* @param id
* @return id if no mapping exists
*/
public static String internalToExternal(String id) {
String rval = internalToExternal.get(id);
if (rval == null) {
return id;
}
return rval;
}
/**
* @param id
* @return id if no mapping exists
*/
public static String externalToInternal(String id) {
String rval = externalToInternal.get(id);
if (rval == null) {
return id;
}
return rval;
}
}

View file

@ -1,408 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.provider;
import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getAsLangString;
import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getKeywords;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import javax.xml.bind.JAXBElement;
import net.opengis.gml.v_3_1_1.PolygonType;
import net.opengis.gml.v_3_1_1.TimePositionType;
import net.opengis.ows.v_1_1_0.AllowedValues;
import net.opengis.ows.v_1_1_0.AnyValue;
import net.opengis.ows.v_1_1_0.BoundingBoxType;
import net.opengis.ows.v_1_1_0.CodeType;
import net.opengis.ows.v_1_1_0.DomainMetadataType;
import net.opengis.ows.v_1_1_0.ObjectFactory;
import net.opengis.ows.v_1_1_0.UnNamedDomainType;
import net.opengis.ows.v_1_1_0.ValueType;
import net.opengis.wcs.v_1_1_2.AvailableKeys;
import net.opengis.wcs.v_1_1_2.AxisType;
import net.opengis.wcs.v_1_1_2.CoverageDescriptionType;
import net.opengis.wcs.v_1_1_2.CoverageDomainType;
import net.opengis.wcs.v_1_1_2.FieldType;
import net.opengis.wcs.v_1_1_2.GridCrsType;
import net.opengis.wcs.v_1_1_2.InterpolationMethodType;
import net.opengis.wcs.v_1_1_2.InterpolationMethods;
import net.opengis.wcs.v_1_1_2.RangeType;
import net.opengis.wcs.v_1_1_2.SpatialDomainType;
import net.opengis.wcs.v_1_1_2.TimePeriodType;
import net.opengis.wcs.v_1_1_2.TimeSequenceType;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311CoordinateConverter;
import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311LinearRingConverter;
import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311PolygonConverter;
import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311SRSReferenceGroupConverter;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.ogc.common.spatial.Composite3DBoundingBox;
import com.raytheon.uf.edex.ogc.common.spatial.CrsLookup;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate;
import com.raytheon.uf.edex.wcs.reg.CoverageDescription;
import com.raytheon.uf.edex.wcs.reg.RangeAxis;
import com.raytheon.uf.edex.wcs.reg.RangeField;
import com.raytheon.uf.edex.wcs.reg.RangeField.InterpolationType;
import com.raytheon.uf.edex.wcs.reg.RangeFieldDefinition;
import com.vividsolutions.jts.geom.Polygon;
/**
*
* @author bclement
* @version 1.0
*/
public class DescCoverageBuilder {
protected ObjectFactory owsFactory = new ObjectFactory();
protected org.jvnet.ogc.gml.v_3_1_1.ObjectFactory gmlFactory = new org.jvnet.ogc.gml.v_3_1_1.ObjectFactory();
protected List<String> formats;
protected JTSToGML311PolygonConverter polyConverter;
/**
* @param formats
*/
public DescCoverageBuilder(List<String> formats) {
super();
this.formats = formats;
JTSToGML311SRSReferenceGroupConverter srsConv = new JTSToGML311SRSReferenceGroupConverter();
JTSToGML311CoordinateConverter coordConv = new JTSToGML311CoordinateConverter(
gmlFactory, srsConv);
JTSToGML311LinearRingConverter ringConv = new JTSToGML311LinearRingConverter(
gmlFactory, srsConv, coordConv);
polyConverter = new JTSToGML311PolygonConverter(gmlFactory, srsConv,
ringConv);
}
protected List<JAXBElement<?>> getBboxes(List<Composite3DBoundingBox> bboxes) {
if (bboxes == null) {
return null;
}
List<JAXBElement<?>> rval = new ArrayList<JAXBElement<?>>(bboxes.size());
for (Composite3DBoundingBox from : bboxes) {
BoundingBoxType to = owsFactory.createBoundingBoxType();
ReferencedEnvelope horiz = from.getHorizontal();
List<Double> lc = new ArrayList<Double>(3);
List<Double> uc = new ArrayList<Double>(3);
lc.add(horiz.getMinX());
lc.add(horiz.getMinY());
uc.add(horiz.getMaxX());
uc.add(horiz.getMaxY());
if (from.hasVertical()) {
VerticalCoordinate vert = from.getVertical();
lc.add(vert.getMin());
uc.add(vert.getMax());
}
to.setUpperCorner(uc);
to.setLowerCorner(lc);
to.setCrs(CrsLookup.createCrsURN(from));
to.setDimensions(BigInteger.valueOf(lc.size()));
rval.add(owsFactory.createBoundingBox(to));
}
return rval;
}
protected PolygonType transform(Polygon p) {
if (p == null) {
return null;
}
return polyConverter.createGeometryType(p);
}
protected List<PolygonType> getPolys(Polygon... poly) {
if (poly == null) {
return null;
}
List<PolygonType> rval = new ArrayList<PolygonType>(poly.length);
for (Polygon p : poly) {
rval.add(transform(p));
}
return rval;
}
protected SpatialDomainType getSpatialDomain(CoverageDescription desc) {
SpatialDomainType rval = new SpatialDomainType();
List<JAXBElement<?>> bboxes = getBboxes(desc.getBboxes());
if (bboxes != null) {
rval.setBoundingBox(bboxes);
}
rval.setPolygon(getPolys(desc.getPolygon()));
rval.setGridCRS(getGridCrs(desc));
return rval;
}
/**
* @param dimentions
* @param gridBaseCrs
* @return
*/
protected GridCrsType getGridCrs(CoverageDescription desc) {
GridCrsType rval = new GridCrsType();
rval.setGridBaseCRS(desc.getGridBaseCrs());
rval.setGridType(desc.getGridType());
List<Double> gridOrigin = desc.getGridOrigin();
if (gridOrigin != null) {
rval.setGridOrigin(gridOrigin);
}
List<Double> gridOffsets = desc.getGridOffsets();
if (gridOffsets != null) {
rval.setGridOffsets(gridOffsets);
}
rval.setGridCS(desc.getGridCs());
return rval;
}
private static final ThreadLocal<SimpleDateFormat> ISO_FORMAT = new ThreadLocal<SimpleDateFormat>() {
/*
* (non-Javadoc)
*
* @see java.lang.ThreadLocal#initialValue()
*/
@Override
protected SimpleDateFormat initialValue() {
SimpleDateFormat rval = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
rval.setTimeZone(TimeZone.getTimeZone("GMT"));
return rval;
}
};
protected TimePositionType transform(Date time) {
TimePositionType rval = new TimePositionType();
// client can't parse all ISO 8601, and it's our problem for some reason
// String timeStr = LayerTransformer.format(time);
String timeStr = ISO_FORMAT.get().format(time);
rval.setValue(Arrays.asList(timeStr));
return rval;
}
protected TimeSequenceType getTimeSequence(List<DataTime> times) {
if (times == null) {
return null;
}
TimeSequenceType timeSequence = new TimeSequenceType();
List<Object> rval = new ArrayList<Object>(times.size());
for (DataTime time : times) {
if (time.getUtilityFlags().contains(DataTime.FLAG.PERIOD_USED)) {
TimePeriodType tp = new TimePeriodType();
TimeRange vp = time.getValidPeriod();
tp.setBeginPosition(transform(vp.getStart()));
tp.setEndPosition(transform(vp.getEnd()));
tp.setTimeResolution("PT0S");
rval.add(tp);
} else {
rval.add(transform(time.getRefTime()));
}
}
timeSequence.setTimePositionOrTimePeriod(rval);
return timeSequence;
}
protected CoverageDomainType getDomain(CoverageDescription desc) {
CoverageDomainType coverageDomain = new CoverageDomainType();
coverageDomain.setSpatialDomain(getSpatialDomain(desc));
coverageDomain.setTemporalDomain(getTimeSequence(desc.getTimes()));
return coverageDomain;
}
public CoverageDescriptionType getCoverageDescriptionType(
CoverageDescription description) {
CoverageDescriptionType cdt = new CoverageDescriptionType();
cdt.setIdentifier(description.getIdentifier());
cdt.setTitle(getAsLangString(description.getTitle()));
cdt.setAbstract(getAsLangString(description.getAbstractStr()));
if (description.getKeywords() != null) {
cdt.setKeywords(getKeywords(description.getKeywords()));
}
cdt.setSupportedCRS(description.getCrs());
cdt.setSupportedFormat(formats);
cdt.setDomain(getDomain(description));
cdt.setRange(getRange(description.getRangeFields()));
return cdt;
}
protected ValueType getAsValue(Object obj) {
if (obj == null) {
return null;
}
ValueType rval = new ValueType();
rval.setValue(obj.toString());
return rval;
}
protected DomainMetadataType getUnits(String units) {
if (units == null) {
return null;
}
DomainMetadataType uom = new DomainMetadataType();
uom.setValue(units);
return uom;
}
protected AllowedValues getAllowedValues(RangeFieldDefinition def) {
AllowedValues values = new AllowedValues();
net.opengis.ows.v_1_1_0.RangeType range = new net.opengis.ows.v_1_1_0.RangeType();
range.setMaximumValue(getAsValue(def.getMaxValue()));
range.setMinimumValue(getAsValue(def.getMinValue()));
values.setValueOrRange(Arrays.asList((Object) range));
return values;
}
protected UnNamedDomainType getUnamed(RangeFieldDefinition def) {
UnNamedDomainType rval = new UnNamedDomainType();
if (def == null) {
rval.setAnyValue(new AnyValue());
} else {
rval.setAllowedValues(getAllowedValues(def));
rval.setUOM(getUnits(def.getUnits()));
}
return rval;
}
protected FieldType transform(RangeField from) {
if (from == null) {
return null;
}
FieldType rval = new FieldType();
rval.setIdentifier(from.getIdentifier());
rval.setDefinition(getUnamed(from.getDefinition()));
rval.setInterpolationMethods(getInterps(from.getDefaultInterpolation(),
from.getAdditionalInterpolations()));
if (from.getAxis() != null) {
rval.setAxis(getAxis(from.getAxis()));
}
if (from.getNullValue() != null) {
rval.setNullValue(getNullValues(from.getNullValue()));
}
return rval;
}
/**
* @param nullValue
* @return
*/
protected List<CodeType> getNullValues(String... nullValue) {
if (nullValue == null) {
return null;
}
List<CodeType> rval = new ArrayList<CodeType>(nullValue.length);
for (String val : nullValue) {
CodeType code = new CodeType();
code.setValue(val);
rval.add(code);
}
return rval;
}
protected AvailableKeys getKeys(Set<String> keys) {
if (keys == null) {
return null;
}
AvailableKeys rval = new AvailableKeys();
rval.setKey(new ArrayList<String>(keys));
return rval;
}
/**
* @param axis
* @return
*/
private List<AxisType> getAxis(List<RangeAxis> axis) {
if (axis == null) {
return null;
}
List<AxisType> rval = new ArrayList<AxisType>(axis.size());
for (RangeAxis ra : axis) {
AxisType at = new AxisType();
at.setIdentifier(ra.getIdentifier());
at.setAvailableKeys(getKeys(ra.getKeys()));
rval.add(at);
}
return rval;
}
protected List<InterpolationMethodType> transform(
List<InterpolationType> from) {
if (from == null) {
return null;
}
List<InterpolationMethodType> rval = new ArrayList<InterpolationMethodType>(
from.size());
for (InterpolationType type : from) {
InterpolationMethodType method = new InterpolationMethodType();
method.setValue(type.toString());
rval.add(method);
}
return rval;
}
/**
* @param defaultInterpolation
* @param additionalInterpolations
* @return
*/
protected InterpolationMethods getInterps(InterpolationType defaultInt,
List<InterpolationType> additional) {
InterpolationMethods rval = new InterpolationMethods();
if (defaultInt == null) {
defaultInt = InterpolationType.none;
}
rval.setDefault(defaultInt.toString());
if (additional != null) {
rval.setInterpolationMethod(transform(additional));
}
return rval;
}
/**
* @param rangeFields
* @return
*/
protected RangeType getRange(List<RangeField> rangeFields) {
if (rangeFields == null) {
return null;
}
List<FieldType> rval = new ArrayList<FieldType>(rangeFields.size());
for (RangeField rf : rangeFields) {
rval.add(transform(rf));
}
RangeType rt = new RangeType();
rt.setField(rval);
return rt;
}
}

View file

@ -1,830 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.provider;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import net.opengis.gml.v_3_1_1.TimePositionType;
import net.opengis.ows.v_1_1_0.AbstractReferenceBaseType;
import net.opengis.ows.v_1_1_0.BoundingBoxType;
import net.opengis.ows.v_1_1_0.CodeType;
import net.opengis.ows.v_1_1_0.ExceptionReport;
import net.opengis.ows.v_1_1_0.ExceptionType;
import net.opengis.ows.v_1_1_0.GetCapabilitiesType;
import net.opengis.ows.v_1_1_0.ReferenceGroupType;
import net.opengis.ows.v_1_1_0.ReferenceType;
import net.opengis.wcs.v_1_1_2.AxisSubset;
import net.opengis.wcs.v_1_1_2.Capabilities;
import net.opengis.wcs.v_1_1_2.CoverageDescriptionType;
import net.opengis.wcs.v_1_1_2.CoverageDescriptions;
import net.opengis.wcs.v_1_1_2.CoveragesType;
import net.opengis.wcs.v_1_1_2.DescribeCoverage;
import net.opengis.wcs.v_1_1_2.GetCapabilities;
import net.opengis.wcs.v_1_1_2.GetCoverage;
import net.opengis.wcs.v_1_1_2.ObjectFactory;
import net.opengis.wcs.v_1_1_2.RangeSubsetType;
import net.opengis.wcs.v_1_1_2.RangeSubsetType.FieldSubset;
import net.opengis.wcs.v_1_1_2.TimePeriodType;
import net.opengis.wcs.v_1_1_2.TimeSequenceType;
import org.apache.commons.codec.binary.Base64InputStream;
import org.apache.cxf.helpers.IOUtils;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.ogc.common.OgcBoundingBox;
import com.raytheon.uf.edex.ogc.common.OgcNamespace;
import com.raytheon.uf.edex.ogc.common.OgcOperationInfo;
import com.raytheon.uf.edex.ogc.common.OgcPrefix;
import com.raytheon.uf.edex.ogc.common.OgcResponse;
import com.raytheon.uf.edex.ogc.common.OgcResponse.ErrorType;
import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE;
import com.raytheon.uf.edex.ogc.common.OgcServiceInfo;
import com.raytheon.uf.edex.ogc.common.http.EndpointInfo;
import com.raytheon.uf.edex.ogc.common.http.MimeType;
import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager;
import com.raytheon.uf.edex.ogc.common.output.IOgcHttpResponse;
import com.raytheon.uf.edex.ogc.common.spatial.Composite3DBoundingBox;
import com.raytheon.uf.edex.ogc.common.spatial.CrsLookup;
import com.raytheon.uf.edex.wcs.CoverageStoreEndpoint;
import com.raytheon.uf.edex.wcs.CoveragesHolder;
import com.raytheon.uf.edex.wcs.WcsException;
import com.raytheon.uf.edex.wcs.WcsException.Code;
import com.raytheon.uf.edex.wcs.WcsProvider;
import com.raytheon.uf.edex.wcs.format.IWcsDataFormatter;
import com.raytheon.uf.edex.wcs.reg.Coverage;
import com.raytheon.uf.edex.wcs.reg.CoverageDescription;
import com.raytheon.uf.edex.wcs.reg.IWcsSource;
import com.raytheon.uf.edex.wcs.reg.RangeAxis;
import com.raytheon.uf.edex.wcs.reg.RangeField;
import com.raytheon.uf.edex.wcs.reg.RangeField.InterpolationType;
import com.raytheon.uf.edex.wcs.reg.WcsSourceAccessor;
import com.raytheon.uf.edex.wcs.request.DescCoverageRequest;
import com.raytheon.uf.edex.wcs.request.GetCapRequest;
import com.raytheon.uf.edex.wcs.request.GetCoverageRequest;
import com.raytheon.uf.edex.wcs.request.WcsRequest;
import com.raytheon.uf.edex.wcs.request.WcsRequest.Type;
import com.vividsolutions.jts.geom.Envelope;
/**
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
*
* </pre>
*
* @author cwmitche
* @version 1
*/
public class OgcWcsProvider implements WcsProvider {
public enum WcsOpType {
GetCapabilities, GetCoverage, DescribeCoverage
}
protected static final String version = "1.1.2";
protected static final String svcTitle = "EDEX Coverage Server";
protected final OgcJaxbManager jaxbManager;
protected final String COVERAGE_ID = "cid:Coverage-";
protected final IUFStatusHandler log = UFStatus.getHandler(this.getClass());
private volatile DescCoverageBuilder _descCoverage;
private volatile CapabilitiesBuilder _capbuilder;
protected boolean base64 = true;
protected final net.opengis.ows.v_1_1_0.ObjectFactory owsFactory = new net.opengis.ows.v_1_1_0.ObjectFactory();
protected final ObjectFactory wcsFactory = new ObjectFactory();
protected static final Map<String, String> NS_MAP = new ConcurrentHashMap<String, String>();
private int restPort = 8085;
private String covStorePath = "coverage";
static {
NS_MAP.put(OgcNamespace.EDEX, OgcPrefix.EDEX);
NS_MAP.put(OgcNamespace.GML, OgcPrefix.GML);
NS_MAP.put(OgcNamespace.OGC, OgcPrefix.OGC);
NS_MAP.put(OgcNamespace.OWS110, OgcPrefix.OWS);
NS_MAP.put(OgcNamespace.WFS, OgcPrefix.WFS);
NS_MAP.put(OgcNamespace.XSI, OgcPrefix.XSI);
NS_MAP.put(OgcNamespace.WCS112, OgcPrefix.WCS);
NS_MAP.put(OgcNamespace.XLINK, OgcPrefix.XLINK);
}
public OgcWcsProvider(OgcJaxbManager manager) throws JAXBException {
this.jaxbManager = manager;
jaxbManager.setPrefixMap(NS_MAP);
}
protected DescCoverageBuilder getCoverageBuilder() {
if (_descCoverage == null) {
synchronized (wcsFactory) {
if (_descCoverage == null) {
List<String> formats = WcsSourceAccessor.getFormats();
if (formats.isEmpty()) {
// don't remember list if empty, may not be initialized
// yet
return new DescCoverageBuilder(formats);
} else {
_descCoverage = new DescCoverageBuilder(formats);
}
}
}
}
return _descCoverage;
}
protected CapabilitiesBuilder getCapBuilder() {
if (_capbuilder == null) {
synchronized (wcsFactory) {
if (_capbuilder == null) {
List<String> formats = WcsSourceAccessor.getFormats();
if (formats.isEmpty()) {
// don't remember list if empty, may not be initialized
// yet
return new CapabilitiesBuilder(formats);
} else {
_capbuilder = new CapabilitiesBuilder(formats);
}
}
}
}
return _capbuilder;
}
@Override
public OgcResponse describeCoverageType(
OgcServiceInfo<WcsOpType> serviceinfo, DescCoverageRequest request) {
CoverageDescriptions rval;
try {
rval = describeCoverage(serviceinfo, request);
return marshalResponse(rval);
} catch (WcsException e) {
return getError(e, request.getExceptionFormat());
}
}
public CoverageDescriptions describeCoverage(EndpointInfo info,
DescCoverageRequest request) throws WcsException {
return describeCoverage(getServiceInfo(info), request);
}
public CoverageDescriptions describeCoverage(
OgcServiceInfo<WcsOpType> serviceinfo, DescCoverageRequest request)
throws WcsException {
CoverageDescriptions rval = new CoverageDescriptions();
String[] externalIds = request.getExternalIds();
List<CoverageDescriptionType> descs = null;
if (externalIds == null) {
throw new WcsException(Code.MissingParameterValue);
}
String[] internalIds = request.getInternalIds();
descs = new ArrayList<CoverageDescriptionType>(externalIds.length);
for (int i = 0; i < externalIds.length; ++i) {
String external = externalIds[i];
String internal = internalIds[i];
descs.add(descCov(external, internal));
}
rval.setCoverageDescription(descs);
return rval;
}
protected CoverageDescriptionType descCov(String externalId,
String internalId) throws WcsException {
IWcsSource<?, ?> source = WcsSourceAccessor.getSource(internalId);
if (source == null) {
throw new WcsException(Code.InvalidParameterValue,
"Coverage ID not found");
}
CoverageDescription cd = source.describeCoverage(internalId);
cd.setIdentifier(externalId);
return getCoverageBuilder().getCoverageDescriptionType(cd);
}
@Override
public OgcResponse getCapabilities(OgcServiceInfo<WcsOpType> serviceinfo,
GetCapRequest request) {
Capabilities capabilities = getCapBuilder().getCapabilities(
serviceinfo, WcsSourceAccessor.getCoverages(true));
return marshalResponse(capabilities);
}
public Capabilities getCapabilities(EndpointInfo info,
GetCapabilities request) {
return getCapBuilder().getCapabilities(getServiceInfo(info),
getCoverages(true));
}
/**
* @param summary
* @return list of coverages with mapped identifiers
*/
private List<CoverageDescription> getCoverages(boolean summary) {
List<CoverageDescription> coverages = WcsSourceAccessor
.getCoverages(true);
for (CoverageDescription desc : coverages) {
String id = CustomIdMap.internalToExternal(desc.getIdentifier());
desc.setIdentifier(id);
}
return coverages;
}
private OgcServiceInfo<WcsOpType> getServiceInfo(EndpointInfo info) {
int port = info.getPort();
String base = "http://" + info.getHost();
if (port != 80) {
base += ":" + port;
}
base += info.getPath();
OgcServiceInfo<WcsOpType> rval = new OgcServiceInfo<WcsOpType>(base);
rval.addOperationInfo(getOp(base, base, WcsOpType.GetCapabilities, info));
rval.addOperationInfo(getOp(base, base, WcsOpType.DescribeCoverage,
info));
rval.addOperationInfo(getOp(base, base, WcsOpType.GetCoverage, info));
return rval;
}
protected OgcOperationInfo<WcsOpType> getOp(String get, String post,
WcsOpType type, EndpointInfo info) {
OgcOperationInfo<WcsOpType> rval = new OgcOperationInfo<WcsOpType>(type);
rval.setHttpBaseHostname(info.getHost());
if (!info.isPostOnly()) {
rval.setHttpGetRes(get);
}
rval.setHttpPostRes(post);
rval.addVersion(version);
rval.addAcceptVersions(version);
rval.addService("WCS");
rval.addFormat("text/xml");
rval.setPostEncoding(info.getEncoding());
return rval;
}
public CoveragesHolder getCoverage(EndpointInfo info,
GetCoverageRequest request) throws WcsException {
String format = request.getFormat();
// try fast lookup first
Map<String, IWcsDataFormatter> formatMap = WcsSourceAccessor
.getFormatMap();
IWcsDataFormatter formatter = formatMap.get(format);
if (formatter == null) {
// check to see if any formatter handles it
for (Entry<String, IWcsDataFormatter> e : formatMap.entrySet()) {
if (e.getValue().matchesFormat(format)) {
formatter = e.getValue();
break;
}
}
if (formatter == null) {
// no match found
throw new WcsException(Code.InvalidFormat);
}
}
String externalId = request.getExternalId();
Coverage coverage = requestCoverage(request);
coverage.setName(CustomIdMap.internalToExternal(coverage.getName()));
CoveragesHolder holder = new CoveragesHolder();
holder.setContentType(format);
Map<String, byte[]> data = new HashMap<String, byte[]>();
String href;
if (request.isStore()) {
try {
File f = formatter.store(coverage);
href = String.format("http://%s:%d/%s?%s=%s", info.getHost(),
restPort, covStorePath,
CoverageStoreEndpoint.ID_HEADER, f.getName());
} catch (Exception e) {
log.error("Problem formatting coverage", e);
throw new WcsException(Code.InternalServerError);
}
} else {
href = getCoverageId(externalId);
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = null;
try {
in = formatter.format(coverage);
IOUtils.copy(in, out);
out.flush();
} catch (Exception e) {
log.error("Problem formatting coverage", e);
throw new WcsException(Code.InternalServerError);
} finally {
close(in, out);
}
data.put(href, out.toByteArray());
}
CoveragesType rval = getCoverageOgcResponse(externalId, href);
holder.setMetadata(rval);
holder.setData(data);
return holder;
}
private Coverage requestCoverage(GetCoverageRequest request)
throws WcsException {
String id = request.getInternalId();
IWcsSource<?, ?> source = WcsSourceAccessor.getSource(id);
if (source == null) {
throw new WcsException(Code.InvalidParameterValue,
"Coverage ID not found");
}
Composite3DBoundingBox bbox = request.getBbox();
return source.getCoverage(id, request.getTimeSequence(), bbox,
request.getFields());
}
private void close(InputStream in, OutputStream out) {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (Throwable t) {
log.error("Unable to close streams", t);
}
}
@Override
public void getCoverage(OgcServiceInfo<WcsOpType> serviceinfo,
GetCoverageRequest request, IOgcHttpResponse httpResp) {
try {
String format = request.getFormat();
IWcsDataFormatter formatter = WcsSourceAccessor.getFormatMap().get(
format);
if (formatter == null) {
throw new WcsException(Code.InvalidFormat);
}
String externalId = request.getExternalId();
Coverage coverage = requestCoverage(request);
coverage.setName(CustomIdMap.internalToExternal(coverage.getName()));
CoveragesType coveragesType = getCoverageOgcResponse(externalId,
getCoverageId(externalId));
try {
// FIXME this code block makes my eyes bleed, needs to be
// refactored
OutputStream out = httpResp.getOutputStream();
if (request.isDefacto()) {
httpResp.setContentType(formatter.getIdentifier());
InputStream in = formatter.format(coverage);
if (base64) {
in = new Base64InputStream(in, true);
}
IOUtils.copy(in, out);
out.flush();
out.close();
in.close();
return;
}
long timestamp = System.currentTimeMillis();
String part = "_Part_" + timestamp;
httpResp.setContentType("multipart/related;boundary=" + part);
PrintStream stream = new PrintStream(out);
String cid = getCoverageId(externalId);
stream.println("--" + part);
stream.println("Content-Type: text/xml");
stream.println("Content-ID: <urn:ogc:wcs:1.1:coverages>");
stream.println();
stream.println(jaxbManager.marshal(wcsFactory
.createCoverages(coveragesType)));
stream.println("--" + part);
stream.println("Content-Type: " + formatter.getIdentifier());
if (base64) {
stream.println("Content-Transfer-Encoding: base64");
}
stream.println("Content-ID: <" + cid + ">");
stream.println();
stream.flush();
InputStream in = formatter.format(coverage);
if (base64) {
in = new Base64InputStream(in, true);
}
IOUtils.copy(in, out);
out.flush();
out.close();
in.close();
} catch (Exception e) {
log.error("Problem formatting coverage", e);
throw new WcsException(Code.InternalServerError);
}
} catch (WcsException e) {
sendTextResponse(httpResp,
getError(e, request.getExceptionFormat()));
}
}
protected void sendTextResponse(IOgcHttpResponse httpRes,
OgcResponse response) {
MimeType mimetype = response.getMimetype();
httpRes.setContentType(mimetype.toString());
try {
Writer writer = new OutputStreamWriter(httpRes.getOutputStream());
writer.write(response.getBody().toString());
writer.close();
} catch (IOException e) {
log.error("Problem sending response", e);
}
}
/**
* @param bbox
* @return
* @throws WcsException
*/
protected Envelope getEnvelope(OgcBoundingBox bbox) throws WcsException {
if (bbox == null) {
throw new WcsException(Code.MissingParameterValue,
"Missing bounding box");
}
return new Envelope(bbox.getMinx(), bbox.getMaxx(), bbox.getMiny(),
bbox.getMaxy());
}
/**
* @param bbox
* @return
* @throws WcsException
*/
protected CoordinateReferenceSystem getCrs(OgcBoundingBox bbox)
throws WcsException {
if (bbox != null) {
try {
return CrsLookup.lookup(bbox.getCrs());
} catch (Exception e) {
log.error("Unable to decode crs: " + bbox.getCrs(), e);
}
}
throw new WcsException(Code.MissingParameterValue,
"Missing bounding box.");
}
protected String getCoverageId(String identifier) {
return COVERAGE_ID + identifier;
}
protected CoveragesType getCoverageOgcResponse(String identifier,
String href) {
CoveragesType coverages = new CoveragesType();
List<ReferenceGroupType> coverageList = new ArrayList<ReferenceGroupType>();
ReferenceGroupType rgt = new ReferenceGroupType();
// Abstract
// rgt.setAbstract(WcsJaxbUtils.getAsLangString("Abstract for "
// + request.getIdentifier()));
// Title
// rgt.setTitle(WcsJaxbUtils.getAsLangString(request.getIdentifier()));
// Identifier
CodeType ident = new CodeType();
ident.setValue(identifier);
rgt.setIdentifier(ident);
// Data reference
ReferenceType rt = new ReferenceType();
rt.setHref(href);
List<JAXBElement<? extends AbstractReferenceBaseType>> refTypeList = new ArrayList<JAXBElement<? extends AbstractReferenceBaseType>>();
refTypeList.add(owsFactory.createReference(rt));
rgt.setAbstractReferenceBase(refTypeList);
coverageList.add(rgt);
coverages.setCoverage(coverageList);
return coverages;
}
@Override
public OgcResponse getError(WcsException e, MimeType exceptionFormat) {
net.opengis.ows.v_1_1_0.ExceptionType et = new ExceptionType();
et.setExceptionCode(e.getCode().toString());
et.setExceptionText(getAsList(e.getMessage()));
net.opengis.ows.v_1_1_0.ExceptionReport report = new ExceptionReport();
report.setException(getAsList(et));
String rval = "";
MimeType mimeType = OgcResponse.TEXT_XML_MIME;
if (exceptionFormat.equalsIgnoreParams(OgcResponse.TEXT_XML_MIME)) {
try {
rval = jaxbManager.marshal(report);
mimeType = OgcResponse.TEXT_XML_MIME;
} catch (JAXBException e1) {
log.error("Unable to marshal WCS response", e1);
rval = "<ows:ExceptionReport version=\"1.0.0\"";
rval += "xsi:schemaLocation=\"http://www.opengis.net/ows\"";
rval += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:ows=\"http://www.opengis.net/ows\">";
rval += "<ows:Exception exceptionCode=\"" + e.getCode() + "\">";
rval += "<ows:ExceptionText>" + e.getMessage()
+ "</ows:ExceptionText>";
rval += "</ows:Exception></ows:ExceptionReport>";
mimeType = OgcResponse.TEXT_XML_MIME;
}
} else if (exceptionFormat
.equalsIgnoreParams(OgcResponse.TEXT_HTML_MIME)) {
rval = "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
rval += "<br>An error occurred performing the request:<br>";
rval += "<br>Error Code: " + e.getCode().toString();
rval += "<br>Message: " + e.getMessage() + "</html>";
mimeType = OgcResponse.TEXT_HTML_MIME;
}
OgcResponse resp = new OgcResponse(rval, mimeType, TYPE.TEXT);
switch (e.getCode()) {
case InternalServerError:
resp.setError(ErrorType.INT_ERR);
break;
case OperationNotSupported:
resp.setError(ErrorType.NOT_IMPLEMENTED);
break;
default:
resp.setError(ErrorType.BAD_REQ);
}
return resp;
}
protected net.opengis.wms.v_1_3_0.Exception getExceptionInfo() {
net.opengis.wms.v_1_3_0.Exception rval = new net.opengis.wms.v_1_3_0.Exception();
rval.setFormat(getAsList("XML"));
return rval;
}
@Override
public WcsRequest getRequest(InputStream in) {
Object obj;
WcsRequest rval;
try {
String xml = getXml(in);
obj = jaxbManager.unmarshal(xml);
rval = getType(obj);
} catch (Throwable e) {
log.error("Unable to decode request", e);
rval = new WcsRequest(Type.ERROR);
}
if (rval.getType().equals(Type.ERROR)) {
OgcResponse error = getError(new WcsException(Code.InvalidRequest,
"Unable to decode request"), OgcResponse.TEXT_XML_MIME);
rval.setRequest(error);
}
return rval;
}
public <T> List<T> getAsList(T... args) {
List<T> rval = new LinkedList<T>();
for (T t : args) {
rval.add(t);
}
return rval;
}
protected WcsRequest getType(Object obj) {
WcsRequest rval;
if (obj instanceof GetCapabilitiesType) {
rval = new GetCapRequest();
} else if (obj instanceof GetCoverage) {
rval = unwrap((GetCoverage) obj);
} else if (obj instanceof DescribeCoverage) {
DescribeCoverage req = (DescribeCoverage) obj;
List<String> ids = req.getIdentifier();
DescCoverageRequest dcr = new DescCoverageRequest();
dcr.setIdentifiers(ids);
rval = dcr;
} else {
rval = new WcsRequest(Type.ERROR);
}
return rval;
}
/**
* @param obj
* @return
*/
protected WcsRequest unwrap(GetCoverage req) {
try {
return new GetCoverageRequest(req);
} catch (WcsException e) {
WcsRequest rval = new WcsRequest(Type.ERROR);
rval.setRequest(e);
return rval;
}
}
protected List<RangeField> transform(RangeSubsetType subset) {
if (subset == null) {
return null;
}
List<FieldSubset> fields = subset.getFieldSubset();
if (fields == null || fields.isEmpty()) {
return null;
}
List<RangeField> rval = new ArrayList<RangeField>(fields.size());
for (FieldSubset fs : fields) {
rval.add(transform(fs));
}
return rval;
}
protected RangeField transform(FieldSubset fs) {
String id = fs.getIdentifier().getValue();
RangeField rval = new RangeField(id, null);
String interp = fs.getInterpolationType();
if (interp != null) {
rval.setDefaultInterpolation(InterpolationType.valueOf(interp));
}
rval.setAxis(transform(fs.getAxisSubset()));
return rval;
}
/**
* @param axisSubset
* @return
*/
protected List<RangeAxis> transform(List<AxisSubset> axisSubset) {
if (axisSubset == null || axisSubset.isEmpty()) {
return null;
}
List<RangeAxis> rval = new ArrayList<RangeAxis>(axisSubset.size());
for (AxisSubset as : axisSubset) {
Set<String> keys = new HashSet<String>(as.getKey());
rval.add(new RangeAxis(as.getIdentifier(), keys));
}
return rval;
}
protected OgcBoundingBox transform(BoundingBoxType bbox) {
OgcBoundingBox rval = new OgcBoundingBox();
rval.setCrs(bbox.getCrs());
List<Double> lower = bbox.getLowerCorner();
List<Double> upper = bbox.getUpperCorner();
rval.setMaxx(upper.get(0));
rval.setMaxy(upper.get(1));
rval.setMinx(lower.get(0));
rval.setMiny(lower.get(1));
return rval;
}
protected DataTime getTime(TimeSequenceType tst) {
if (tst == null) {
return null;
}
List<Object> times = tst.getTimePositionOrTimePeriod();
if (times == null || times.isEmpty()) {
return null;
}
if (times.size() != 1) {
log.warn("multiple times not supported in request, taking first");
}
Object timeObj = times.get(0);
return parseTime(timeObj);
}
protected DataTime parseTime(Object timeObj) {
if (timeObj instanceof TimePositionType) {
TimePositionType pos = (TimePositionType) timeObj;
return new DataTime(getTime(pos));
} else {
TimePeriodType period = (TimePeriodType) timeObj;
Date start = getTime(period.getBeginPosition());
Date end = getTime(period.getEndPosition());
TimeRange range = new TimeRange(start, end);
DataTime rval = new DataTime(start);
rval.setValidPeriod(range);
return rval;
}
}
protected Date getTime(TimePositionType pos) {
List<String> values = pos.getValue();
if (values == null || values.isEmpty()) {
log.error("unable to parse time");
return null;
}
return DatatypeConverter.parseDateTime(values.get(0)).getTime();
}
protected String getXml(InputStream in) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String rval = "";
String line = "";
while ((line = reader.readLine()) != null) {
rval += line + "\n";
}
return rval;
}
protected OgcResponse marshalResponse(Object jaxbobject) {
OgcResponse rval;
try {
String xml = jaxbManager.marshal(jaxbobject);
rval = new OgcResponse(xml, OgcResponse.TEXT_XML_MIME, TYPE.TEXT);
} catch (JAXBException e) {
log.error("Unable to marshal WCS response", e);
// TODO: real error code
rval = getError(new WcsException(Code.OperationNotSupported),
OgcResponse.TEXT_XML_MIME);
}
return rval;
}
public boolean isBase64() {
return base64;
}
public void setBase64(boolean base64) {
this.base64 = base64;
}
/**
* @return the restPort
*/
public int getRestPort() {
return restPort;
}
/**
* @param restPort
* the restPort to set
*/
public void setRestPort(int restPort) {
this.restPort = restPort;
}
/**
* @return the covStorePath
*/
public String getCovStorePath() {
return covStorePath;
}
/**
* @param covStorePath
* the covStorePath to set
*/
public void setCovStorePath(String covStorePath) {
this.covStorePath = covStorePath;
}
}

View file

@ -1,123 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.provider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import net.opengis.ows.v_1_1_0.DomainType;
import net.opengis.ows.v_1_1_0.ObjectFactory;
import com.raytheon.uf.edex.ogc.common.AbstractOpDescriber;
import com.raytheon.uf.edex.ogc.common.OgcOperationInfo;
import com.raytheon.uf.edex.ogc.common.OgcServiceInfo;
import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType;
/**
*
* @author bclement
* @version 1.0
*/
public class OperationsDescriber extends AbstractOpDescriber<WcsOpType> {
protected ObjectFactory owsFactory = new ObjectFactory();
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.AbstractOpDescriber#getParams(com.raytheon
* .uf.edex.ogc.common.OgcServiceInfo)
*/
@Override
protected List<DomainType> getParams(OgcServiceInfo<WcsOpType> serviceinfo) {
// TODO: this info should be passed in from somewhere
List<String> value = new LinkedList<String>();
value.add("EPSG:4326");
return Arrays.asList(getAsDomainType("srsName", value));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.AbstractOpDescriber#getOpParams(com.raytheon
* .uf.edex.ogc.common.OgcOperationInfo)
*/
@Override
protected List<DomainType> getOpParams(OgcOperationInfo<WcsOpType> op) {
List<DomainType> opParamList = new ArrayList<DomainType>();
switch (op.getType()) {
case GetCapabilities:
opParamList = Arrays.asList(
getAsDomainType("AcceptVersions", op.getVersions()),
getAsDomainType("AcceptFormats", op.getFormats()),
getAsDomainType("service", op.getServices()));
break;
case DescribeCoverage:
opParamList = Arrays.asList(
getAsDomainType("AcceptVersions", op.getVersions()),
getAsDomainType("AcceptFormats", op.getFormats()),
getAsDomainType("service", op.getServices()));// ,
// getAsDomainType("Identifier", getLayerIdentifierList()));
break;
case GetCoverage:
opParamList = Arrays
.asList(getAsDomainType("AcceptVersions", op.getVersions()),
getAsDomainType("AcceptFormats", op.getFormats()),
getAsDomainType("service", op.getServices()),
// getAsDomainType("Identifier",
// getLayerIdentifierList()),
getAsDomainType("InterpolationType",
getInterpolationType()),
getAsDomainType("store",
Arrays.asList("true", "false")));
break;
default:
}
return opParamList;
}
/**
* @return default interpolation types
*/
protected List<String> getInterpolationType() {
List<String> interpolationType = new ArrayList<String>();
interpolationType.add("nearest");
interpolationType.add("linear");
return interpolationType;
}
/**
* @return default formats
*/
protected List<String> getFormat() {
return new ArrayList<String>();
}
}

View file

@ -1,63 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.provider;
import java.util.ArrayList;
import java.util.List;
import net.opengis.ows.v_1_1_0.KeywordsType;
import net.opengis.ows.v_1_1_0.LanguageStringType;
/**
*
* @author bclement
* @version 1.0
*/
public class WcsJaxbUtils {
protected static final String DEFAULT_LANGUAGE = "english";
public static List<LanguageStringType> getAsLangString(String... strs) {
if (strs == null) {
return null;
}
List<LanguageStringType> rval = new ArrayList<LanguageStringType>(
strs.length);
for (String str : strs) {
LanguageStringType lst = new LanguageStringType();
lst.setLang(DEFAULT_LANGUAGE);
lst.setValue(str);
rval.add(lst);
}
return rval;
}
public static List<KeywordsType> getKeywords(List<String> strs) {
if (strs == null) {
return null;
}
List<KeywordsType> rval = new ArrayList<KeywordsType>(strs.size());
for (String str : strs) {
KeywordsType kwt = new KeywordsType();
kwt.setKeyword(getAsLangString(str));
}
return rval;
}
}

View file

@ -1,95 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.querystore;
import java.io.File;
import javax.xml.bind.JAXBException;
import net.opengis.wcs.v_1_1_2.GetCoverage;
import com.raytheon.uf.edex.ogc.common.AbstractFSQueryStore;
import com.raytheon.uf.edex.ogc.common.OgcException;
import com.raytheon.uf.edex.ogc.common.OgcException.Code;
import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 18, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class WcsQueryStore extends AbstractFSQueryStore<GetCoverage> {
private static final String STORE_NAME = "wcsquerystore";
protected final OgcJaxbManager jaxbManager;
/**
* @param registry
* @param storeLocation
* @throws IllegalArgumentException
* if storage location cannot be created or is not a writable
* directory
*/
public WcsQueryStore(OgcJaxbManager jaxbManager, File storeLocation)
throws IllegalArgumentException {
super(storeLocation);
this.jaxbManager = jaxbManager;
}
public WcsQueryStore(OgcJaxbManager jaxbManager) {
super(findStore(STORE_NAME));
this.jaxbManager = jaxbManager;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.AbstractFSQueryStore#marshal(java.lang
* .Object)
*/
@Override
protected String marshal(GetCoverage query) throws OgcException {
try {
return jaxbManager.marshal(query);
} catch (JAXBException e) {
throw new OgcException(Code.InternalServerError, e);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.edex.ogc.common.AbstractFSQueryStore#unmarshal(java.lang
* .String)
*/
@Override
protected GetCoverage unmarshal(String xml) throws OgcException {
try {
return (GetCoverage) jaxbManager.unmarshal(xml);
} catch (JAXBException e) {
throw new OgcException(Code.InternalServerError, e);
}
}
}

View file

@ -1,68 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.reg;
import java.util.List;
/**
* WCS Coverage
*
* @author bclement
* @version 1.0
*/
public class Coverage {
private String name;
private final List<CoverageField> fields;
/**
* @param name
* @param fields
*/
public Coverage(String name, List<CoverageField> fields) {
super();
this.name = name;
this.fields = fields;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the fields
*/
public List<CoverageField> getFields() {
return fields;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
}

View file

@ -1,186 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.reg;
import java.util.List;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox;
import com.raytheon.uf.edex.ogc.common.spatial.Composite3DBoundingBox;
import com.vividsolutions.jts.geom.Polygon;
/**
*
* @author bclement
* @version 1.0
*/
public class CoverageDescription {
protected String identifier;
protected String title;
protected String abstractStr;
protected List<String> crs;
protected List<String> keywords;
protected List<DataTime> times;
protected List<Composite3DBoundingBox> bboxes;
protected List<RangeField> rangeFields;
protected OgcGeoBoundingBox crs84Bbox;
protected Polygon polygon;
protected List<Double> gridOffsets;
protected String gridBaseCrs;
protected String gridType;
protected String gridCs;
protected List<Double> gridOrigin;
public OgcGeoBoundingBox getCrs84Bbox() {
return crs84Bbox;
}
public void setCrs84Bbox(OgcGeoBoundingBox crs84Bbox) {
this.crs84Bbox = crs84Bbox;
}
public List<Double> getGridOrigin() {
return gridOrigin;
}
public void setGridOrigin(List<Double> gridOrigin) {
this.gridOrigin = gridOrigin;
}
public String getGridType() {
return gridType;
}
public void setGridType(String gridType) {
this.gridType = gridType;
}
public String getGridCs() {
return gridCs;
}
public void setGridCs(String gridCs) {
this.gridCs = gridCs;
}
public String getGridBaseCrs() {
return gridBaseCrs;
}
public void setGridBaseCrs(String gridBaseCrs) {
this.gridBaseCrs = gridBaseCrs;
}
public List<Double> getGridOffsets() {
return gridOffsets;
}
public void setGridOffsets(List<Double> offsets) {
this.gridOffsets = offsets;
}
public Polygon getPolygon() {
return polygon;
}
public void setPolygon(Polygon polygon) {
this.polygon = polygon;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAbstractStr() {
return abstractStr;
}
public void setAbstractStr(String abstractStr) {
this.abstractStr = abstractStr;
}
public List<String> getCrs() {
return crs;
}
public void setCrs(List<String> crs) {
this.crs = crs;
}
public List<String> getKeywords() {
return keywords;
}
public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}
public List<DataTime> getTimes() {
return times;
}
public void setTimes(List<DataTime> times) {
this.times = times;
}
public List<Composite3DBoundingBox> getBboxes() {
return bboxes;
}
public void setBboxes(List<Composite3DBoundingBox> bboxes) {
this.bboxes = bboxes;
}
public List<RangeField> getRangeFields() {
return rangeFields;
}
public void setRangeFields(List<RangeField> rangeFields) {
this.rangeFields = rangeFields;
}
}

View file

@ -1,117 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.reg;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 2, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoverageDimensions {
private final CoverageXYAxis xyAxis;
private final CoverageZAxis zAxis;
private final CoverageTAxis tAxis;
/**
* @param xyAxis
* @param zAxis
* @param times
*/
public CoverageDimensions(CoverageXYAxis xyAxis, CoverageZAxis zAxis,
CoverageTAxis tAxis) {
this.xyAxis = xyAxis;
this.zAxis = zAxis;
this.tAxis = tAxis;
}
/**
* @return the xyAxis
*/
public CoverageXYAxis getXyAxis() {
return xyAxis;
}
/**
* @return the zAxis
*/
public CoverageZAxis getZAxis() {
return zAxis;
}
/**
* @return the tAxis
*/
public CoverageTAxis getTAxis() {
return tAxis;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((tAxis == null) ? 0 : tAxis.hashCode());
result = prime * result + ((xyAxis == null) ? 0 : xyAxis.hashCode());
result = prime * result + ((zAxis == null) ? 0 : zAxis.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CoverageDimensions other = (CoverageDimensions) obj;
if (tAxis == null) {
if (other.tAxis != null)
return false;
} else if (!tAxis.equals(other.tAxis))
return false;
if (xyAxis == null) {
if (other.xyAxis != null)
return false;
} else if (!xyAxis.equals(other.xyAxis))
return false;
if (zAxis == null) {
if (other.zAxis != null)
return false;
} else if (!zAxis.equals(other.zAxis))
return false;
return true;
}
}

View file

@ -1,128 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.reg;
import java.util.List;
/**
* 4D coverage for a specific field value
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 2, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoverageField {
private String name;
private String standardName;
private final List<TemporalCube> timeCube;
private final CoverageDimensions dimensions;
private String units;
private Number paddingValue;
/**
* @param timeCube
*/
public CoverageField(List<TemporalCube> timeCube, CoverageDimensions dims) {
this.timeCube = timeCube;
this.dimensions = dims;
}
/**
* @return the timeCube
*/
public List<TemporalCube> getTimeCube() {
return timeCube;
}
/**
* @return the units
*/
public String getUnits() {
return units;
}
/**
* @param units
* the units to set
*/
public void setUnits(String units) {
this.units = units;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the standardName
*/
public String getStandardName() {
return standardName;
}
/**
* @param standardName
* the standardName to set
*/
public void setStandardName(String standardName) {
this.standardName = standardName;
}
/**
* May be null
*
* @return the paddingValue
*/
public Number getPaddingValue() {
return paddingValue;
}
/**
* @param paddingValue
* the paddingValue to set
*/
public void setPaddingValue(Number paddingValue) {
this.paddingValue = paddingValue;
}
/**
* @return the dimensions
*/
public CoverageDimensions getDimensions() {
return dimensions;
}
}

View file

@ -1,81 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.reg;
import java.util.Arrays;
import java.util.Date;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoverageTAxis {
private final Date[] times;
/**
* @param times
*/
public CoverageTAxis(Date[] times) {
this.times = times;
}
/**
* @return the times
*/
public Date[] getTimes() {
return times;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(times);
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CoverageTAxis other = (CoverageTAxis) obj;
if (!Arrays.equals(times, other.times))
return false;
return true;
}
}

View file

@ -1,286 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.reg;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.measure.unit.SI;
import org.apache.commons.lang.StringUtils;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.DataTime.FLAG;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox;
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer;
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
import com.raytheon.uf.edex.ogc.common.spatial.AltUtil;
import com.raytheon.uf.edex.ogc.common.spatial.Composite3DBoundingBox;
import com.raytheon.uf.edex.ogc.common.spatial.CrsLookup;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalCoordinate.Reference;
import com.raytheon.uf.edex.plugin.dataset.urn.URNLookup;
import com.raytheon.uf.edex.wcs.WcsConfig;
import com.raytheon.uf.edex.wcs.WcsException;
import com.raytheon.uf.edex.wcs.WcsException.Code;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LinearRing;
/**
*
* @author bclement
* @version 1.0
*/
public abstract class CoverageTransform<D extends SimpleDimension, L extends SimpleLayer<D>> {
protected IUFStatusHandler log = UFStatus.getHandler(this.getClass());
protected String key;
public CoverageTransform(String key) {
this.key = key;
}
public List<CoverageDescription> transform(List<L> layers,
boolean summaryOnly)
throws WcsException {
if (layers == null) {
return null;
}
List<CoverageDescription> rval = new ArrayList<CoverageDescription>(
layers.size());
for (L layer : layers) {
rval.add(transform(layer, summaryOnly));
}
return rval;
}
public CoverageDescription transform(L layer,
boolean summaryOnly) throws WcsException {
CoverageDescription rval = new CoverageDescription();
rval.setIdentifier(URNLookup.localToUrn(layer.getName()));
OgcGeoBoundingBox bbox = LayerTransformer.getGeoBoundingBox(layer);
List<Composite3DBoundingBox> bboxes = getBboxes(layer);
if (!bboxes.isEmpty() && WcsConfig.isProperty(WcsConfig.FORCE_KM_BBOX)) {
List<Composite3DBoundingBox> newList = new ArrayList<Composite3DBoundingBox>(
bboxes.size());
for (Composite3DBoundingBox box : bboxes) {
if (box.hasVertical()) {
VerticalCoordinate vert = box.getVertical();
vert = AltUtil.convert(SI.KILOMETER, Reference.UNKNOWN,
vert);
newList.add(new Composite3DBoundingBox(box.getHorizontal(),
box.getNative2DCrsUrn(), vert));
} else {
newList.add(box);
}
}
bboxes = newList;
}
if (bbox != null) {
rval.setCrs84Bbox(bbox);
rval.setCrs(getSupportedCrsList(layer.getTargetCrsCode(), bboxes));
} else {
log.warn("Unable to get geographic information for layer: "
+ layer.getName());
}
if (!summaryOnly) {
describe(rval, layer, bboxes);
}
return rval;
}
/**
* @param rval
* @param layer
* @throws WcsException
*/
protected void describe(CoverageDescription rval, L layer,
List<Composite3DBoundingBox> bboxes) throws WcsException {
rval.setGridOffsets(Arrays.asList((double) layer.getNx(),
(double) layer.getNy()));
double minx = layer.getTargetMinx();
double miny = layer.getTargetMiny();
double maxx = layer.getTargetMaxx();
double maxy = layer.getTargetMaxy();
GeometryFactory geomFact = new GeometryFactory();
Coordinate[] coords = new Coordinate[5];
coords[0] = new Coordinate(minx, miny);
coords[1] = new Coordinate(minx, maxy);
coords[2] = new Coordinate(maxx, maxy);
coords[3] = new Coordinate(maxx, miny);
coords[4] = new Coordinate(minx, miny);
LinearRing ring = geomFact.createLinearRing(coords);
rval.setTimes(getTimes(layer.getTimes(), layer.isTimesAsRanges()));
rval.setRangeFields(getRangeFields(layer));
rval.setPolygon(geomFact.createPolygon(ring, new LinearRing[0]));
rval.setGridType("urn:ogc:def:method:WCS:1.1:grid2dIn2dMethod");
rval.setGridOrigin(Arrays.asList(minx, maxy));
int nx = layer.getNx();
int ny = layer.getNy();
rval.setGridOffsets(Arrays.asList(getDn(nx, minx, maxx), 0.0, 0.0,
-getDn(ny, miny, maxy)));
rval.setGridCs("urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS");
rval.setBboxes(bboxes);
String targetCrs = translateCrs(layer.getTargetCrsCode());
rval.setGridBaseCrs(targetCrs);
//add all the crs' from the bounding boxes
List<String> crs = new ArrayList<String>(Arrays.asList(targetCrs));
for(Composite3DBoundingBox bBox : bboxes) {
String bBoxCrs = CrsLookup.createCrsURN(bBox);
if(bBoxCrs != null && !crs.contains(bBoxCrs)) {
crs.add(bBoxCrs);
}
}
rval.setCrs(crs);
}
/**
* Create a list composed of target crs and bounding box CRS URNs
*
* @param targetCrs
* @param bboxes
* @return
*/
private List<String> getSupportedCrsList(String targetCrs,
List<Composite3DBoundingBox> bboxes) {
List<String> rval = new ArrayList<String>(Arrays.asList(targetCrs));
for (Composite3DBoundingBox bBox : bboxes) {
String bBoxCrs = CrsLookup.createCrsURN(bBox);
if (bBoxCrs != null && !rval.contains(bBoxCrs)) {
rval.add(bBoxCrs);
}
}
return rval;
}
protected List<Composite3DBoundingBox> getBboxes(L layer)
throws WcsException {
Composite3DBoundingBox bbox = new Composite3DBoundingBox(
getHorizontal(layer), getVertical(layer));
return Arrays.asList(bbox);
}
/**
* @param layer
* @return null if layer doesn't have vertical information
* @throws WcsException
*/
protected abstract VerticalCoordinate getVertical(L layer)
throws WcsException;
/**
* @param layer
* @return
* @throws WcsException
*/
protected ReferencedEnvelope getHorizontal(L layer)
throws WcsException {
CoordinateReferenceSystem crs2d;
try {
crs2d = CrsLookup.lookup(layer.getTargetCrsCode());
} catch (Exception e) {
log.error("Unable to parse target crs", e);
throw new WcsException(Code.InternalServerError);
}
return new ReferencedEnvelope(layer.getTargetMinx(),
layer.getTargetMaxx(), layer.getTargetMiny(),
layer.getTargetMaxy(), crs2d);
}
protected double getDn(int nn, double n1, double n2) {
return Math.abs(n1 - n2) / (double) nn;
}
public static String translateCrs(String crs) {
if ( crs == null){
return null;
}
if (crs.equalsIgnoreCase("crs:84")) {
return "urn:ogc:def:crs:OGC:2:84";
}
String[] split = crs.split(":");
List<String> parts = new ArrayList<String>(split.length + 1);
parts.add("urn:ogc:def:crs");
if (split.length == 2) {
parts.add(split[0]);
parts.add("");
parts.add(split[1]);
} else {
parts.addAll(Arrays.asList(split));
}
return StringUtils.join(parts, ":");
}
/**
* @param layer
* @return
*/
protected abstract List<RangeField> getRangeFields(L layer);
protected List<DataTime> getTimes(Set<Date> times, boolean asRanges) {
if (times == null || times.isEmpty()) {
return new ArrayList<DataTime>(0);
}
List<DataTime> rval;
if (asRanges) {
rval = new ArrayList<DataTime>((int) Math.ceil(times.size() / 2.0));
Iterator<Date> iter = times.iterator();
while (iter.hasNext()) {
Date start = iter.next();
Date end = (iter.hasNext() ? iter.next() : start);
DataTime time = new DataTime(Calendar.getInstance(),
new TimeRange(start, end));
time.setUtilityFlags(EnumSet.of(FLAG.PERIOD_USED));
rval.add(time);
}
} else {
rval = new ArrayList<DataTime>(times.size());
for (Date d : times) {
rval.add(new DataTime(d));
}
}
return rval;
}
}

View file

@ -1,103 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.reg;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
/**
* Metadata for coverage X and Y axis
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoverageXYAxis {
private final GridGeometry2D gridGeometry;
private final ReferencedEnvelope envelope;
/**
* @param gridGeometry
* @param crs
*/
public CoverageXYAxis(GridGeometry2D gridGeometry,ReferencedEnvelope envelope) {
this.gridGeometry = gridGeometry;
this.envelope = envelope;
}
/**
* @return the gridGeometry
*/
public GridGeometry2D getGridGeometry() {
return gridGeometry;
}
/**
* @return the envelope
*/
public ReferencedEnvelope getEnvelope() {
return envelope;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((envelope == null) ? 0 : envelope.hashCode());
result = prime * result
+ ((gridGeometry == null) ? 0 : gridGeometry.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CoverageXYAxis other = (CoverageXYAxis) obj;
if (envelope == null) {
if (other.envelope != null)
return false;
} else if (!envelope.equals(other.envelope))
return false;
if (gridGeometry == null) {
if (other.gridGeometry != null)
return false;
} else if (!gridGeometry.equals(other.gridGeometry))
return false;
return true;
}
}

View file

@ -1,129 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.reg;
import java.util.Arrays;
/**
* Metadata for coverage Z axis
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class CoverageZAxis {
private final double[] value;
private final String units;
private final String reference;
private final boolean upIsPositive;
/**
* @param value
* @param units
* @param upIsPositive
*/
public CoverageZAxis(double[] value, String units, String reference,
boolean upIsPositive) {
this.value = value;
this.units = units;
this.reference = reference;
this.upIsPositive = upIsPositive;
}
/**
* @return the value
*/
public double[] getValue() {
return value;
}
/**
* @return the units
*/
public String getUnits() {
return units;
}
/**
* @return the upIsPositive
*/
public boolean isUpIsPositive() {
return upIsPositive;
}
/**
* @return the reference
*/
public String getReference() {
return reference;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((reference == null) ? 0 : reference.hashCode());
result = prime * result + ((units == null) ? 0 : units.hashCode());
result = prime * result + (upIsPositive ? 1231 : 1237);
result = prime * result + Arrays.hashCode(value);
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CoverageZAxis other = (CoverageZAxis) obj;
if (reference == null) {
if (other.reference != null)
return false;
} else if (!reference.equals(other.reference))
return false;
if (units == null) {
if (other.units != null)
return false;
} else if (!units.equals(other.units))
return false;
if (upIsPositive != other.upIsPositive)
return false;
if (!Arrays.equals(value, other.value))
return false;
return true;
}
}

View file

@ -1,90 +0,0 @@
/**
* Copyright 09/24/12 Raytheon Company.
*
* Unlimited Rights
* This software was developed pursuant to Contract Number
* DTFAWA-10-D-00028 with the US Government. The US Governments rights
* in and to this copyrighted software are as specified in DFARS
* 252.227-7014 which was made part of the above contract.
*/
package com.raytheon.uf.edex.wcs.reg;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.springframework.context.ApplicationContext;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.ogc.common.spatial.VerticalSpatialFactory;
/**
* Factory for getting coverage field for plugin data object
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 5, 2013 bclement Initial creation
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class FieldAdapterFactory {
private static Map<Class<?>, IFieldAdapted<?>> REGISTRY = null;
private static final IUFStatusHandler log = UFStatus
.getHandler(FieldAdapterFactory.class);
private static final class Init implements Runnable {
@Override
public void run() {
while (!EDEXUtil.isRunning()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
}
try {
ApplicationContext ctx = EDEXUtil.getSpringContext();
String[] beans = ctx.getBeanNamesForType(IFieldAdapted.class);
HashMap<Class<?>, IFieldAdapted<?>> map = new HashMap<Class<?>, IFieldAdapted<?>>(
beans.length);
for (String bean : beans) {
IFieldAdapted<?> fa = (IFieldAdapted<?>) ctx.getBean(bean);
map.put(fa.getSupportedClass(), fa);
}
REGISTRY = Collections.unmodifiableMap(map);
} catch (Throwable e) {
log.error("Unable to init " + VerticalSpatialFactory.class, e);
}
}
}
static {
new Thread(new Init()).start();
}
/**
* @param c
* @return null if factory isn't initialized or no adapter found for c
*/
@SuppressWarnings("unchecked")
public static <T> IFieldAdapted<T> getAdapted(Class<T> c) {
if (REGISTRY == null) {
return null;
}
return (IFieldAdapted<T>) REGISTRY.get(c);
}
public static boolean isInitialized() {
return REGISTRY != null;
}
}

View file

@ -1,53 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
*
**/
package com.raytheon.uf.edex.wcs.reg;
import com.raytheon.uf.common.spatial.reprojection.ReferencedDataRecord;
import com.raytheon.uf.edex.wcs.WcsException;
/**
* Data Record Fetcher for WCS
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 3, 2013 bclement Initial creation
* Aug 18, 2013 #2097 dhladky interface standards
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public interface IDataRecordFetcher {
/**
* @param cache
* true if the record will likely be retrieved again
* @return
* @throws Exception
*/
public ReferencedDataRecord get(boolean cache) throws WcsException;
}

View file

@ -1,53 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
*
**/
package com.raytheon.uf.edex.wcs.reg;
/**
* Adapter for coverage field information
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 5, 2013 bclement Initial creation
* Aug 18, 2013 #2097 dhladky interface standards
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public interface IFieldAdapted<T> {
/**
* @param obj
* @return
*/
public String getCoverageField(T obj);
/**
* @return class supported by adapter
*/
public Class<T> getSupportedClass();
}

View file

@ -1,68 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 5, 2011 bclement Initial creation
* Aug 18, 2013 #2097 dhladky interface standards
*
*/
package com.raytheon.uf.edex.wcs.reg;
import java.util.List;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
import com.raytheon.uf.edex.ogc.common.spatial.Composite3DBoundingBox;
import com.raytheon.uf.edex.wcs.WcsException;
public interface IWcsSource<D extends SimpleDimension, L extends SimpleLayer<D>> {
/**
* long name attribute for coverages
*/
public static final String LONG_NAME_ATTR = "long_name";
public List<CoverageDescription> listCoverages(boolean summary);
public CoverageDescription describeCoverage(String identifier)
throws WcsException;
public CoverageTransform<D, L> getCoverageTransform();
public Coverage getCoverage(String identifier, DataTime time,
Composite3DBoundingBox bbox, List<RangeField> rangeFields)
throws WcsException;
public String getKey();
public boolean hasCoverage(String id) throws WcsException;
/**
* @param c
* extension class
* @return extension object for class, null if none registered
*/
public <T> T getExtension(Class<T> c);
}

View file

@ -1,151 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.reg;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
/**
*
* @author bclement
* @version 1.0
*/
public class RangeAxis {
protected String identifier;
protected Set<String> keys;
protected static Pattern axisPattern = Pattern
.compile("^([^\\[]+)\\[([^\\]]+)]$");
/**
* @param description
* @param identifier
* @param keys
*/
public RangeAxis(String identifier, Set<String> keys) {
super();
this.identifier = identifier;
this.keys = keys;
}
/**
* @param axisSubset
* string that conforms to the following grammar<br/>
* AxisSubsets = AxisSubset *( , AxisSubset ) <br/>
* AxisSubset = AxisId [ Keys ] <br/>
* Keys = Key *( , Key )
* @return null if axisSubset is null
* @throws RangeParseException
* if axisSubsets doesn't follow the above grammar
*/
public static List<RangeAxis> getAxisList(String axisSubsets)
throws RangeParseException {
if (axisSubsets == null || axisSubsets.isEmpty()) {
throw new RangeParseException(
"axis subsets cannot be null or empty");
}
List<String> parts = axisSplit(axisSubsets);
List<RangeAxis> rval = new ArrayList<RangeAxis>(parts.size());
for (String s : parts) {
rval.add(getAxis(s));
}
return rval;
}
/**
* @param axisSubset
* string that conforms to the following grammar<br/>
* AxisSubset = AxisId [ Keys ] <br/>
* Keys = Key *( , Key )
* @return
* @throws RangeParseException
* if axisSubset doesn't follow the above grammar
*/
public static RangeAxis getAxis(String axisSubset)
throws RangeParseException {
if (axisSubset == null) {
throw new RangeParseException("axis subset cannot be null");
}
Matcher m = axisPattern.matcher(axisSubset);
if (m.matches()) {
Set<String> keys = new HashSet<String>();
keys.addAll(Arrays.asList(m.group(2).split(",")));
return new RangeAxis(m.group(1), keys);
}
throw new RangeParseException("Invalid axis subset: " + axisSubset);
}
/**
* @param axisStr
* @return
*/
protected static List<String> axisSplit(String axisStr) {
int start = 0;
int end = 0;
int mark = -1;
List<String> rval = new ArrayList<String>();
do {
mark = axisStr.indexOf(',', end);
if (mark > 0 && axisStr.charAt(mark - 1) == ']') {
rval.add(axisStr.substring(start, mark));
start = mark + 1;
}
end = mark + 1;
} while (mark > 0);
rval.add(axisStr.substring(start));
return rval;
}
@Override
public String toString() {
String rval = String.valueOf(identifier);
if (keys != null && !keys.isEmpty()) {
String keyStr = StringUtils.join(keys, ',');
rval = rval + '[' + keyStr + ']';
}
return rval;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public Set<String> getKeys() {
return keys;
}
public void setKeys(Set<String> keys) {
this.keys = keys;
}
}

View file

@ -1,212 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.reg;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
/**
*
* @author bclement
* @version 1.0
*/
public class RangeField {
protected static Pattern fieldPattern = Pattern
.compile("^([^\\[:]+)(:([^\\[]+))?(\\[(.*)\\])?$");
public enum InterpolationType {
nearest, linear, cubic, quadratic, none
};
protected String identifier;
protected RangeFieldDefinition definition;
protected InterpolationType defaultInterpolation = InterpolationType.none;
protected List<InterpolationType> additionalInterpolations;
protected List<RangeAxis> axis;
protected String nullValue;
/**
* @param identifier
* @param description
* @param definition
*/
public RangeField(String identifier, RangeFieldDefinition definition) {
super();
this.identifier = identifier;
this.definition = definition;
}
/**
* @param rangeSubset
* string that conforms to the following grammar<br/>
* RangeSubset = FieldSubset *( ; FieldSubset ) <br/>
* FieldSubset = FieldId [ : Interpolation ] [ [ AxisSubsets
* ] ]<br/>
* AxisSubsets = AxisSubset *( , AxisSubset ) <br/>
* AxisSubset = AxisId [ Keys ] <br/>
* Keys = Key *( , Key )
* @return
* @throws RangeParseException
* if argument doesn't match above grammar or interpolation type
* isn't recognized
*/
public static List<RangeField> getRanges(String rangeSubset)
throws RangeParseException {
if (rangeSubset == null || rangeSubset.isEmpty()) {
throw new RangeParseException(
"range subset cannot be null or empty");
}
String[] parts = rangeSubset.split(";");
ArrayList<RangeField> rval = new ArrayList<RangeField>(parts.length);
for (String s : parts) {
rval.add(getField(s));
}
return rval;
}
/**
* @param fieldSubset
* string that conforms to the following grammar<br/>
* FieldSubset = FieldId [ : Interpolation ] [ [ AxisSubsets
* ] ]<br/>
* AxisSubsets = AxisSubset *( , AxisSubset ) <br/>
* AxisSubset = AxisId [ Keys ] <br/>
* Keys = Key *( , Key )
* @return
* @throws RangeParseException
* if argument doesn't match above grammar or interpolation type
* isn't recognized
*/
public static RangeField getField(String fieldSubset)
throws RangeParseException {
if (fieldSubset == null) {
throw new RangeParseException("field subset cannot be null");
}
Matcher m = fieldPattern.matcher(fieldSubset);
if (m.matches()) {
String id = m.group(1);
String interp = m.group(3);
RangeField rval = new RangeField(id, null);
rval.setDefaultInterpolation(getInterp(interp));
if (m.group(5) != null) {
rval.setAxis(RangeAxis.getAxisList(m.group(5)));
}
return rval;
}
throw new RangeParseException("Invalid field subset: " + fieldSubset);
}
/**
* @param interp
* @return
* @throws RangeParseException
*/
protected static InterpolationType getInterp(String interp)
throws RangeParseException {
InterpolationType rval = InterpolationType.none;
try {
if (interp != null) {
rval = InterpolationType.valueOf(interp);
}
} catch (Throwable t) {
throw new RangeParseException("Invalid interpolation type: "
+ interp, t);
}
return rval;
}
@Override
public String toString() {
String rval = String.valueOf(identifier);
if (defaultInterpolation != null
&& !defaultInterpolation.equals(InterpolationType.none)) {
rval = rval + ':' + defaultInterpolation;
}
if (axis != null && !axis.isEmpty()) {
List<String> strList = new ArrayList<String>(axis.size());
for (RangeAxis ra : axis) {
strList.add(ra.toString());
}
String axisStr = StringUtils.join(strList, ',');
rval = rval + '[' + axisStr + ']';
}
return rval;
}
public String getNullValue() {
return nullValue;
}
public void setNullValue(String nullValue) {
this.nullValue = nullValue;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public RangeFieldDefinition getDefinition() {
return definition;
}
public void setDefinition(RangeFieldDefinition definition) {
this.definition = definition;
}
public InterpolationType getDefaultInterpolation() {
return defaultInterpolation;
}
public void setDefaultInterpolation(InterpolationType defaultInterpolation) {
this.defaultInterpolation = defaultInterpolation;
}
public List<InterpolationType> getAdditionalInterpolations() {
return additionalInterpolations;
}
public void setAdditionalInterpolations(
List<InterpolationType> additionalInterpolations) {
this.additionalInterpolations = additionalInterpolations;
}
public List<RangeAxis> getAxis() {
return axis;
}
public void setAxis(List<RangeAxis> axis) {
this.axis = axis;
}
}

View file

@ -1,94 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wcs.reg;
/**
*
* @author bclement
* @version 1.0
*/
public class RangeFieldDefinition {
public enum Closure {
open, closed, closedOpen, openClosed
};
protected double maxValue;
protected double minValue;
protected Closure closure;
protected String units;
/**
* @param maxValue
* @param minValue
*/
public RangeFieldDefinition(double maxValue, double minValue) {
this(maxValue, minValue, Closure.closed);
}
/**
* @param maxValue
* @param minValue
* @param closure
*/
public RangeFieldDefinition(double maxValue, double minValue,
Closure closure) {
super();
this.maxValue = maxValue;
this.minValue = minValue;
this.closure = closure;
}
public String getUnits() {
return units;
}
public void setUnits(String units) {
this.units = units;
}
public double getMaxValue() {
return maxValue;
}
public void setMaxValue(double maxValue) {
this.maxValue = maxValue;
}
public double getMinValue() {
return minValue;
}
public void setMinValue(double minValue) {
this.minValue = minValue;
}
public Closure getClosure() {
return closure;
}
public void setClosure(Closure closure) {
this.closure = closure;
}
}

Some files were not shown because too many files have changed in this diff Show more