Issue #1323 initial commit of interfaces of data access framework
Change-Id: I301d94a85a4e86550cd409bc17ef94ea3fdd6e02 Former-commit-id:d7f7152e93
[formerlyb24c9eb456
] [formerlyf255f65b3c
] [formerlybf72e29752
[formerlyf255f65b3c
[formerly d6b63788ef2af3da474a0d3affcafdddec3690a5]]] Former-commit-id:bf72e29752
Former-commit-id: 321cb3de1f60b624ae9aad5c85b473334d3d249e [formerly78a1185b19
] Former-commit-id:cfed9d9664
This commit is contained in:
parent
4a8b71a632
commit
6d3beb139e
30 changed files with 2367 additions and 0 deletions
7
edexOsgi/com.raytheon.uf.common.dataaccess/.classpath
Normal file
7
edexOsgi/com.raytheon.uf.common.dataaccess/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?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>
|
28
edexOsgi/com.raytheon.uf.common.dataaccess/.project
Normal file
28
edexOsgi/com.raytheon.uf.common.dataaccess/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.common.dataaccess</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>
|
|
@ -0,0 +1,8 @@
|
|||
#Tue Sep 18 14:46:02 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
|
|
@ -0,0 +1,17 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Dataaccess
|
||||
Bundle-SymbolicName: com.raytheon.uf.common.dataaccess
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.raytheon.uf.common.time;visibility:=reexport,
|
||||
com.raytheon.uf.common.datastorage,
|
||||
com.raytheon.uf.common.geospatial;visibility:=reexport,
|
||||
javax.measure;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin.level;visibility:=reexport
|
||||
Export-Package: com.raytheon.uf.common.dataaccess,
|
||||
com.raytheon.uf.common.dataaccess.exception,
|
||||
com.raytheon.uf.common.dataaccess.geom,
|
||||
com.raytheon.uf.common.dataaccess.grid,
|
||||
com.raytheon.uf.common.dataaccess.impl
|
|
@ -0,0 +1,4 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
|
@ -0,0 +1,8 @@
|
|||
<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">
|
||||
|
||||
<bean id="dataAccessRegistry" class="com.raytheon.uf.common.dataaccess.DataFactoryRegistry"
|
||||
factory-method="getInstance" />
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,165 @@
|
|||
/**
|
||||
* 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.common.dataaccess;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
||||
/**
|
||||
* The Data Access Layer is the published API for getting data through the Data
|
||||
* Access Framework. Code from other components should go through these methods
|
||||
* to retrieve the data. All methods may potentially throw
|
||||
* UnsupportedOperationException or IllegalArgumentException dependent on how
|
||||
* much support has been provided per datatype.
|
||||
*
|
||||
* The implementation of this class is a retrieval of the corresponding factory
|
||||
* and then delegating the processing to that factory. All the generics that
|
||||
* exist in this implementation are to save the caller from the hassle of
|
||||
* casting what is returned.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 24, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataAccessLayer {
|
||||
|
||||
/**
|
||||
* Gets the times of available data to the request
|
||||
*
|
||||
* @param request
|
||||
* the request to find available times for
|
||||
* @return the available times that match the request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes(
|
||||
R request) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
return factory.getAvailableTimes(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the times of available data to the request with a BinOffset applied
|
||||
*
|
||||
* @param request
|
||||
* the request to find available times for
|
||||
* @param binOffset
|
||||
* the BinOffset to apply
|
||||
* @return the available times with the bin offset applied that match the
|
||||
* request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes(
|
||||
R request, BinOffset binOffset) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
return factory.getAvailableTimes(request, binOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data that matches the request at the specified times. If data is
|
||||
* time agnostic then simply don't pass in any DataTimes, for example
|
||||
* DataAccessLayer.getData(R)
|
||||
*
|
||||
* @param request
|
||||
* the request to get data for
|
||||
* @param times
|
||||
* the times to get data for
|
||||
* @return the data that matches the request and times
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> D[] getData(
|
||||
R request, DataTime... times) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
return factory.getData(request, times);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data that matches the request within the time range
|
||||
*
|
||||
* @param request
|
||||
* the request to get data for
|
||||
* @param timeRange
|
||||
* the time range to get data for
|
||||
* @return the data that matches the request and time range
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> D[] getData(
|
||||
R request, TimeRange timeRange) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
return factory.getData(request, timeRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the grid geometry of the data matching the request without actually
|
||||
* requesting the data. Useful for then making slab/subgrid/line requests by
|
||||
* setting the storage request parameter on an IGridRequest.
|
||||
*
|
||||
* @param request
|
||||
* the request to get the grid geometry of the data for
|
||||
* @return the geometry of the data if the data was requested
|
||||
*/
|
||||
public static GridGeometry2D getGridGeometry(IGridRequest request) {
|
||||
IGridDataFactory factory = (IGridDataFactory) getFactory(request);
|
||||
return factory.getGeometry(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the available location names that match the request without actually
|
||||
* requesting the data.
|
||||
*
|
||||
* @param request
|
||||
* @return the available location names if the data was requested
|
||||
*/
|
||||
public static String[] getAvailableLocationNames(IGeometryRequest request) {
|
||||
IGeometryDataFactory factory = (IGeometryDataFactory) getFactory(request);
|
||||
return factory.getAvailableLocationNames(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: contemplate making this public to allow for special case handling
|
||||
* Returns the factory that should process the request. Will never return
|
||||
* null, will instead throw exceptions.
|
||||
*
|
||||
* @param request
|
||||
* @return the factory that matches the request
|
||||
* @throws DataFactoryNotFoundException
|
||||
*/
|
||||
private static <R extends IDataRequest<D>, D extends IData> IDataFactory<R, D> getFactory(
|
||||
R request) {
|
||||
return DataFactoryRegistry.getInstance().getFactory(request);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/**
|
||||
* 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.common.dataaccess;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
|
||||
|
||||
/**
|
||||
* Registry containing the support for different datatypes in the Data Access
|
||||
* Framework. The registry maps a datatype name/key to a request type
|
||||
* (IGridRequest vs IGeometryRequest) and the corresponding factory to support
|
||||
* that request type.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataFactoryRegistry {
|
||||
|
||||
private Map<String, Map<Class<IDataRequest<?>>, IDataFactory<?, ?>>> datatypeMap;
|
||||
|
||||
private static DataFactoryRegistry instance;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private DataFactoryRegistry() {
|
||||
datatypeMap = new HashMap<String, Map<Class<IDataRequest<?>>, IDataFactory<?, ?>>>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance of the DataFactoryRegistry
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static DataFactoryRegistry getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DataFactoryRegistry();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a datatype name with a request type and the supporting factory.
|
||||
* Should only be called from spring.
|
||||
*
|
||||
* @param datatype
|
||||
* the datatype name that will become the key for requests'
|
||||
* datatypes
|
||||
* @param requestType
|
||||
* IGridRequest vs IGeometryRequest
|
||||
* @param factory
|
||||
* the factory that will support requests of this datatype and
|
||||
* type
|
||||
*/
|
||||
public void register(String datatype, Class<IDataRequest<?>> requestType,
|
||||
IDataFactory<?, ?> factory) {
|
||||
Map<Class<IDataRequest<?>>, IDataFactory<?, ?>> requestTypeMap = datatypeMap
|
||||
.get(datatype);
|
||||
if (requestTypeMap == null) {
|
||||
requestTypeMap = new HashMap<Class<IDataRequest<?>>, IDataFactory<?, ?>>();
|
||||
datatypeMap.put(datatype, requestTypeMap);
|
||||
}
|
||||
requestTypeMap.put(requestType, factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory that should process the request. Will never return
|
||||
* null and will instead throw an exception if no registered factories
|
||||
* match.
|
||||
*
|
||||
* @param request
|
||||
* the request to find a matching factory for
|
||||
* @return the factory that is registered to process the request
|
||||
* @throws DataFactoryNotFoundException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R extends IDataRequest<D>, D extends IData> IDataFactory<R, D> getFactory(
|
||||
R request) {
|
||||
String datatype = request.getDatatype();
|
||||
if (datatype != null) {
|
||||
Map<Class<IDataRequest<?>>, IDataFactory<?, ?>> requestTypeMap = datatypeMap
|
||||
.get(datatype);
|
||||
if (requestTypeMap != null) {
|
||||
IDataFactory<?, ?> factory = null;
|
||||
for (Entry<Class<IDataRequest<?>>, IDataFactory<?, ?>> entry : requestTypeMap
|
||||
.entrySet()) {
|
||||
if (entry.getKey().isInstance(request)) {
|
||||
factory = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (factory != null) {
|
||||
return (IDataFactory<R, D>) factory;
|
||||
} else {
|
||||
throw new DataFactoryNotFoundException(
|
||||
"No data access support for requests of datatype "
|
||||
+ datatype + " and type "
|
||||
+ request.getClass());
|
||||
}
|
||||
} else {
|
||||
throw new DataFactoryNotFoundException(
|
||||
"No data access support registered to datatype key: "
|
||||
+ datatype);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Request must have a datatype set");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.common.dataaccess;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
/**
|
||||
* An IData represents the bare minimum of any piece of data, namely that it can
|
||||
* have attributes, a time, and a level.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IData {
|
||||
|
||||
/**
|
||||
* Gets an attribute of the data based on the key.
|
||||
*
|
||||
* @param key
|
||||
* @return the attribute
|
||||
*/
|
||||
public Object getAttribute(String key);
|
||||
|
||||
/**
|
||||
* Gets the DataTime of the data. May be null if the data is time agnostic.
|
||||
*
|
||||
* @return the time of the data, possibly null for some data types
|
||||
*/
|
||||
public DataTime getDataTime();
|
||||
|
||||
/**
|
||||
* Gets the level of the data. May be null depending on the datatype.
|
||||
*
|
||||
* @return the level of the data, possibly null for some data types
|
||||
*/
|
||||
public Level getLevel();
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* 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.common.dataaccess;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
||||
/**
|
||||
* Factory interface for producing data objects that implement IData, hiding the
|
||||
* details of the underlying data implementation object and how it was
|
||||
* retrieved.
|
||||
*
|
||||
* Implementations of IDataFactory should strive to handle all their processing
|
||||
* based on the request interface that was received. If at all possible, they
|
||||
* should not cast the request to a specific request implementation, ensuring
|
||||
* that they will work with multiple request implementations.
|
||||
*
|
||||
* The return types of the getData() methods should be geared towards returning
|
||||
* what a caller of the API would expect. For example, a request for county
|
||||
* polygons may not explicitly request that it wants the US state name as an
|
||||
* attribute on the returned object. However, a caller could reasonably expect
|
||||
* when requesting counties that the returned object includes state name. This
|
||||
* must be balanced carefully since a caller of the API does not see the factory
|
||||
* implementation but has expectations about what will be returned.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
* @param <D>
|
||||
*/
|
||||
|
||||
public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
|
||||
|
||||
/**
|
||||
* Gets the available times that match the request. Implementations should
|
||||
* throw TimeAgnosticDataException if the datatype is time agnostic.
|
||||
*
|
||||
* @param request
|
||||
* the request to find matching times for
|
||||
* @return the times that have data available for this request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public DataTime[] getAvailableTimes(R request)
|
||||
throws TimeAgnosticDataException;
|
||||
|
||||
/**
|
||||
* Gets the available times that match the request within the BinOffset.
|
||||
* Implementations should throw TimeAgnosticDataException if the datatype is
|
||||
* time agnostic.
|
||||
*
|
||||
* @param request
|
||||
* the request to find matching times for
|
||||
* @param binOffset
|
||||
* the bin offset to limit the returned times
|
||||
* @return the times with the bin offset applied that have data available
|
||||
* for this request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public DataTime[] getAvailableTimes(R request, BinOffset binOffset)
|
||||
throws TimeAgnosticDataException;
|
||||
|
||||
/**
|
||||
* Gets the available data that matches the request at the specified times.
|
||||
* If data is time agnostic, use getData(R).
|
||||
*
|
||||
* @param request
|
||||
* the request to get matching data for
|
||||
* @param times
|
||||
* the times to get data for. If data is time agnostic, use
|
||||
* getData(R)
|
||||
* @return the data that matches the request at the specified times
|
||||
*/
|
||||
public D[] getData(R request, DataTime... times);
|
||||
|
||||
/**
|
||||
* Gets the available data that matches the request and is within the time
|
||||
* range. If data is time agnostic, use getData(R).
|
||||
*
|
||||
* @param request
|
||||
* the request to get matching data for
|
||||
* @param timeRange
|
||||
* the time range to return data for. If data is time agnostic,
|
||||
* use getData(R).
|
||||
* @return the data that matches the request within the time range
|
||||
*/
|
||||
public D[] getData(R request, TimeRange timeRange);
|
||||
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
* 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.common.dataaccess;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
|
||||
/**
|
||||
* A generic request for geospatial data to the Data Access Framework. All
|
||||
* requests must have a datatype set.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IDataRequest<D extends IData> {
|
||||
|
||||
/**
|
||||
* The datatype of the data, usually the pluginName. This value will be used
|
||||
* as a key to determine the corresponding IDataFactory that should process
|
||||
* the request. This is required to be non-null.
|
||||
*
|
||||
* @param datatype
|
||||
* the datatype of the data to request
|
||||
*/
|
||||
public void setDatatype(String datatype);
|
||||
|
||||
/**
|
||||
* Adds an identifier the factory can use to determine exactly what data is
|
||||
* desired. Note that sub-interfaces may add methods for specific
|
||||
* identifying characteristics.
|
||||
*
|
||||
* @param key
|
||||
* the name of the identifier
|
||||
* @param value
|
||||
* the value desired on all the return data
|
||||
*/
|
||||
public void addIdentifier(String key, Object value);
|
||||
|
||||
/**
|
||||
* Sets the parameters to request of the data.
|
||||
*
|
||||
* @param params
|
||||
* the parameters to request
|
||||
*/
|
||||
public void setParameters(String... params);
|
||||
|
||||
/**
|
||||
* Sets the levels to request of the data. Some factories may ignore this or
|
||||
* throw an exception if all data is at one level.
|
||||
*
|
||||
* @param levels
|
||||
* the levels to request
|
||||
*/
|
||||
public void setLevels(Level... levels);
|
||||
|
||||
/**
|
||||
* Returns the datatype set on the request.
|
||||
*
|
||||
* @return the datatype of the request
|
||||
*/
|
||||
public String getDatatype();
|
||||
|
||||
/**
|
||||
* Returns the identifiers added to the request.
|
||||
*
|
||||
* @return the identifiers of the request
|
||||
*/
|
||||
public Map<String, Object> getIdentifiers();
|
||||
|
||||
/**
|
||||
* Returns the parameters set on the request.
|
||||
*
|
||||
* @return the parameters of the request
|
||||
*/
|
||||
public String[] getParameters();
|
||||
|
||||
/**
|
||||
* Returns the levels set on the request.
|
||||
*
|
||||
* @return the levels of the request
|
||||
*/
|
||||
public Level[] getLevels();
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* 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.common.dataaccess.exception;
|
||||
|
||||
/**
|
||||
* An exception that comes out of the Data Access Framework.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class DataAccessException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DataAccessException() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
*/
|
||||
public DataAccessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public DataAccessException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public DataAccessException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* 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.common.dataaccess.exception;
|
||||
|
||||
/**
|
||||
* An exception for when a data factory is not found to fulfill a request.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataFactoryNotFoundException extends DataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public DataFactoryNotFoundException() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
*/
|
||||
public DataFactoryNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public DataFactoryNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public DataFactoryNotFoundException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* 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.common.dataaccess.exception;
|
||||
|
||||
/**
|
||||
* An exception for when the data does not support bounding envelopes.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EnvelopeUnsupportedException extends DataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public EnvelopeUnsupportedException() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
*/
|
||||
public EnvelopeUnsupportedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public EnvelopeUnsupportedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public EnvelopeUnsupportedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* 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.common.dataaccess.exception;
|
||||
|
||||
/**
|
||||
* An exception for when the data does not support location names.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class LocationNameUnsupportedException extends DataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public LocationNameUnsupportedException() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
*/
|
||||
public LocationNameUnsupportedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public LocationNameUnsupportedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public LocationNameUnsupportedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* 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.common.dataaccess.exception;
|
||||
|
||||
/**
|
||||
* An exception for when the data is time agnostic and time requests are not
|
||||
* supported.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class TimeAgnosticDataException extends DataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public TimeAgnosticDataException() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
*/
|
||||
public TimeAgnosticDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param message
|
||||
* the error message
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public TimeAgnosticDataException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param cause
|
||||
* the cause of the error
|
||||
*/
|
||||
public TimeAgnosticDataException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* 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.common.dataaccess.geom;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.measure.converter.ConversionException;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IData;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* An IGeometryData represents data of potentially multiple parameters
|
||||
* associated with a single geometry, typically a point or polygon, at a single
|
||||
* level.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGeometryData extends IData {
|
||||
|
||||
public static enum Type {
|
||||
STRING, INT, LONG, FLOAT, DOUBLE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the geometry associated with this instance of data. The geometry
|
||||
* coordinates are in Lat/Lon space.
|
||||
*
|
||||
* @return the geometry of the data
|
||||
*/
|
||||
public Geometry getGeometry();
|
||||
|
||||
/**
|
||||
* Gets the list of parameters associated with this instance of data
|
||||
*
|
||||
* @return the parameters on this instance of data
|
||||
*/
|
||||
public Set<String> getParameters();
|
||||
|
||||
/**
|
||||
* Gets the string value of a particular parameter.
|
||||
*
|
||||
* @param param
|
||||
* the parameter to get the value of
|
||||
* @return the string value of the parameter
|
||||
*/
|
||||
public String getString(String param);
|
||||
|
||||
/**
|
||||
* Gets the number value of a particular parameter
|
||||
*
|
||||
* @param param
|
||||
* the parameter to get the value of
|
||||
* @return the number value of the parameter
|
||||
*/
|
||||
public Number getNumber(String param);
|
||||
|
||||
/**
|
||||
* Gets the number value of a particular parameter converted to the
|
||||
* specified unit. Will throw ConversionException if the units are
|
||||
* incompatible or the data has no unit.
|
||||
*
|
||||
* @param param
|
||||
* the parameter to get the value of
|
||||
* @param unit
|
||||
* the unit to get the value as
|
||||
* @return the number value of a parameter, converted to the specified unit
|
||||
* @throws ConversionException
|
||||
*/
|
||||
public Number getNumber(String param, Unit<?> unit)
|
||||
throws ConversionException;
|
||||
|
||||
/**
|
||||
* Gets the unit associated with a particular parameter. May be null.
|
||||
*
|
||||
* @param param
|
||||
* the parameter to get the unit of
|
||||
* @return the unit of the parameter
|
||||
*/
|
||||
public Unit<?> getUnit(String param);
|
||||
|
||||
/**
|
||||
* Gets the type of a particular parameter.
|
||||
*
|
||||
* @param param
|
||||
* the parameter to get the type of
|
||||
* @return the type as specified in IGeometryData.type
|
||||
*/
|
||||
public Type getType(String param);
|
||||
|
||||
/**
|
||||
* Gets the location name associated with this instance of IData. May be
|
||||
* null.
|
||||
*
|
||||
* @return the location name or null
|
||||
*/
|
||||
public String getLocationName();
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* 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.common.dataaccess.geom;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.exception.LocationNameUnsupportedException;
|
||||
|
||||
/**
|
||||
* IDataFactory for any data that is non-gridded, for example points or
|
||||
* polygons.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGeometryDataFactory extends
|
||||
IDataFactory<IGeometryRequest, IGeometryData> {
|
||||
|
||||
/**
|
||||
* Gets the available location names that match the request. Implementations
|
||||
* should throw LocationNameUnsupportedException if location names do not
|
||||
* apply to their datatype.
|
||||
*
|
||||
* @param request
|
||||
* the request to find matching location names for
|
||||
* @return the available location names that match the request
|
||||
*/
|
||||
public String[] getAvailableLocationNames(IGeometryRequest request)
|
||||
throws LocationNameUnsupportedException;
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* 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.common.dataaccess.geom;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* A request for any data type that is non-gridded and can be represented by a
|
||||
* geometry.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGeometryRequest extends IDataRequest<IGeometryData> {
|
||||
|
||||
/**
|
||||
* Sets a bounding box on the request to limit the area of the request. The
|
||||
* envelope coordinates should be in Lat/Lon space. Note that not all
|
||||
* factories may support the envelope and instead may throw an
|
||||
* EnvelopeUnsupportedException or ignore the envelope.
|
||||
*
|
||||
* @param env
|
||||
* the envelope to constrain the request
|
||||
*/
|
||||
public void setEnvelope(Envelope env);
|
||||
|
||||
/**
|
||||
* Returns the envelope set on the request.
|
||||
*
|
||||
* @return the envelope set on the request
|
||||
*/
|
||||
public Envelope getEnvelope();
|
||||
|
||||
/**
|
||||
* Sets a list of location names to limit what is returned. Each datatype
|
||||
* may have its own mapping of what a location is (e.g. ICAO vs stationId vs
|
||||
* radar name, etc). Possible location names can be retrieved by using the
|
||||
* method getAvailableLocationNames(IGeometryRequest) on the DataAccessLayer
|
||||
* or IGeometryDataFactory. Note that not all factories may support requests
|
||||
* by location names and instead may throw a
|
||||
* LocationNameUnsupportedException or ignore the location names.
|
||||
*
|
||||
* @param locationNames
|
||||
*/
|
||||
public void setLocationNames(String... locationNames);
|
||||
|
||||
/**
|
||||
* Returns the location names set on the request.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getLocationNames();
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* 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.common.dataaccess.grid;
|
||||
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IData;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataDestination;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.UnitConvertingDataDestination;
|
||||
|
||||
/**
|
||||
* An IGridData represents data that is gridded, ie rectangular (when not
|
||||
* projected) with a set x and y size.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGridData extends IData {
|
||||
|
||||
/**
|
||||
* Gets the parameter of the data
|
||||
*
|
||||
* @return the parameter of the data
|
||||
*/
|
||||
public String getParameter();
|
||||
|
||||
/**
|
||||
* Gets the level of the data
|
||||
*
|
||||
* @return the level of the data
|
||||
*/
|
||||
public Level getLevel();
|
||||
|
||||
/**
|
||||
* Gets the GridGeometry of the data
|
||||
*
|
||||
* @return the grid geometry of the data
|
||||
*/
|
||||
public GridGeometry2D getGridGeometry();
|
||||
|
||||
/**
|
||||
* Gets the unit of the raw data. This may differ from the unit of a data
|
||||
* destination.
|
||||
*
|
||||
* @return the unit of the data
|
||||
*/
|
||||
public Unit<?> getUnit();
|
||||
|
||||
/**
|
||||
* Populates the DataDestination argument with the raw data converted to the
|
||||
* type to match the DataDestination. The destination must not be null. If
|
||||
* unit conversions are desired, use the
|
||||
* {@link UnitConvertingDataDestination} to specify what unit conversion
|
||||
* should be applied to the data.
|
||||
*
|
||||
* @param destination
|
||||
* the destination to fill with data
|
||||
* @return the data destination that was passed in, with the data populated
|
||||
*/
|
||||
public <DD extends DataDestination> DD populateData(DD destination);
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* 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.common.dataaccess.grid;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
|
||||
/**
|
||||
* IDataFactory interface for two dimensional gridded data. Note that IGridData
|
||||
* has the populateData() methods, therefore the implementations of this
|
||||
* interface can choose to either retrieve the raw data when factory.getData()
|
||||
* is called, or have the implementation of IGridData retrieve the raw data when
|
||||
* populateData() is called.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGridDataFactory extends IDataFactory<IGridRequest, IGridData> {
|
||||
|
||||
/**
|
||||
* Gets the GridGeometry2D that matches the request. Useful for determining
|
||||
* the area before requesting the data.
|
||||
*
|
||||
* @param request
|
||||
* the request to get the geometry for
|
||||
* @return the grid geometry of the data that would be returned from this
|
||||
* request
|
||||
*/
|
||||
public GridGeometry2D getGeometry(IGridRequest request);
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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.common.dataaccess.grid;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
|
||||
/**
|
||||
* A request for gridded data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGridRequest extends IDataRequest<IGridData> {
|
||||
|
||||
/**
|
||||
* Sets a storage request as part of the request. If null, the entire
|
||||
* dataset will be retrieved. Useful for slab requests to avoid retrieving
|
||||
* the entire dataset and boost performance in some scenarios.
|
||||
*
|
||||
* @param request
|
||||
* the {@link Request} to limit the data returned
|
||||
*/
|
||||
public void setStorageRequest(Request request);
|
||||
|
||||
/**
|
||||
* Gets the storage request set on the request.
|
||||
*
|
||||
* @return the {@link Request} set on the IGridRequest
|
||||
*/
|
||||
public Request getStorageRequest();
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* 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.common.dataaccess.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
|
||||
/**
|
||||
*
|
||||
* An abstract request for requesting data through the Data Access Framework.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 6, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractDataRequest {
|
||||
|
||||
protected String datatype;
|
||||
|
||||
protected Map<String, Object> identifiers;
|
||||
|
||||
protected String[] parameters;
|
||||
|
||||
protected Level[] levels;
|
||||
|
||||
public void setDatatype(String datatype) {
|
||||
this.datatype = datatype;
|
||||
}
|
||||
|
||||
public void addIdentifier(String key, Object value) {
|
||||
if (identifiers == null) {
|
||||
identifiers = new HashMap<String, Object>();
|
||||
}
|
||||
identifiers.put(key, value);
|
||||
}
|
||||
|
||||
public void setParameters(String... params) {
|
||||
this.parameters = params;
|
||||
}
|
||||
|
||||
public void setLevels(Level... levels) {
|
||||
this.levels = levels;
|
||||
}
|
||||
|
||||
public String getDatatype() {
|
||||
return datatype;
|
||||
}
|
||||
|
||||
public Map<String, Object> getIdentifiers() {
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
public String[] getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public Level[] getLevels() {
|
||||
return levels;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
/**
|
||||
* 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.common.dataaccess.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.measure.converter.ConversionException;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* A default geometry data object if factory developers do not wish to create
|
||||
* their own IGeometryData implementations.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 9, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DefaultGeometryData implements IGeometryData {
|
||||
|
||||
/**
|
||||
* A simple object to hold a value, type, and unit of a parameter
|
||||
*/
|
||||
public class GeomData {
|
||||
private Object value;
|
||||
|
||||
private Type type;
|
||||
|
||||
private Unit<?> unit;
|
||||
}
|
||||
|
||||
protected Map<String, GeomData> dataMap = new HashMap<String, GeomData>();
|
||||
|
||||
protected DataTime time;
|
||||
|
||||
protected Level level;
|
||||
|
||||
protected Geometry geometry;
|
||||
|
||||
protected String locationName;
|
||||
|
||||
protected Map<String, Object> attributes;
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String key) {
|
||||
Object result = null;
|
||||
if (attributes != null) {
|
||||
result = attributes.get(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTime getDataTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Geometry getGeometry() {
|
||||
return geometry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getParameters() {
|
||||
return dataMap.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(String param) {
|
||||
String result = null;
|
||||
GeomData data = dataMap.get(param);
|
||||
if (data != null) {
|
||||
result = data.value.toString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number getNumber(String param) {
|
||||
Number result = null;
|
||||
GeomData data = dataMap.get(param);
|
||||
if (data != null) {
|
||||
switch (data.type) {
|
||||
case STRING:
|
||||
result = Double.valueOf((String) data.value);
|
||||
break;
|
||||
case INT:
|
||||
result = (Integer) data.value;
|
||||
break;
|
||||
case LONG:
|
||||
result = (Long) data.value;
|
||||
break;
|
||||
case FLOAT:
|
||||
result = (Float) data.value;
|
||||
break;
|
||||
case DOUBLE:
|
||||
result = (Double) data.value;
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(
|
||||
"Unable to handle data of type "
|
||||
+ data.value.getClass());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number getNumber(String param, Unit<?> unit) {
|
||||
Number result = null;
|
||||
if (unit == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unable to convert data to null unit");
|
||||
}
|
||||
GeomData data = dataMap.get(param);
|
||||
if (data != null) {
|
||||
if (data.unit != null) {
|
||||
if (data.unit.isCompatible(unit)) {
|
||||
Number orig = getNumber(param);
|
||||
result = data.unit.getConverterTo(unit).convert(
|
||||
orig.doubleValue());
|
||||
} else {
|
||||
throw new ConversionException("Requested unit " + unit
|
||||
+ " is incompatible with " + param
|
||||
+ " data's unit " + data.unit);
|
||||
}
|
||||
} else {
|
||||
throw new ConversionException(
|
||||
"Unable to convert data due to no unit associated with "
|
||||
+ param);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unit<?> getUnit(String param) {
|
||||
Unit<?> result = null;
|
||||
GeomData data = dataMap.get(param);
|
||||
if (data != null) {
|
||||
result = data.unit;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType(String param) {
|
||||
Type result = null;
|
||||
GeomData data = dataMap.get(param);
|
||||
if (data != null) {
|
||||
result = data.type;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocationName() {
|
||||
return locationName;
|
||||
}
|
||||
|
||||
public void addData(String parameter, GeomData data) {
|
||||
this.dataMap.put(parameter, data);
|
||||
}
|
||||
|
||||
public void setGeometry(Geometry geom) {
|
||||
this.geometry = geom;
|
||||
}
|
||||
|
||||
public void setLevel(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void setDataTime(DataTime time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setLocationName(String locationName) {
|
||||
this.locationName = locationName;
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, Object> attrs) {
|
||||
this.attributes = attrs;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* 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.common.dataaccess.impl;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* A default IGeometryRequest that can be used for most IGeometryRequests.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DefaultGeometryRequest extends AbstractDataRequest implements
|
||||
IGeometryRequest {
|
||||
|
||||
protected Envelope envelope;
|
||||
|
||||
protected String[] locationNames;
|
||||
|
||||
@Override
|
||||
public void setEnvelope(Envelope env) {
|
||||
this.envelope = env;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Envelope getEnvelope() {
|
||||
return envelope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocationNames(String... locationNames) {
|
||||
this.locationNames = locationNames;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLocationNames() {
|
||||
return locationNames;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/**
|
||||
* 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.common.dataaccess.impl;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataDestination;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
/**
|
||||
* A default grid data object if factory developers do not wish to create their
|
||||
* own IGridData implementations.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DefaultGridData implements IGridData {
|
||||
|
||||
protected DataSource data;
|
||||
|
||||
protected DataTime time;
|
||||
|
||||
protected String parameter;
|
||||
|
||||
protected Level level;
|
||||
|
||||
protected Unit<?> unit;
|
||||
|
||||
protected GridGeometry2D gridGeometry;
|
||||
|
||||
protected Map<String, Object> attributes;
|
||||
|
||||
public DefaultGridData(DataSource data, GridGeometry2D gridGeometry) {
|
||||
this.data = data;
|
||||
this.gridGeometry = gridGeometry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String key) {
|
||||
Object result = null;
|
||||
if (attributes != null) {
|
||||
result = attributes.get(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTime getDataTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridGeometry2D getGridGeometry() {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unit<?> getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataDestination populateData(DataDestination destination) {
|
||||
if (destination == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Data destination must not be null");
|
||||
}
|
||||
|
||||
for (int x = 0; x < gridGeometry.axisDimensionX; x++) {
|
||||
for (int y = 0; y < gridGeometry.axisDimensionY; y++) {
|
||||
destination.setDataValue(data.getDataValue(x, y), x, y);
|
||||
}
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
|
||||
public void setDataTime(DataTime time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setParameter(String parameter) {
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
public void setLevel(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public void setUnit(Unit<?> unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, Object> attrs) {
|
||||
this.attributes = attrs;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* 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.common.dataaccess.impl;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
|
||||
/**
|
||||
* A default IGridRequest that can be used for most IGridRequests.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DefaultGridRequest extends AbstractDataRequest implements
|
||||
IGridRequest {
|
||||
|
||||
protected Request storageRequest;
|
||||
|
||||
@Override
|
||||
public void setStorageRequest(Request request) {
|
||||
this.storageRequest = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request getStorageRequest() {
|
||||
return this.storageRequest;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* 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.common.geospatial.interpolation.data;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
||||
/**
|
||||
* Wraps an int array as a {@link DataSource} and {@link DataDestination}
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class IntArrayWrapper extends DataWrapper1D {
|
||||
|
||||
protected final int[] array;
|
||||
|
||||
public IntArrayWrapper(int[] array, GeneralGridGeometry geometry) {
|
||||
super(geometry);
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public IntArrayWrapper(int[] array, int nx, int ny) {
|
||||
super(nx, ny);
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public IntArrayWrapper(int nx, int ny) {
|
||||
this(new int[nx * ny], nx, ny);
|
||||
}
|
||||
|
||||
public IntArrayWrapper(GeneralGridGeometry geometry) {
|
||||
// assume this is going to be a destination and avoid passing
|
||||
// geometry to super to save time on checking for wrapping.
|
||||
this(geometry.getGridRange().getSpan(0), geometry.getGridRange()
|
||||
.getSpan(1));
|
||||
}
|
||||
|
||||
public int[] getArray() {
|
||||
return array;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getDataValueInternal(int index) {
|
||||
return array[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDataValueInternal(double dataValue, int index) {
|
||||
array[index] = (int) dataValue;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.common.geospatial.interpolation.data;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
|
||||
/**
|
||||
* A data destination that converts to a unit with the specified unit converter;
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class UnitConvertingDataDestination implements DataDestination {
|
||||
|
||||
protected UnitConverter unitConverter;
|
||||
|
||||
protected DataDestination wrappedDestination;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param converter
|
||||
* the unit converter to apply when setting the values in the
|
||||
* destination
|
||||
* @param destination
|
||||
* the destination to set values on
|
||||
*/
|
||||
public UnitConvertingDataDestination(UnitConverter converter,
|
||||
DataDestination destination) {
|
||||
this.unitConverter = converter;
|
||||
this.wrappedDestination = destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataValue(double dataValue, int x, int y) {
|
||||
wrappedDestination.setDataValue(unitConverter.convert(dataValue), x, y);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.common.geospatial.interpolation.data;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
|
||||
/**
|
||||
* A data source that converts requested values to a unit with the specified
|
||||
* converter.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 12, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class UnitConvertingDataSource implements DataSource {
|
||||
|
||||
protected UnitConverter unitConverter;
|
||||
|
||||
protected DataSource wrappedSource;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param converter
|
||||
* the unit converter to apply when getting the values in the
|
||||
* data source
|
||||
* @param source
|
||||
* the source to get values from
|
||||
*/
|
||||
public UnitConvertingDataSource(UnitConverter converter, DataSource source) {
|
||||
this.unitConverter = converter;
|
||||
this.wrappedSource = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDataValue(int x, int y) {
|
||||
return unitConverter.convert(wrappedSource.getDataValue(x, y));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue