Issue #189 checkin of gridcoverage plugin and switch existing grib to use new plugin

Change-Id: I060f13ce68e7947e54d62d25d90ebdad2666bece

Former-commit-id: 05849f634d [formerly 8f164a7b948e462b14caf6576de2b898a9a4e880]
Former-commit-id: bd8eb7fc15
This commit is contained in:
Ben Steffensmeier 2012-09-11 10:40:36 -05:00
parent c1a0d9556e
commit 4fe2127bfb
83 changed files with 2089 additions and 1867 deletions

View file

@ -28,9 +28,9 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.objectiveanalysis.rsc
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.radar,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.viz.derivparam.library,
com.raytheon.uf.viz.derivparam.tree,
com.raytheon.viz.ui,

View file

@ -39,4 +39,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.gridcoverage"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.viz.productbrowser;bundle-version="1.11.31",
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
com.raytheon.uf.viz.points;bundle-version="1.0.0"
com.raytheon.uf.viz.points;bundle-version="1.0.0",
com.raytheon.uf.common.gridcoverage
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.grid,
com.raytheon.viz.grid.gridcache,
@ -37,7 +38,6 @@ Import-Package: com.raytheon.edex.scriptfactory,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.exception,
com.raytheon.uf.common.dataplugin.grib.request,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.subgrid,
com.raytheon.uf.common.dataplugin.grib.util,
com.raytheon.uf.common.dataplugin.level,

View file

@ -24,10 +24,10 @@ import java.util.List;
import javax.media.jai.Interpolation;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;

View file

@ -28,7 +28,6 @@ import javax.measure.unit.Unit;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.common.dataplugin.radar.util.RadarDataRetriever;
@ -38,6 +37,7 @@ import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
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.common.status.UFStatus.Priority;

View file

@ -22,7 +22,6 @@ package com.raytheon.viz.grid.data;
import javax.measure.unit.SI;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.dataplugin.grib.util.StaticGridData;
@ -30,6 +29,7 @@ import com.raytheon.uf.common.dataplugin.grib.util.StaticGridDataType;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
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.common.status.UFStatus.Priority;

View file

@ -21,10 +21,10 @@ package com.raytheon.viz.grid.data;
import javax.measure.unit.SI;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.viz.grid.util.CoverageUtils;

View file

@ -27,10 +27,10 @@ import javax.measure.unit.SI;
import org.geotools.coverage.grid.GridGeometry2D;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
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.common.status.UFStatus.Priority;

View file

@ -33,7 +33,6 @@ import java.util.NavigableSet;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.dataplugin.grib.util.StaticGridDataType;
@ -46,6 +45,7 @@ import com.raytheon.uf.common.derivparam.tree.DataTree;
import com.raytheon.uf.common.derivparam.tree.LevelNode;
import com.raytheon.uf.common.derivparam.tree.ParameterNode;
import com.raytheon.uf.common.derivparam.tree.SourceNode;
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.common.status.UFStatus.Priority;

View file

@ -29,10 +29,10 @@ import javax.measure.unit.UnitFormat;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.viz.grid.data.GribRequestableData;

View file

@ -51,11 +51,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.grib.CombinedGribRecord;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.MercatorGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.PolarStereoGridCoverage;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
@ -63,6 +58,11 @@ import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.interpolation.BilinearInterpolation;
import com.raytheon.uf.common.geospatial.interpolation.GridReprojection;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LambertConformalGridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.gridcoverage.MercatorGridCoverage;
import com.raytheon.uf.common.gridcoverage.PolarStereoGridCoverage;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;

View file

@ -62,8 +62,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.grib.CombinedGribRecord;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
@ -75,6 +73,8 @@ import com.raytheon.uf.common.geospatial.interpolation.GridReprojection;
import com.raytheon.uf.common.geospatial.interpolation.GridSampler;
import com.raytheon.uf.common.geospatial.interpolation.NearestNeighborInterpolation;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;

View file

@ -43,7 +43,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.grib.CombinedGribRecord;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
@ -55,6 +54,7 @@ import com.raytheon.uf.common.geospatial.interpolation.BilinearInterpolation;
import com.raytheon.uf.common.geospatial.interpolation.GridReprojection;
import com.raytheon.uf.common.geospatial.interpolation.GridSampler;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
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.common.status.UFStatus.Priority;

View file

@ -33,7 +33,6 @@ import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
@ -43,6 +42,7 @@ import com.raytheon.uf.common.geospatial.interpolation.Interpolation;
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatBufferWrapper;
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.common.status.UFStatus.Priority;

View file

@ -21,10 +21,8 @@ package com.raytheon.viz.grid.spatial;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
/**
* Stereographic Coverage used by radar data.
@ -47,21 +45,17 @@ public class StereographicCoverage extends GridCoverage {
private Integer ny;
@Override
public void generateName() {
}
@Override
public String getProjectionType() {
return "Stereographic";
}
@Override
public void initialize() throws GribException {
public void initialize() {
}
@Override
public GridCoverage trim(SubGridDef subGridDef, SubGrid subGrid) {
public GridCoverage trim(SubGrid subGrid) {
// NOT SUPPORTED
return null;
}

View file

@ -44,9 +44,9 @@ import org.opengis.geometry.Envelope;
import com.raytheon.uf.common.dataplugin.grib.request.GetCoverageRequest;
import com.raytheon.uf.common.dataplugin.grib.request.GetCoveragesRequest;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;

View file

@ -30,11 +30,11 @@ import org.geotools.referencing.GeodeticCalculator;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.dataplugin.radar.RadarStation;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;

View file

@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.mpe;bundle-version="1.11.13",
com.raytheon.uf.viz.core.maps;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174"
com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.hydrocommon,
com.raytheon.viz.hydrocommon.actions,

View file

@ -41,11 +41,11 @@ Export-Package: com.raytheon.viz.volumebrowser,
com.raytheon.viz.volumebrowser.xml
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.util,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.obs.metar,
com.raytheon.uf.common.derivparam.tree,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.menus,
com.raytheon.uf.common.menus.xml,
com.raytheon.uf.common.message.response,

View file

@ -35,11 +35,11 @@ import org.geotools.geometry.Envelope2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.geospatial.MapUtil;
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.common.status.UFStatus.Priority;

View file

@ -0,0 +1,67 @@
#!/bin/bash
# This script will add register the gridcoverage plugin, which was previously part of grib
#
# This needs to be performed with build ????
#
PSQL="/awips2/psql/bin/psql"
SQL_COMMAND_CHECK="select * FROM gridcoverage LIMIT 1;"
SQL_COMMAND_REGISTER="insert into plugin_info (name, database, initialized, tablename) VALUES('gridcoverage', 'metadata', TRUE, 'gridcoverage');"
SQL_COMMAND_SEQ="CREATE SEQUENCE gridcoverage_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; ALTER TABLE gridcoverage_seq OWNER TO awips;"
SQL_COMMAND_UPDATE_ID="update gridcoverage set id=nextval('gridcoverage_seq');"
SQL_COMMAND_ALTER_NAME_DESC="ALTER TABLE gridcoverage DROP COLUMN description, ALTER COLUMN name TYPE character varying(255);"
SQL_COMMAND_UPDATE_NAME="update gridcoverage g1 set name = 'Subgrid-' || g2.id from gridcoverage g2 where g1.name like '%-SubGrid-%' and g2.name = split_part(g1.name, '-',1);"
if [ ! -f ${PSQL} ]; then
echo "ERROR: The PSQL executable does not exist - ${PSQL}."
echo "FATAL: Update Failed!"
exit 1
fi
echo ""
echo "Press Enter to perform the updates Ctrl-C to quit."
read done
${PSQL} -U awips -d metadata -c "${SQL_COMMAND_CHECK}" > /dev/null
if [ $? -ne 0 ]; then
echo "WARN: gridcoverage table does not exist so we are not registering the plugin"
exit 0
fi
${PSQL} -U awips -d metadata -c "${SQL_COMMAND_REGISTER}"
if [ $? -ne 0 ]; then
echo "FATAL: Update Failed!"
exit 1
fi
${PSQL} -U awips -d metadata -c "${SQL_COMMAND_SEQ}"
if [ $? -ne 0 ]; then
echo "FATAL: unable to create gridcoverage_seq"
exit 1
fi
FK=`${PSQL} -U awips -d metadata -c "\d grib_models" | grep gridcoverage | awk -F"\"" '{print $2}'`
if [ -z "$FK" ]; then
echo "FATAL: unable to find foreign key constraint on grib_models"
exit 1
fi
${PSQL} -U awips -d metadata -c "ALTER TABLE grib_models DROP CONSTRAINT ${FK}, ADD CONSTRAINT ${FK} FOREIGN KEY (location_id) REFERENCES gridcoverage (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE NO ACTION;"
if [ -z "$FK" ]; then
echo "FATAL: unable to modify foreign key constraint on grib_models"
exit 1
fi
${PSQL} -U awips -d metadata -c "${SQL_COMMAND_UPDATE_ID}"
if [ -z "$FK" ]; then
echo "FATAL: unable to update gridcoverage ids"
exit 1
fi
${PSQL} -U awips -d metadata -c "${SQL_COMMAND_ALTER_NAME_DESC}"
if [ -z "$FK" ]; then
echo "WARN: unable to remove description column from gridcoverage table"
fi
echo "INFO: The update was successfully applied."
exit 0

View file

@ -73,9 +73,11 @@
<include>time-common.xml</include>
<include>grib-common.xml</include>
<include>grib-ingest.xml</include>
<include>level-common.xml</include>
<include>level-common.xml</include>
<include>gridcoverage-common.xml</include>
<include>persist-ingest.xml</include>
<include>management-common.xml</include>
<include>database-common.xml</include>
<include>auth-common.xml</include>
<!-- ncep excludes until tested -->
<exclude>ncgrib-common.xml</exclude>

View file

@ -61,7 +61,6 @@ Import-Package: com.raytheon.edex.db.dao,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.annotations,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.util,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.persist,
@ -69,6 +68,7 @@ Import-Package: com.raytheon.edex.db.dao,
com.raytheon.uf.common.datastorage,
com.raytheon.uf.common.datastorage.records,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.message,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.python,

View file

@ -61,9 +61,9 @@ import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice;
import com.raytheon.uf.common.dataplugin.gfe.util.GfeUtil;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.message.WsId;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;

View file

@ -46,11 +46,11 @@ from com.raytheon.uf.common.serialization import SerializationUtil
from com.raytheon.uf.common.dataplugin.grib import GribRecord
from com.raytheon.uf.common.dataplugin.grib import GribModel
from com.raytheon.uf.common.dataplugin.grib.spatial.projections import LambertConformalGridCoverage
from com.raytheon.uf.common.dataplugin.grib.spatial.projections import LatLonGridCoverage
from com.raytheon.uf.common.dataplugin.grib.spatial.projections import MercatorGridCoverage
from com.raytheon.uf.common.dataplugin.grib.spatial.projections import PolarStereoGridCoverage
from com.raytheon.uf.common.dataplugin.grib.spatial.projections import Corner
from com.raytheon.uf.common.gridcoverage import LambertConformalGridCoverage
from com.raytheon.uf.common.gridcoverage import LatLonGridCoverage
from com.raytheon.uf.common.gridcoverage import MercatorGridCoverage
from com.raytheon.uf.common.gridcoverage import PolarStereoGridCoverage
from com.raytheon.uf.common.gridcoverage import Corner
from com.raytheon.uf.common.dataplugin.grib.util import GribModelLookup
from com.raytheon.uf.common.dataplugin.level import Level
@ -368,6 +368,7 @@ class GribDecoder():
# check sub gridding
modelName = pdsSectionValues['model'].getModelName()
spatialCache = GribSpatialCache.getInstance()
gridCoverage = gdsSectionValues['coverage']
subCoverage = spatialCache.getSubGridCoverage(modelName)
if subCoverage is not None:
@ -399,11 +400,9 @@ class GribDecoder():
# set the new coverage
gdsSectionValues['coverage'] = subCoverage
numpyDataArray = numpy.resize(numpyDataArray, (1, metadata[4]))
pdsSectionValues['model'].setLocation(gdsSectionValues['coverage'])
numpyDataArray = numpy.resize(numpyDataArray, (1, metadata[4]))
newAbbr = GribParamTranslator.getInstance().translateParameter(2, pdsSectionValues['model'], dataTime)
newAbbr = GribParamTranslator.getInstance().translateParameter(2, pdsSectionValues['model'].getParameterAbbreviation(), pdsSectionValues['model'].getCenterid(), pdsSectionValues['model'].getSubcenterid(), pdsSectionValues['model'].getGenprocess(), dataTime, gridCoverage)
if newAbbr is None:
if pdsSectionValues['model'].getParameterName() != MISSING and dataTime.getValidPeriod().getDuration() > 0:
@ -816,7 +815,6 @@ class GribDecoder():
coverage.setDx(dx)
coverage.setDy(dy)
coverage.determineFirstGridPointCorner(scanMode)
coverage.setId(coverage.hashCode())
coverage = self._getGrid(coverage)
@ -860,7 +858,6 @@ class GribDecoder():
coverage.setDx(dx)
coverage.setDy(dy)
coverage.determineFirstGridPointCorner(scanMode)
coverage.setId(coverage.hashCode())
coverage = self._getGrid(coverage)
@ -892,8 +889,6 @@ class GribDecoder():
coverage.setDx(dx)
coverage.setDy(dy)
coverage.determineFirstGridPointCorner(scanMode)
coverage.setId(coverage.hashCode())
coverage = self._getGrid(coverage)
@ -927,7 +922,6 @@ class GribDecoder():
coverage.setLatin1(latin1)
coverage.setLatin2(latin2)
coverage.determineFirstGridPointCorner(scanMode)
coverage.setId(coverage.hashCode())
coverage = self._getGrid(coverage)

View file

@ -22,13 +22,13 @@ Require-Bundle: javax.measure,
com.raytheon.uf.common.datastorage.hdf5;bundle-version="1.12.1174",
com.raytheon.uf.edex.awipstools;bundle-version="1.12.1174",
com.raytheon.uf.common.awipstools;bundle-version="1.12.1174",
ucar.nc2;bundle-version="1.0.0"
ucar.nc2;bundle-version="1.0.0",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0"
Import-Package: com.raytheon.edex.exception,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.exception,
com.raytheon.uf.common.dataplugin.grib.request,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.subgrid,
com.raytheon.uf.common.dataplugin.grib.util,
com.raytheon.uf.common.dataplugin.level,

View file

@ -15,6 +15,7 @@
<property name="dependencyFQNs">
<list>
<value>com.raytheon.uf.common.dataplugin.level</value>
<value>com.raytheon.uf.common.gridcoverage</value>
</list>
</property>
<property name="pathProvider">
@ -24,7 +25,7 @@
</bean>
<bean id="gribRegistered" factory-bean="pluginRegistry" factory-method="register"
depends-on="levelRegistered">
depends-on="levelRegistered,gridcoverageRegistered,gridcoveragelookup">
<constructor-arg value="grib"/>
<constructor-arg ref="gribProperties"/>
</bean>
@ -32,10 +33,6 @@
<bean id="gribModelCache"
class="com.raytheon.edex.plugin.grib.util.GribModelCache" factory-method="getInstance" />
<bean id="LatLonDao" class="com.raytheon.edex.plugin.grib.dao.LatLonDao" />
<bean id="MercatorDao" class="com.raytheon.edex.plugin.grib.dao.MercatorDao" />
<bean id="PolarStereographicDao" class="com.raytheon.edex.plugin.grib.dao.PolarStereoDao" />
<bean id="LambertConformalDao" class="com.raytheon.edex.plugin.grib.dao.LambertConformalDao" />
<camelContext id="grib-common-camel" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<route id="purgeGribModelCache">

View file

@ -58,16 +58,16 @@ import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.MercatorGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.PolarStereoGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LambertConformalGridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.gridcoverage.MercatorGridCoverage;
import com.raytheon.uf.common.gridcoverage.PolarStereoGridCoverage;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
@ -465,7 +465,8 @@ public class Grib1Decoder extends AbstractDecoder {
}
String newAbbr = GribParamTranslator.getInstance().translateParameter(
1, model, dataTime);
1, parameterAbbreviation, centerid, subcenterid,
model.getGenprocess(), dataTime, gridCoverage);
if (newAbbr == null) {
if (!model.getParameterName().equals(MISSING)
@ -768,7 +769,6 @@ public class Grib1Decoder extends AbstractDecoder {
latLonCoverage.setDy(latLonCoverage.getDx());
}
latLonCoverage.determineFirstGridPointCorner(gdsVars.getScanMode());
latLonCoverage.setId(latLonCoverage.hashCode());
coverage = getGridFromCache(latLonCoverage, gridNumber);
break;
}
@ -797,7 +797,6 @@ public class Grib1Decoder extends AbstractDecoder {
mercator.setDy(gdsVars.getDy() / 1000);
}
mercator.determineFirstGridPointCorner(gdsVars.getScanMode());
mercator.setId(mercator.hashCode());
coverage = getGridFromCache(mercator, gridNumber);
break;
}
@ -825,7 +824,6 @@ public class Grib1Decoder extends AbstractDecoder {
lambert.setDy(gdsVars.getDy() / 1000);
}
lambert.determineFirstGridPointCorner(gdsVars.getScanMode());
lambert.setId(lambert.hashCode());
coverage = getGridFromCache(lambert, gridNumber);
break;
@ -858,7 +856,6 @@ public class Grib1Decoder extends AbstractDecoder {
polar.setDy(gdsVars.getDy() / 1000);
}
polar.determineFirstGridPointCorner(gdsVars.getScanMode());
polar.setId(polar.hashCode());
coverage = getGridFromCache(polar, gridNumber);
break;
}

View file

@ -60,7 +60,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
public class GribModelDao extends CoreDao {
private static final IUFStatusHandler handler = UFStatus
.getHandler(GridCoverageDao.class);
.getHandler(GribModelDao.class);
/**
* Creates a new GribModelDao

View file

@ -1,197 +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.edex.plugin.grib.dao;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataquery.db.QueryParam;
import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
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;
/**
* Data access object for retrieving GridCoverage objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class GridCoverageDao extends CoreDao {
protected static final float QUERY_TOLERANCE = 0.1f;
private static final IUFStatusHandler handler = UFStatus
.getHandler(GridCoverageDao.class);
public GridCoverageDao() {
super(DaoConfig.forClass(GridCoverage.class));
}
public GridCoverageDao(DaoConfig config) {
super(config);
}
protected QueryParam addQueryTolerance(String field, double value) {
String between = String.valueOf(value - QUERY_TOLERANCE) + "--"
+ String.valueOf(value + QUERY_TOLERANCE);
return new QueryParam(field, between, QueryOperand.BETWEEN);
}
@SuppressWarnings("unchecked")
public GridCoverage queryByGridNumber(Integer number)
throws DataAccessLayerException {
List<GridCoverage> coverages = (List<GridCoverage>) this
.queryBySingleCriteria("name", String.valueOf(number));
if (coverages.isEmpty()) {
return null;
} else {
return coverages.get(0);
}
}
/**
* Method used by subclasses to pick the known grid if multiple results from
* the query are returned and the results include generated unknown grib
* coverage objects
*
* @param coverages
* The grib coverages to examine
* @return The 'known' coverage object if one is contained in the list
*/
protected GridCoverage selectKnownGrid(
List<? extends GridCoverage> coverages) {
if (coverages.isEmpty()) {
return null;
} else if (coverages.size() == 1) {
return coverages.get(0);
} else {
for (GridCoverage coverage : coverages) {
if (!coverage.getDescription().startsWith("Unknown")) {
return coverage;
}
}
return coverages.get(0);
}
}
@SuppressWarnings("unchecked")
public List<? extends GridCoverage> loadBaseGrids() {
return (List<GridCoverage>) txTemplate
.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate();
Session sess = ht.getSessionFactory()
.getCurrentSession();
Criteria crit = sess.createCriteria(GridCoverage.class);
Criterion where = Restrictions.not(Restrictions.like(
"name", "Unknown%"));
where = Restrictions.and(where, Restrictions
.not(Restrictions.like("name", "%SubGrid%")));
crit.add(where);
return crit.list();
}
});
}
@SuppressWarnings("unchecked")
public List<? extends GridCoverage> loadSubGrids() {
return (List<GridCoverage>) txTemplate
.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate();
Session sess = ht.getSessionFactory()
.getCurrentSession();
Criteria crit = sess.createCriteria(GridCoverage.class);
Criterion where = Restrictions
.like("name", "%SubGrid%");
crit.add(where);
return crit.list();
}
});
}
@SuppressWarnings("unchecked")
public List<? extends GridCoverage> loadUnknownGrids() {
return (List<GridCoverage>) txTemplate
.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = getHibernateTemplate();
Session sess = ht.getSessionFactory()
.getCurrentSession();
Criteria crit = sess.createCriteria(GridCoverage.class);
Criterion where = Restrictions.like("name", "Unknown%");
crit.add(where);
return crit.list();
}
});
}
public boolean deleteCoverageAssociatedData(GridCoverage cov,
boolean deleteCoverage) {
boolean rval = false;
try {
GribModelDao modelDao = new GribModelDao();
// query for models to delete
List<String> modelNames = modelDao.getModelNamesForCoverage(cov
.getId());
for (String modelName : modelNames) {
handler.info("Coverage for model " + modelName
+ " has changed. Deleting prior records");
modelDao.deleteModelAndAssociatedData(modelName);
}
// delete coverage
if (deleteCoverage) {
this.delete(cov);
}
rval = true;
} catch (Exception e) {
handler.error("Error occurred deleting coverage associated data", e);
}
return rval;
}
}

View file

@ -1,85 +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.edex.plugin.grib.dao;
import java.util.List;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
/**
* Data Access Object for retrieving LambertConforamlGridCoverage objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class LambertConformalDao extends GridCoverageDao implements
IGridCoverageDao {
/**
* Creates new MercatorDao
*/
public LambertConformalDao() {
super(DaoConfig.forClass(LambertConformalGridCoverage.class));
}
/**
* Checks that database to see if a grid exists in the database which very
* closely resembles the provided coverage
*
* @param coverage
* The PolarStereoGridCoverage to check against
* @return The Grid from the database or null if not found
* @throws DataAccessLayerException
* If problems during query
*/
@SuppressWarnings("unchecked")
public GridCoverage checkGrid(GridCoverage grid)
throws DataAccessLayerException {
LambertConformalGridCoverage coverage = (LambertConformalGridCoverage) grid;
DatabaseQuery query = new DatabaseQuery(this.daoClass);
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
query.addQueryParam(addQueryTolerance("latin1", coverage.getLatin1()));
query.addQueryParam(addQueryTolerance("latin2", coverage.getLatin2()));
query.addQueryParam(addQueryTolerance("lov", coverage.getLov()));
query.addQueryParam("nx", coverage.getNx());
query.addQueryParam("ny", coverage.getNy());
List<LambertConformalGridCoverage> result = (List<LambertConformalGridCoverage>) queryByCriteria(query);
return selectKnownGrid(result);
}
}

View file

@ -1,140 +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.edex.plugin.grib.dao;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.plugin.grib.Grib1Decoder;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
/**
* Data Access Object for retrieving LatLonGridCoverage objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class LatLonDao extends GridCoverageDao implements IGridCoverageDao {
/**
* Creates a new LatLonDao
*/
public LatLonDao() {
super(DaoConfig.forClass(LatLonGridCoverage.class));
}
/**
* Checks that database to see if a grid exists in the database which very
* closely resembles the provided coverage
*
* @param coverage
* The LatLonGridCoverage to check against
* @return The Grid from the database or null if not found
* @throws DataAccessLayerException
* If problems during query
*/
@SuppressWarnings("unchecked")
public GridCoverage checkGrid(GridCoverage grid)
throws DataAccessLayerException {
LatLonGridCoverage coverage = (LatLonGridCoverage) grid;
DatabaseQuery query = new DatabaseQuery(this.daoClass);
// If dx and dy are present, use them
if (coverage.getDx() != 65.535) {
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
}
if (coverage.getDy() != 65.535) {
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
}
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
query.addQueryParam("nx", coverage.getNx());
query.addQueryParam("ny", coverage.getNy());
query.addQueryParam("firstGridPointCorner",coverage.getFirstGridPointCorner());
List<LatLonGridCoverage> result = (List<LatLonGridCoverage>) queryByCriteria(query);
if (result.isEmpty()) {
return manualCheck(coverage);
} else {
return selectKnownGrid(result);
}
}
@SuppressWarnings("unchecked")
private GridCoverage manualCheck(LatLonGridCoverage coverage)
throws DataAccessLayerException {
DatabaseQuery query = new DatabaseQuery(this.daoClass);
query.addQueryParam("nx", coverage.getNx());
query.addQueryParam("ny", coverage.getNy());
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
List<LatLonGridCoverage> result = (List<LatLonGridCoverage>) queryByCriteria(query);
List<LatLonGridCoverage> matchingCoverages = new ArrayList<LatLonGridCoverage>();
for (LatLonGridCoverage gridToCheck : result) {
if (checkLat(coverage.getLa1(), gridToCheck.getLa1())
&& checkLon(coverage.getLo1(), gridToCheck.getLo1())) {
matchingCoverages.add(gridToCheck);
}
}
return selectKnownGrid(matchingCoverages);
}
private boolean checkLat(double reference, double latToCheck) {
double correctedRef = Grib1Decoder.correctLat((float) reference);
double correctedLat = Grib1Decoder.correctLat((float) latToCheck);
if (Math.abs(correctedRef - correctedLat) < QUERY_TOLERANCE
|| Math.abs(correctedLat - correctedRef) < QUERY_TOLERANCE) {
return true;
}
return false;
}
private boolean checkLon(double reference, double lonToCheck) {
double correctedRef = Grib1Decoder.correctLon((float) reference);
double correctedLon = Grib1Decoder.correctLon((float) lonToCheck);
if (Math.abs(correctedRef - correctedLon) < QUERY_TOLERANCE
|| Math.abs(correctedLon - correctedRef) < QUERY_TOLERANCE) {
return true;
}
return false;
}
}

View file

@ -1,83 +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.edex.plugin.grib.dao;
import java.util.List;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.MercatorGridCoverage;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
/**
* Data Access Object for retrieving MercatorCoverage objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class MercatorDao extends GridCoverageDao implements IGridCoverageDao {
/**
* Creates new MercatorDao
*/
public MercatorDao() {
super(DaoConfig.forClass(MercatorGridCoverage.class));
}
/**
* Checks that database to see if a grid exists in the database which very
* closely resembles the provided coverage
*
* @param coverage
* The MercatorCoverage to check against
* @return The Grid from the database or null if not found
* @throws DataAccessLayerException
* If problems during query
*/
@SuppressWarnings("unchecked")
public GridCoverage checkGrid(GridCoverage grid)
throws DataAccessLayerException {
MercatorGridCoverage coverage = (MercatorGridCoverage) grid;
DatabaseQuery query = new DatabaseQuery(this.daoClass);
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
query.addQueryParam(addQueryTolerance("latin", coverage.getLatin()));
query.addQueryParam("nx", coverage.getNx());
query.addQueryParam("ny", coverage.getNy());
List<MercatorGridCoverage> result = (List<MercatorGridCoverage>) queryByCriteria(query);
return selectKnownGrid(result);
}
}

View file

@ -1,84 +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.edex.plugin.grib.dao;
import java.util.List;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.PolarStereoGridCoverage;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
/**
* Data Access Object for retrieving PolarStereoGridCoverage objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class PolarStereoDao extends GridCoverageDao implements IGridCoverageDao {
/**
* Creates new MercatorDao
*/
public PolarStereoDao() {
super(DaoConfig.forClass(PolarStereoGridCoverage.class));
}
/**
* Checks that database to see if a grid exists in the database which very
* closely resembles the provided coverage
*
* @param coverage
* The PolarStereoGridCoverage to check against
* @return The Grid from the database or null if not found
* @throws DataAccessLayerException
* If problems during query
*/
@SuppressWarnings("unchecked")
public GridCoverage checkGrid(GridCoverage grid)
throws DataAccessLayerException {
PolarStereoGridCoverage coverage = (PolarStereoGridCoverage) grid;
DatabaseQuery query = new DatabaseQuery(this.daoClass);
query.addQueryParam(addQueryTolerance("dx", coverage.getDx()));
query.addQueryParam(addQueryTolerance("dy", coverage.getDy()));
query.addQueryParam(addQueryTolerance("la1", coverage.getLa1()));
query.addQueryParam(addQueryTolerance("lo1", coverage.getLo1()));
query.addQueryParam(addQueryTolerance("lov", coverage.getLov()));
query.addQueryParam(addQueryTolerance("lad", coverage.getLad()));
query.addQueryParam("nx", coverage.getNx());
query.addQueryParam("ny", coverage.getNy());
List<PolarStereoGridCoverage> result = (List<PolarStereoGridCoverage>) queryByCriteria(query);
return selectKnownGrid(result);
}
}

View file

@ -38,11 +38,11 @@ import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.StatusConstants;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.StorageStatus;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;

View file

@ -21,7 +21,7 @@ package com.raytheon.edex.plugin.grib.handler;
import com.raytheon.edex.plugin.grib.spatial.GribSpatialCache;
import com.raytheon.uf.common.dataplugin.grib.request.GetCoverageRequest;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**

View file

@ -24,7 +24,7 @@ import java.util.List;
import com.raytheon.edex.plugin.grib.spatial.GribSpatialCache;
import com.raytheon.uf.common.dataplugin.grib.request.GetCoveragesRequest;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**

View file

@ -63,7 +63,6 @@ import com.raytheon.edex.plugin.grib.spatial.GribSpatialCache;
import com.raytheon.edex.plugin.grib.util.GribParamInfoLookup;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
@ -77,6 +76,7 @@ import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.geospatial.CRSCache;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -598,7 +598,7 @@ public class StaticTopoData {
* fully populated
*/
float[] finalData = null;
for (String topoData : TOPO_FILES) {
for (String dataSet : TopoAttributes.attributeMap.keySet()) {
if (dataSet.startsWith(topoData)) {
@ -614,15 +614,15 @@ public class StaticTopoData {
break;
}
}
for (int i = 0; i < finalData.length; i++) {
float v = finalData[i];
if (Float.isNaN(v))
finalData[i] = TOPO_FILL;
else if (v == DATA_FILL || (v > -0.5 && v < 0.5))
finalData[i] = 0.0f;
else
finalData[i] = v;
float v = finalData[i];
if (Float.isNaN(v))
finalData[i] = TOPO_FILL;
else if (v == DATA_FILL || (v > -0.5 && v < 0.5))
finalData[i] = 0.0f;
else
finalData[i] = v;
}
return finalData;
@ -702,10 +702,12 @@ public class StaticTopoData {
inGeom.getEnvelope2D(), inCrs);
refEnv = refEnv.transform(topoCrs, true);
DirectPosition upperCorner = topoGeom.getCRSToGrid2D(PixelOrientation.UPPER_LEFT).transform(
refEnv.getUpperCorner(), null);
DirectPosition lowerCorner = topoGeom.getCRSToGrid2D(PixelOrientation.UPPER_LEFT).transform(
refEnv.getLowerCorner(), null);
DirectPosition upperCorner = topoGeom.getCRSToGrid2D(
PixelOrientation.UPPER_LEFT).transform(refEnv.getUpperCorner(),
null);
DirectPosition lowerCorner = topoGeom.getCRSToGrid2D(
PixelOrientation.UPPER_LEFT).transform(refEnv.getLowerCorner(),
null);
int minx = (int) Math.floor(Math.min(lowerCorner.getOrdinate(0),
upperCorner.getOrdinate(0)));
@ -717,48 +719,47 @@ public class StaticTopoData {
upperCorner.getOrdinate(1)));
if ("world".equals(name)) {
if (minx - DATA_MARGIN < 0 ||
miny - DATA_MARGIN < 0 ||
maxx + DATA_MARGIN >= nx ||
maxy + DATA_MARGIN >= ny) {
/* TODO: Have to do quite a bit more for minimal world
* projection subset. Just load the whole thing for now.
if (minx - DATA_MARGIN < 0 || miny - DATA_MARGIN < 0
|| maxx + DATA_MARGIN >= nx || maxy + DATA_MARGIN >= ny) {
/*
* TODO: Have to do quite a bit more for minimal world
* projection subset. Just load the whole thing for now.
*/
minx = miny = 0;
maxx = nx;
maxy = ny;
}
minx = miny = 0;
maxx = nx;
maxy = ny;
}
} else {
if (minx - DATA_MARGIN >= 0) {
minx -= DATA_MARGIN;
} else {
minx = 0;
}
if (miny - DATA_MARGIN >= 0) {
miny -= DATA_MARGIN;
} else {
miny = 0;
}
if (maxx + DATA_MARGIN <= nx) {
maxx += DATA_MARGIN;
} else {
maxx = nx;
}
if (maxy + DATA_MARGIN <= ny) {
maxy += DATA_MARGIN;
} else {
maxy = ny;
}
if (minx - DATA_MARGIN >= 0) {
minx -= DATA_MARGIN;
} else {
minx = 0;
}
if (miny - DATA_MARGIN >= 0) {
miny -= DATA_MARGIN;
} else {
miny = 0;
}
if (maxx + DATA_MARGIN <= nx) {
maxx += DATA_MARGIN;
} else {
maxx = nx;
}
if (maxy + DATA_MARGIN <= ny) {
maxy += DATA_MARGIN;
} else {
maxy = ny;
}
}
double[] input = new double[] { minx, miny, maxx, maxy };
double[] output = new double[input.length];
topoGeom.getGridToCRS(PixelInCell.CELL_CORNER)
.transform(input, 0, output, 0, input.length / 2);
topoGeom.getGridToCRS(PixelInCell.CELL_CORNER).transform(input, 0,
output, 0, input.length / 2);
DirectPosition dpUpper = new DirectPosition2D(Math.max(output[0],
output[2]), Math.max(output[1], output[3]));
@ -797,12 +798,13 @@ public class StaticTopoData {
// Reproject the data into the requested CRS and geometry
float[] f1 = null;
try {
f1 = simpleResample(topoCoverage, slabData, inGeom, name, minx, miny);
f1 = simpleResample(topoCoverage, slabData, inGeom, name, minx,
miny);
} catch (Exception e) {
statusHandler.error("rasample failed", e);
throw e;
statusHandler.error("rasample failed", e);
throw e;
}
if (finalData == null) {
finalData = f1;
} else {
@ -816,182 +818,202 @@ public class StaticTopoData {
return finalData;
}
float[] simpleResample(GridCoverage2D sourceGC, float[][] sourceData, GridGeometry2D targetGG, String pfx, int minx, int miny) {
int sourceWidth = sourceGC.getGridGeometry().getGridRange2D().getSpan(0);
int sourceHeight = sourceGC.getGridGeometry().getGridRange2D().getSpan(1);
int targetWidth = targetGG.getGridRange2D().getSpan(0);
int targetHeight = targetGG.getGridRange2D().getSpan(1);
float[] output = new float[targetWidth * targetHeight];
Arrays.fill(output, Float.NaN);
float[] simpleResample(GridCoverage2D sourceGC, float[][] sourceData,
GridGeometry2D targetGG, String pfx, int minx, int miny) {
int sourceWidth = sourceGC.getGridGeometry().getGridRange2D()
.getSpan(0);
int sourceHeight = sourceGC.getGridGeometry().getGridRange2D()
.getSpan(1);
int targetWidth = targetGG.getGridRange2D().getSpan(0);
int targetHeight = targetGG.getGridRange2D().getSpan(1);
float[] output = new float[targetWidth * targetHeight];
Arrays.fill(output, Float.NaN);
ArrayList<MathTransform> transforms = new ArrayList<MathTransform>();
ArrayList<MathTransform> toGeoXforms = new ArrayList<MathTransform>();
ArrayList<MathTransform> sourceToGeoXforms = new ArrayList<MathTransform>();
ArrayList<MathTransform> transforms = new ArrayList<MathTransform>();
ArrayList<MathTransform> toGeoXforms = new ArrayList<MathTransform>();
ArrayList<MathTransform> sourceToGeoXforms = new ArrayList<MathTransform>();
MathTransform targetGtoCRS = targetGG.getGridToCRS(PixelInCell.CELL_CENTER);
MathTransform sourceCRStoG = sourceGC.getGridGeometry().getCRSToGrid2D(PixelOrientation.CENTER);
CoordinateReferenceSystem targetCRS = targetGG.getCoordinateReferenceSystem();
CoordinateReferenceSystem sourceCRS = sourceGC.getCoordinateReferenceSystem();
transforms.add(targetGtoCRS);
if (! CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
GeographicCRS sourceGeoCRS = null;
GeographicCRS targetGeoCRS = null;
if (sourceCRS instanceof ProjectedCRS) {
sourceGeoCRS = ((ProjectedCRS) sourceCRS).getBaseCRS();
}
if (targetCRS instanceof ProjectedCRS) {
targetGeoCRS = ((ProjectedCRS) targetCRS).getBaseCRS();
}
try {
transforms.add(CRS.findMathTransform(targetCRS, targetGeoCRS, true));
toGeoXforms.addAll(transforms);
if (CRS.equalsIgnoreMetadata(sourceGeoCRS, targetGeoCRS)) {
// nothing...
} else {
transforms.add(CRS.findMathTransform(targetGeoCRS, sourceGeoCRS));
}
transforms.add(CRS.findMathTransform(sourceGeoCRS, sourceCRS, true));
sourceToGeoXforms.add(0, CRS.findMathTransform(sourceCRS, sourceGeoCRS));
} catch (FactoryException e) {
// TODO: log
return output;
}
}
transforms.add(sourceCRStoG);
sourceToGeoXforms.add(0, sourceGC.getGridGeometry().getGridToCRS(PixelInCell.CELL_CENTER));
MathTransform targetGtoCRS = targetGG
.getGridToCRS(PixelInCell.CELL_CENTER);
MathTransform sourceCRStoG = sourceGC.getGridGeometry().getCRSToGrid2D(
PixelOrientation.CENTER);
CoordinateReferenceSystem targetCRS = targetGG
.getCoordinateReferenceSystem();
CoordinateReferenceSystem sourceCRS = sourceGC
.getCoordinateReferenceSystem();
transforms.add(targetGtoCRS);
if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
GeographicCRS sourceGeoCRS = null;
GeographicCRS targetGeoCRS = null;
if (sourceCRS instanceof ProjectedCRS) {
sourceGeoCRS = ((ProjectedCRS) sourceCRS).getBaseCRS();
}
if (targetCRS instanceof ProjectedCRS) {
targetGeoCRS = ((ProjectedCRS) targetCRS).getBaseCRS();
}
try {
transforms.add(CRS.findMathTransform(targetCRS, targetGeoCRS,
true));
toGeoXforms.addAll(transforms);
if (CRS.equalsIgnoreMetadata(sourceGeoCRS, targetGeoCRS)) {
// nothing...
} else {
transforms.add(CRS.findMathTransform(targetGeoCRS,
sourceGeoCRS));
}
transforms.add(CRS.findMathTransform(sourceGeoCRS, sourceCRS,
true));
sourceToGeoXforms.add(0,
CRS.findMathTransform(sourceCRS, sourceGeoCRS));
} catch (FactoryException e) {
// TODO: log
return output;
}
}
transforms.add(sourceCRStoG);
sourceToGeoXforms.add(0,
sourceGC.getGridGeometry()
.getGridToCRS(PixelInCell.CELL_CENTER));
MathTransform mt;
try {
mt = concatenateTransforms(transforms);
} catch (FactoryException e1) {
// TODO: log
return output;
}
double[] coord = new double[2];
/*
* Output index. Assumes we iterate top-left to bottom-right in
* row-major order.
*/
int oi = 0;
for (int y = 0; y < targetHeight; ++y) {
for (int x = 0; x < targetWidth; ++x, ++oi) {
coord[0] = x;
coord[1] = y;
try {
mt.transform(coord, 0, coord, 0, 1);
} catch (TransformException e) {
continue;
}
// Integer cell coordinates of upper-left cell of the 2x2 cell
// sample area
int sulx = (int) coord[0];
int suly = (int) coord[1];
double fx = coord[0] - sulx;
double fy = coord[1] - suly;
double tv = 0; // sum of weighted valid values
double tw = 0; // sum of valid weights
float v0;
double w0;
if (sulx >= 0 && suly >= 0 && sulx < sourceWidth - 1
&& suly < sourceHeight - 1) {
if (valid(v0 = fix(sourceData[suly][sulx]))) {
w0 = (1 - fx) * (1 - fy);
tv += v0 * w0;
tw += w0;
}
if (valid(v0 = fix(sourceData[suly][sulx + 1]))) {
w0 = (fx) * (1 - fy);
tv += v0 * w0;
tw += w0;
}
if (valid(v0 = fix(sourceData[suly + 1][sulx]))) {
w0 = (1 - fx) * (fy);
tv += v0 * w0;
tw += w0;
}
if (valid(v0 = fix(sourceData[suly + 1][sulx + 1]))) {
w0 = (fx) * (fy);
tv += v0 * w0;
tw += w0;
}
} else {
if (isValidCoord(sulx, suly, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly][sulx]))) {
w0 = (1 - fx) * (1 - fy);
tv += v0 * w0;
tw += w0;
}
if (isValidCoord(sulx + 1, suly, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly][sulx + 1]))) {
w0 = (fx) * (1 - fy);
tv += v0 * w0;
tw += w0;
}
if (isValidCoord(sulx, suly + 1, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly + 1][sulx]))) {
w0 = (1 - fx) * (fy);
tv += v0 * w0;
tw += w0;
}
if (isValidCoord(sulx + 1, suly + 1, sourceWidth,
sourceHeight)
&& valid(v0 = fix(sourceData[suly + 1][sulx + 1]))) {
w0 = (fx) * (fy);
tv += v0 * w0;
tw += w0;
}
}
if (tw != 0) {
output[oi] = (float) (tv / tw);
}
}
}
return output;
MathTransform mt;
try {
mt = concatenateTransforms(transforms);
} catch (FactoryException e1) {
// TODO: log
return output;
}
double[] coord = new double[2];
/*
* Output index. Assumes we iterate top-left to bottom-right in
* row-major order.
*/
int oi = 0;
for (int y = 0; y < targetHeight; ++y) {
for (int x = 0; x < targetWidth; ++x, ++oi) {
coord[0] = x;
coord[1] = y;
try {
mt.transform(coord, 0, coord, 0, 1);
} catch (TransformException e) {
continue;
}
// Integer cell coordinates of upper-left cell of the 2x2 cell sample area
int sulx = (int) coord[0];
int suly = (int) coord[1];
double fx = coord[0] - sulx;
double fy = coord[1] - suly;
double tv = 0; // sum of weighted valid values
double tw = 0; // sum of valid weights
float v0;
double w0;
if (sulx >= 0 && suly >= 0 && sulx < sourceWidth - 1
&& suly < sourceHeight - 1) {
if (valid(v0 = fix(sourceData[suly][sulx]))) {
w0 = (1-fx)*(1-fy);
tv += v0 * w0;
tw += w0;
}
if (valid(v0 = fix(sourceData[suly][sulx+1]))) {
w0 = (fx)*(1-fy);
tv += v0 * w0;
tw += w0;
}
if (valid(v0 = fix(sourceData[suly+1][sulx]))) {
w0 = (1-fx)*(fy);
tv += v0 * w0;
tw += w0;
}
if (valid(v0 = fix(sourceData[suly+1][sulx+1]))) {
w0 = (fx)*(fy);
tv += v0 * w0;
tw += w0;
}
} else {
if (isValidCoord(sulx, suly, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly][sulx]))) {
w0 = (1-fx)*(1-fy);
tv += v0 * w0;
tw += w0;
}
if (isValidCoord(sulx + 1, suly, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly][sulx+1]))) {
w0 = (fx)*(1-fy);
tv += v0 * w0;
tw += w0;
}
if (isValidCoord(sulx, suly + 1, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly+1][sulx]))) {
w0 = (1-fx)*(fy);
tv += v0 * w0;
tw += w0;
}
if (isValidCoord(sulx + 1, suly + 1, sourceWidth, sourceHeight)
&& valid(v0 = fix(sourceData[suly+1][sulx+1]))) {
w0 = (fx)*(fy);
tv += v0 * w0;
tw += w0;
}
}
if (tw != 0) {
output[oi] = (float) (tv / tw);
}
}
}
return output;
}
private static final boolean isValidCoord(int ulx, int uly, int nx, int ny) {
return ulx >= 0 && uly >= 0 && ulx < nx && uly < ny;
return ulx >= 0 && uly >= 0 && ulx < nx && uly < ny;
}
private static final boolean valid(float v) {
return ! Float.isNaN(v) && v > DATA_FILL;
return !Float.isNaN(v) && v > DATA_FILL;
}
// A1: passes N -9999 to test_grhi_remap, setting
// all source -9999 values to 0.
private static float fix(float v) {
return v > DATA_FILL ? v : 0;
return v > DATA_FILL ? v : 0;
}
private MathTransform concatenateTransforms(ArrayList<MathTransform> transforms) throws FactoryException {
Hints hints = new Hints();
final CoordinateOperationFactory factory =
ReferencingFactoryFinder.getCoordinateOperationFactory(hints);
final MathTransformFactory mtFactory;
if (factory instanceof AbstractCoordinateOperationFactory) {
mtFactory = ((AbstractCoordinateOperationFactory) factory).getMathTransformFactory();
} else {
mtFactory = ReferencingFactoryFinder.getMathTransformFactory(hints);
}
MathTransform mt = null;
for (MathTransform mti : transforms/*int i = 0; i < transforms.size(); ++i*/) {
if (mt == null)
mt = mti;
else {
mt = mtFactory.createConcatenatedTransform(mt, mti);
}
}
return mt != null ? mt : IdentityTransform.create(2);
private MathTransform concatenateTransforms(
ArrayList<MathTransform> transforms) throws FactoryException {
Hints hints = new Hints();
final CoordinateOperationFactory factory = ReferencingFactoryFinder
.getCoordinateOperationFactory(hints);
final MathTransformFactory mtFactory;
if (factory instanceof AbstractCoordinateOperationFactory) {
mtFactory = ((AbstractCoordinateOperationFactory) factory)
.getMathTransformFactory();
} else {
mtFactory = ReferencingFactoryFinder.getMathTransformFactory(hints);
}
MathTransform mt = null;
for (MathTransform mti : transforms/*
* int i = 0; i < transforms.size();
* ++i
*/) {
if (mt == null)
mt = mti;
else {
mt = mtFactory.createConcatenatedTransform(mt, mti);
}
}
return mt != null ? mt : IdentityTransform.create(2);
}
/**
* Reads the raw data from the topo files
*
@ -1116,11 +1138,11 @@ public class StaticTopoData {
Math.max(ll.getOrdinate(1), ur.getOrdinate(1)));
envelope.setCoordinateReferenceSystem(crs);
GridToEnvelopeMapper mapper = new GridToEnvelopeMapper();
mapper.setEnvelope(envelope);
mapper.setGridRange(new GeneralGridEnvelope(
new int[] { 1, 1 }, new int[] { nx, ny }, false));
mapper.setGridRange(new GeneralGridEnvelope(new int[] { 1, 1 },
new int[] { nx, ny }, false));
mapper.setPixelAnchor(PixelInCell.CELL_CENTER);
mapper.setReverseAxis(new boolean[] { false, true });
MathTransform mt = mapper.createTransform();

View file

@ -27,11 +27,10 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.edex.plugin.grib.spatial.GribSpatialCache;
import com.raytheon.edex.plugin.grib.util.DataFieldTableLookup;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
@ -129,16 +128,19 @@ public class GribParamTranslator {
* @param model
* The grib model object from the record
* @param dataTime
* The datatime of the grib data
* The datatime of the grib data the geospatial location of the
* grib data, if this model is being subgridded then this expects
* the full coverage, not the subgridded coverage.
* @return The translated grib parameter
*/
public String translateParameter(int gribVersion, GribModel model,
DataTime dataTime) {
public String translateParameter(int gribVersion, String parName,
int center, int subcenter, int genProcess, DataTime dataTime,
GridCoverage location) {
String parName = model.getParameterAbbreviation();
String pcs = parName + "_" + getGenProcess(model);
String centerName = getCenterName(model);
String subcenterName = getSubcenterName(model);
String pcs = parName + "_"
+ getGenProcess(center, subcenter, genProcess);
String centerName = getCenterName(center, subcenter);
String subcenterName = getSubcenterName(center, subcenter);
if (centerName != null && !centerName.equals("NONE")) {
pcs += "-" + centerName;
}
@ -147,15 +149,7 @@ public class GribParamTranslator {
pcs += "-" + subcenterName;
}
String dimstr = "";
GridCoverage location = model.getLocation();
if (location.isSubGridded()) {
GridCoverage fullCoverage = GribSpatialCache.getInstance()
.getGridByName(location.getParentGridName());
dimstr = "_" + fullCoverage.getNx() + "x" + fullCoverage.getNy();
} else {
dimstr = "_" + location.getNx() + "x" + location.getNy();
}
String dimstr = "_" + location.getNx() + "x" + location.getNy();
long duration = dataTime.getValidPeriod().getDuration() / 1000;
@ -205,49 +199,42 @@ public class GribParamTranslator {
/**
* Gets the name of the center for the parameter contained in the provided
* grib model object
* center and subcenter
*
* @param model
* The grib model object
* @param center
* @param subcenter
* @return The center name
*/
private String getCenterName(GribModel model) {
int center = model.getCenterid();
int subcenter = model.getSubcenterid();
private String getCenterName(int center, int subcenter) {
return (String) GribTableLookup.getInstance().getTableValue(center,
subcenter, "0", center);
}
/**
* Gets the name of the sub-center for the parameter contained in the
* provided grib model object
* provided center and subcenter
*
* @param model
* The grib model object
* @param center
* @param subcenter
* @return The sub-center name
*/
private String getSubcenterName(GribModel model) {
int center = model.getCenterid();
int subcenter = model.getSubcenterid();
private String getSubcenterName(int center, int subcenter) {
return (String) GribTableLookup.getInstance().getTableValue(center,
subcenter, "C-center" + center, subcenter);
}
/**
* Gets the name of the generating process contained in the provided grib
* model object
* center and subcenter
*
* @param model
* The grib model object
* @param center
* @param subcenter
* @return The generating process name
*/
private String getGenProcess(GribModel model) {
int center = model.getCenterid();
int subcenter = model.getSubcenterid();
private String getGenProcess(int center, int subcenter, int genProcess) {
return (String) GribTableLookup.getInstance().getTableValue(center,
subcenter, "A-center" + center, model.getGenprocess());
subcenter, "A-center" + center, genProcess);
}
/**

View file

@ -20,7 +20,8 @@ Require-Bundle: com.raytheon.uf.common.localization;bundle-version="1.11.24",
com.raytheon.edex.common;bundle-version="1.11.24",
javax.jms;bundle-version="1.0.0",
com.raytheon.edex.plugin.radar;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174"
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0"
Import-Package: com.raytheon.uf.common.dataplugin.radar,
com.raytheon.uf.common.dataplugin.radar.request,
com.raytheon.uf.common.ohd,

View file

@ -64,12 +64,12 @@ import com.raytheon.rcm.mqsrvr.ReqObj;
import com.raytheon.rcm.mqsrvr.ReqObj.SendMessageToRPG;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage;
import com.raytheon.uf.common.dataplugin.radar.RadarStation;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.TransformFactory;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LambertConformalGridCoverage;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.PathManagerFactory;

View file

@ -44,12 +44,12 @@ Import-Package: com.raytheon.edex.exception,
com.raytheon.uf.common.activetable,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.annotations,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.util,
com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.geospatial.interpolation,
com.raytheon.uf.common.geospatial.interpolation.data,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.localization,
com.raytheon.uf.common.localization.exception,
com.raytheon.uf.common.message,

View file

@ -39,7 +39,7 @@ import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DBit;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.time.TimeRange;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;

View file

@ -17,13 +17,12 @@ Require-Bundle: javax.measure,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.status,
com.raytheon.uf.common.localization
Import-Package: com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.geospatial
com.raytheon.uf.common.localization,
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0"
Export-Package: com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.exception,
com.raytheon.uf.common.dataplugin.grib.request,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.subgrid,
com.raytheon.uf.common.dataplugin.grib.util
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -1,9 +1,5 @@
com.raytheon.uf.common.dataplugin.grib.GribModel
com.raytheon.uf.common.dataplugin.grib.GribRecord
com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage
com.raytheon.uf.common.dataplugin.grib.spatial.projections.MercatorGridCoverage
com.raytheon.uf.common.dataplugin.grib.spatial.projections.PolarStereoGridCoverage
com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage
com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef
com.raytheon.uf.common.dataplugin.grib.util.GridModel
com.raytheon.uf.common.dataplugin.grib.util.GridModelSet

View file

@ -40,11 +40,11 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;

View file

@ -24,9 +24,9 @@ import java.util.Map;
import org.opengis.metadata.spatial.PixelOrientation;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.vividsolutions.jts.geom.Coordinate;
/**

View file

@ -21,10 +21,10 @@ package com.raytheon.uf.common.dataplugin.grib;
import org.opengis.metadata.spatial.PixelOrientation;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.Corner;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.Corner;
import com.raytheon.uf.common.gridcoverage.LambertConformalGridCoverage;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
import com.vividsolutions.jts.geom.Coordinate;
/**
@ -103,7 +103,7 @@ public class CoverageTest {
ll = MapUtil.gridCoordinateToLatLon(c, orient, cov);
System.out.println("grid cell: " + c + " lonLat: " + ll);
} catch (GribException e) {
} catch (GridCoverageException e) {
e.printStackTrace();
}
}

View 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>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.gridcoverage</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

@ -0,0 +1,8 @@
#Tue Jan 31 13:49:11 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

@ -0,0 +1,33 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Grid Coverage
Bundle-SymbolicName: com.raytheon.uf.common.gridcoverage
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Import-Package: com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.annotations,
com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.dataquery.requests,
com.raytheon.uf.common.dataquery.responses,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.annotations,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.status,
com.vividsolutions.jts.geom,
javax.measure.converter,
javax.measure.unit,
javax.persistence,
org.apache.commons.beanutils,
org.apache.commons.collections.map,
org.apache.commons.lang.builder,
org.hibernate.annotations
Export-Package: com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.gridcoverage.convert,
com.raytheon.uf.common.gridcoverage.exception,
com.raytheon.uf.common.gridcoverage.lookup,
com.raytheon.uf.common.gridcoverage.request,
com.raytheon.uf.common.gridcoverage.subgrid
Require-Bundle: org.geotools;bundle-version="2.6.4"

View file

@ -0,0 +1,4 @@
com.raytheon.uf.common.gridcoverage.LatLonGridCoverage
com.raytheon.uf.common.gridcoverage.MercatorGridCoverage
com.raytheon.uf.common.gridcoverage.PolarStereoGridCoverage
com.raytheon.uf.common.gridcoverage.LambertConformalGridCoverage

View file

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

View file

@ -17,30 +17,12 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
CREATE INDEX "gridCoverageType_idx"
ON gridcoverage
USING btree
(dtype);
package com.raytheon.edex.plugin.grib.dao;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.edex.database.DataAccessLayerException;
/**
* Interface implemented by grid coverage data access objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public interface IGridCoverageDao {
public GridCoverage checkGrid(GridCoverage grid)
throws DataAccessLayerException;
}
CREATE INDEX "gridCoverageNxNy_idx"
ON gridcoverage
USING btree
(nx, ny);

View file

@ -17,10 +17,10 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage;
/**
* TODO Add Description
* enum for starting corner of GridCoverages
*
* <pre>
*

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
@ -27,9 +27,13 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@ -42,13 +46,13 @@ import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.geospatial.CRSCache;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.vividsolutions.jts.geom.Geometry;
@ -71,29 +75,34 @@ import com.vividsolutions.jts.geom.Geometry;
* @version 1
*/
@Entity
@Table
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@SequenceGenerator(name = "GRIDCOVERAGE_GENERATOR", sequenceName = "gridcoverage_seq", allocationSize = 1)
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public abstract class GridCoverage extends PersistableDataObject implements
ISpatialObject {
private static final long serialVersionUID = -1355232934065074837L;
protected static final String SUBGRID_TOKEN = "-SubGrid-";
protected static final String SUBGRID_TOKEN = "SubGrid-";
public static final double SPATIAL_TOLERANCE = 0.1;
/** The id for this grid. This value is generated in the initialize method **/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GRIDCOVERAGE_GENERATOR")
@DynamicSerializeElement
protected int id;
protected Integer id;
/** The name of the grid */
@Column(length = 2047)
@Column
@XmlElement
@DynamicSerializeElement
@DataURI(position = 0)
protected String name;
/** A description of the grid coverage */
@Column(length = 3071)
@XmlElement
@DynamicSerializeElement
protected String description;
@ -198,7 +207,11 @@ public abstract class GridCoverage extends PersistableDataObject implements
@Override
public String toString() {
return "Coverage Information Not Specified yet";
if (id == 0) {
return "Coverage Information Not Specified yet";
} else {
return Integer.toString(id);
}
}
@Override
@ -214,9 +227,6 @@ public abstract class GridCoverage extends PersistableDataObject implements
*/
public int generateHash() {
HashCodeBuilder hashBuilder = new HashCodeBuilder();
if (getName() == null) {
generateName();
}
hashBuilder.append(name);
hashBuilder.append(nx);
hashBuilder.append(ny);
@ -233,10 +243,10 @@ public abstract class GridCoverage extends PersistableDataObject implements
* Initializes the grib coverage object. Initialization should entail
* creation of the crs and geometry object as well as assigning the id field
*
* @throws GribException
* @throws GridCoverageException
* If problems occur while creating the crs, geometry, or the id
*/
public abstract void initialize() throws GribException;
public abstract void initialize() throws GridCoverageException;
/**
* Gets the name of the projection. The projection type is specified by each
@ -246,12 +256,6 @@ public abstract class GridCoverage extends PersistableDataObject implements
*/
public abstract String getProjectionType();
/**
* If this grid coverage object describes a grid that is not predefined,
* this method is used to generate and assign a descriptive name.
*/
public abstract void generateName();
/**
* Trim this GridCoverage to a sub grid.
*
@ -259,7 +263,7 @@ public abstract class GridCoverage extends PersistableDataObject implements
* @param subGrid
* @return trimmed coverage
*/
public abstract GridCoverage trim(SubGridDef subGridDef, SubGrid subGrid);
public abstract GridCoverage trim(SubGrid subGrid);
public Geometry getGeometry() {
return geometry;
@ -282,7 +286,7 @@ public abstract class GridCoverage extends PersistableDataObject implements
*
* @return The id
*/
public int getId() {
public Integer getId() {
return id;
}
@ -292,7 +296,7 @@ public abstract class GridCoverage extends PersistableDataObject implements
* @param id
* The id
*/
public void setId(int id) {
public void setId(Integer id) {
this.id = id;
}
@ -401,14 +405,14 @@ public abstract class GridCoverage extends PersistableDataObject implements
this.lo1 = lo1;
}
public Double getLowerLeftLat() throws GribException {
public Double getLowerLeftLat() throws GridCoverageException {
if (lowerLeftLat == null) {
generateLowerLeft();
}
return lowerLeftLat;
}
public Double getLowerLeftLon() throws GribException {
public Double getLowerLeftLon() throws GridCoverageException {
if (lowerLeftLon == null) {
generateLowerLeft();
}
@ -490,7 +494,7 @@ public abstract class GridCoverage extends PersistableDataObject implements
/**
*
*/
protected void generateLowerLeft() throws GribException {
protected void generateLowerLeft() throws GridCoverageException {
try {
if ("degree".equals(spacingUnit)) {
switch (firstGridPointCorner) {
@ -520,7 +524,7 @@ public abstract class GridCoverage extends PersistableDataObject implements
lowerLeftLon = lo1;
} else {
if (getCrs() == null) {
throw new GribException("CRS is null.");
throw new GridCoverageException("CRS is null.");
}
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
@ -561,23 +565,23 @@ public abstract class GridCoverage extends PersistableDataObject implements
lowerLeftLon = lonLat[0];
lowerLeftLat = lonLat[1];
} else {
throw new GribException("Cannot converter " + spacingUnit
+ " to meters");
throw new GridCoverageException("Cannot convert "
+ spacingUnit + " to meters");
}
}
} catch (Exception e) {
throw new GribException(
throw new GridCoverageException(
"Cannot determine LowerLeft and UpperRight points of grid",
e);
}
lowerLeftLon = MapUtil.correctLon(lowerLeftLon);
lowerLeftLat = MapUtil.correctLat(lowerLeftLat);
}
protected void generateGeometry() throws GribException {
protected void generateGeometry() throws GridCoverageException {
if ("degree".equals(spacingUnit)) {
// lower left is cell center, we want cell corners.
double minLat = MapUtil.correctLat(getLowerLeftLat() - dy / 2);
// special case in data delivery
double minLat = getLowerLeftLat() - dy / 2;
double maxLat = minLat + dy * ny;
double minLon = getLowerLeftLon() - dx / 2;
if (dx * nx <= 360) {
@ -599,7 +603,7 @@ public abstract class GridCoverage extends PersistableDataObject implements
geometry = MapUtil.createGeometry(minLat, minLon, maxLat,
maxLon);
} catch (Exception e) {
throw new GribException("Error creating geometry", e);
throw new GridCoverageException("Error creating geometry", e);
}
} else {
try {
@ -611,11 +615,12 @@ public abstract class GridCoverage extends PersistableDataObject implements
getLowerLeftLon(), converter.convert(dx),
converter.convert(dy), nx, ny);
} else {
throw new GribException("Unable to convert " + spacingUnit
throw new GridCoverageException("Unable to convert "
+ spacingUnit
+ " to meters while creating geometry!");
}
} catch (Exception e) {
throw new GribException("Error creating geometry", e);
throw new GridCoverageException("Error creating geometry", e);
}
}
}
@ -671,27 +676,76 @@ public abstract class GridCoverage extends PersistableDataObject implements
return true;
}
public void determineFirstGridPointCorner(int scanMode) {
if ((scanMode & 128) > 0) {
// -i
if ((scanMode & 64) > 0) {
// +j
setFirstGridPointCorner(Corner.LowerRight);
} else {
// -j
setFirstGridPointCorner(Corner.UpperRight);
}
} else {
// +i
if ((scanMode & 64) > 0) {
// +j
setFirstGridPointCorner(Corner.LowerLeft);
} else {
// -j
setFirstGridPointCorner(Corner.UpperLeft);
}
/**
* Compare coverages to see if they are equivelant within a certain
* tolerance
*
* @param other
* @return true to indicate the coverages should be treated as equals, false
* if they are too different.
*/
public boolean spatialEquals(GridCoverage other) {
if (!this.getClass().equals(other.getClass())) {
return false;
}
if (nx == null) {
if (other.nx != null) {
return false;
}
} else if (!nx.equals(other.nx)) {
return false;
}
if (ny == null) {
if (other.ny != null) {
return false;
}
} else if (!ny.equals(other.ny)) {
return false;
}
if (spacingUnit == null) {
if (other.spacingUnit != null) {
return false;
}
} else if (!spacingUnit.equals(other.spacingUnit)) {
return false;
}
if (firstGridPointCorner != other.firstGridPointCorner) {
return false;
}
if (Math.abs(dx - other.dx) > SPATIAL_TOLERANCE) {
return false;
} else if (Math.abs(dy - other.dy) > SPATIAL_TOLERANCE) {
return false;
} else if (Math.abs(la1 - other.la1) > SPATIAL_TOLERANCE) {
return false;
} else if (Math.abs(MapUtil.correctLon(lo1)
- MapUtil.correctLon(other.lo1)) > SPATIAL_TOLERANCE) {
return false;
}
return true;
}
/**
* Unique key containing the spatial attributes of this coverage.
*
* @return
*/
public String spatialKey() {
StringBuilder key = new StringBuilder(96);
key.append(getProjectionType().replace(" ", "_"));
key.append(DataURI.SEPARATOR);
key.append(nx);
key.append(DataURI.SEPARATOR);
key.append(ny);
key.append(DataURI.SEPARATOR);
key.append(dx);
key.append(DataURI.SEPARATOR);
key.append(dy);
key.append(DataURI.SEPARATOR);
key.append(lo1);
key.append(DataURI.SEPARATOR);
key.append(la1);
return key.toString();
}
public GridCoverage(GridCoverage coverage) {
@ -717,48 +771,4 @@ public abstract class GridCoverage extends PersistableDataObject implements
this.includePole = coverage.includePole;
}
/**
* Determines if this coverage is a subGrid.
*
* @return
*/
public boolean isSubGridded() {
String subGridName = getName();
if (subGridName != null) {
return getName().contains(SUBGRID_TOKEN);
}
return false;
}
/**
* If this coverage is subGridded, return the model it is a subGrid for,
* else null.
*
* @return
*/
public String getSubGridModel() {
String model = null;
if (isSubGridded()) {
String subGridName = getName();
int index = subGridName.lastIndexOf(SUBGRID_TOKEN);
if (index >= 0 && index + SUBGRID_TOKEN.length() < subGridName.length()) {
model = subGridName.substring(index + SUBGRID_TOKEN.length());
}
}
return model;
}
public String getParentGridName() {
String parentName = null;
if (isSubGridded()) {
String subGridName = getName();
int index = subGridName.indexOf(SUBGRID_TOKEN);
if (index >= 0) {
parentName = subGridName.substring(0, index);
}
}
return parentName;
}
}

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
@ -34,11 +34,11 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.TrimUtil.Trim;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
import com.raytheon.uf.common.gridcoverage.subgrid.TrimUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -121,24 +121,15 @@ public class LambertConformalGridCoverage extends GridCoverage {
}
@Override
public void initialize() throws GribException {
public void initialize() throws GridCoverageException {
crs = MapUtil.constructLambertConformal(majorAxis, minorAxis, latin1,
latin2, lov);
crsWKT = crs.toWKT();
generateGeometry();
id = generateHash();
}
public void generateName() {
String nameAndDescription = "Unknown " + nx + " X " + ny + " "
+ Math.round(dx) + " " + spacingUnit + " "
+ getProjectionType() + " grid";
this.setName(nameAndDescription);
this.setDescription(nameAndDescription);
}
@Override
public GridCoverage trim(SubGridDef subGridDef, SubGrid subGrid) {
public GridCoverage trim(SubGrid subGrid) {
LambertConformalGridCoverage rval = new LambertConformalGridCoverage();
rval.description = this.description;
rval.dx = this.dx;
@ -150,8 +141,6 @@ public class LambertConformalGridCoverage extends GridCoverage {
rval.majorAxis = this.majorAxis;
rval.minorAxis = this.minorAxis;
rval.setName(this.name + SUBGRID_TOKEN + subGrid.getModelName());
try {
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
if (spacingUnitObj.isCompatible(SI.METRE)) {
@ -163,35 +152,26 @@ public class LambertConformalGridCoverage extends GridCoverage {
.getTransformFromLatLon(getCrs());
MathTransform toLatLon = fromLatLon.inverse();
Trim trim = null;
try {
trim = TrimUtil.trimMeterSpace(getLowerLeftLat(),
getLowerLeftLon(), subGridDef, this.nx, this.ny,
TrimUtil.trimMeterSpace(getLowerLeftLat(),
getLowerLeftLon(), subGrid, this.nx, this.ny,
dxMeter, dyMeter, fromLatLon, toLatLon, true);
} catch (GribException e) {
} catch (GridCoverageException e) {
statusHandler.handle(Priority.WARN, "Grib coverage ["
+ this.getName() + "] not applicable to this site");
return null;
}
subGrid.setUpperLeftX(trim.upperLeftX);
subGrid.setUpperLeftY(trim.upperLeftY);
subGrid.setNX(trim.nx);
subGrid.setNY(trim.ny);
rval.firstGridPointCorner = Corner.LowerLeft;
rval.lo1 = trim.lowerLeftLon;
rval.la1 = trim.lowerLeftLat;
rval.nx = trim.nx;
rval.ny = trim.ny;
rval.lo1 = subGrid.getLowerLeftLon();
rval.la1 = subGrid.getLowerLeftLat();
rval.nx = subGrid.getNX();
rval.ny = subGrid.getNY();
rval.setId(rval.hashCode());
rval.setName(SUBGRID_TOKEN + this.getId());
} else {
statusHandler.handle(
Priority.PROBLEM,
"Error creating sub grid definition ["
+ subGrid.getModelName()
statusHandler.handle(Priority.PROBLEM,
"Error creating sub grid definition [" + this.name
+ "], units are not compatible with meter ["
+ spacingUnit + "]");
rval = null;
@ -334,6 +314,34 @@ public class LambertConformalGridCoverage extends GridCoverage {
return true;
}
public boolean spatialEquals(GridCoverage other) {
if (super.spatialEquals(other)) {
LambertConformalGridCoverage otherLambert = (LambertConformalGridCoverage) other;
if (Math.abs(latin1 - otherLambert.latin1) > SPATIAL_TOLERANCE) {
return false;
} else if (Math.abs(latin2 - otherLambert.latin2) > SPATIAL_TOLERANCE) {
return false;
} else if (Math.abs(lov - otherLambert.lov) > SPATIAL_TOLERANCE) {
return false;
}
return true;
}
return false;
}
@Override
public String spatialKey() {
StringBuilder key = new StringBuilder(96);
key.append(super.spatialKey());
key.append(DataURI.SEPARATOR);
key.append(latin1);
key.append(DataURI.SEPARATOR);
key.append(latin2);
key.append(DataURI.SEPARATOR);
key.append(lov);
return key.toString();
}
public LambertConformalGridCoverage() {
super();
}

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -28,11 +28,10 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.TrimUtil.Trim;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
import com.raytheon.uf.common.gridcoverage.subgrid.TrimUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -91,7 +90,7 @@ public class LatLonGridCoverage extends GridCoverage {
private int[] parallels;
@Override
public void initialize() throws GribException {
public void initialize() throws GridCoverageException {
// lower left is cell center, we want cell corners.
double minLon = getLowerLeftLon() - dx / 2;
double maxLon = minLon + dx * nx;
@ -104,17 +103,6 @@ public class LatLonGridCoverage extends GridCoverage {
crsWKT = crs.toWKT();
generateGeometry();
id = generateHash();
}
@Override
public void generateName() {
String nameAndDescription = "Unknown " + nx + " X " + ny + " "
+ getProjectionType() + " grid";
this.setName(nameAndDescription);
this.setDescription(nameAndDescription);
}
@Override
@ -133,36 +121,26 @@ public class LatLonGridCoverage extends GridCoverage {
}
@Override
public GridCoverage trim(SubGridDef subGridDef, SubGrid subGrid) {
public GridCoverage trim(SubGrid subGrid) {
LatLonGridCoverage rval = new LatLonGridCoverage();
rval.description = this.description;
rval.dx = this.dx;
rval.dy = this.dy;
rval.spacingUnit = this.spacingUnit;
rval.setName(this.name + SUBGRID_TOKEN + subGrid.getModelName());
try {
if (spacingUnit.equals("degree")) {
Trim trim = TrimUtil.trimLatLonSpace(getLowerLeftLat(),
getLowerLeftLon(), subGridDef, this.nx, this.ny,
this.dx, this.dy);
subGrid.setUpperLeftX(trim.upperLeftX);
subGrid.setUpperLeftY(trim.upperLeftY);
subGrid.setNX(trim.nx);
subGrid.setNY(trim.ny);
TrimUtil.trimLatLonSpace(getLowerLeftLat(), getLowerLeftLon(),
subGrid, this.nx, this.ny, this.dx, this.dy);
rval.firstGridPointCorner = Corner.LowerLeft;
rval.lo1 = trim.lowerLeftLon;
rval.la1 = trim.lowerLeftLat;
rval.nx = trim.nx;
rval.ny = trim.ny;
rval.setId(rval.hashCode());
rval.lo1 = subGrid.getLowerLeftLon();
rval.la1 = subGrid.getLowerLeftLat();
rval.nx = subGrid.getNX();
rval.ny = subGrid.getNY();
rval.setName(SUBGRID_TOKEN + this.getId());
} else {
throw new GribException(
throw new GridCoverageException(
"SubGridding a lat/lon grid not in lat lon spacing is unimplemented");
}
} catch (Exception e) {

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
@ -36,11 +36,11 @@ import org.geotools.geometry.DirectPosition2D;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.TrimUtil.Trim;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
import com.raytheon.uf.common.gridcoverage.subgrid.TrimUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -121,7 +121,7 @@ public class MercatorGridCoverage extends GridCoverage {
}
@Override
public void initialize() throws GribException {
public void initialize() throws GridCoverageException {
double meridian = 0;
if (la2 == null || lo2 == null) {
initializeSecondCorner();
@ -157,11 +157,9 @@ public class MercatorGridCoverage extends GridCoverage {
crs = MapUtil.constructMercator(majorAxis, minorAxis, latin, meridian);
crsWKT = crs.toWKT();
generateGeometry();
id = generateHash();
}
private void initializeSecondCorner() throws GribException {
private void initializeSecondCorner() throws GridCoverageException {
// Since the CRS has not been produced yet, we create a dummy CRS for
// calculation purposes
@ -203,7 +201,7 @@ public class MercatorGridCoverage extends GridCoverage {
firstPosition.y - dy * ny);
break;
default:
throw new GribException(
throw new GridCoverageException(
"Inavalid grid point corner specified: "
+ this.firstGridPointCorner);
}
@ -213,22 +211,13 @@ public class MercatorGridCoverage extends GridCoverage {
lo2 = cornerPosition.x;
la2 = cornerPosition.y;
} catch (Exception e) {
throw new GribException(
throw new GridCoverageException(
"Error calculating la2/lo2 for mercator projection!", e);
}
}
@Override
public void generateName() {
String nameAndDescription = "Unknown " + nx + " X " + ny + " "
+ Math.round(dx) + " " + spacingUnit + " "
+ getProjectionType() + " grid";
this.setName(nameAndDescription);
this.setDescription(nameAndDescription);
}
@Override
public GridCoverage trim(SubGridDef subGridDef, SubGrid subGrid) {
public GridCoverage trim(SubGrid subGrid) {
MercatorGridCoverage rval = new MercatorGridCoverage();
rval.description = this.description;
rval.dx = this.dx;
@ -237,7 +226,6 @@ public class MercatorGridCoverage extends GridCoverage {
rval.latin = this.latin;
rval.majorAxis = this.majorAxis;
rval.minorAxis = this.minorAxis;
rval.setName(this.name + SUBGRID_TOKEN + subGrid.getModelName());
try {
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
@ -250,37 +238,27 @@ public class MercatorGridCoverage extends GridCoverage {
.getTransformFromLatLon(getCrs());
MathTransform toLatLon = fromLatLon.inverse();
Trim trim = null;
try {
trim = TrimUtil.trimMeterSpace(getLowerLeftLat(),
getLowerLeftLon(), subGridDef, this.nx, this.ny,
TrimUtil.trimMeterSpace(getLowerLeftLat(),
getLowerLeftLon(), subGrid, this.nx, this.ny,
dxMeter, dyMeter, fromLatLon, toLatLon, true);
} catch (GribException e) {
} catch (GridCoverageException e) {
statusHandler.handle(Priority.WARN, "Grib coverage ["
+ this.getName() + "] not applicable to this site");
return null;
}
subGrid.setUpperLeftX(trim.upperLeftX);
subGrid.setUpperLeftY(trim.upperLeftY);
subGrid.setNX(trim.nx);
subGrid.setNY(trim.ny);
rval.firstGridPointCorner = Corner.LowerLeft;
rval.lo1 = trim.lowerLeftLon;
rval.la1 = trim.lowerLeftLat;
rval.lo2 = trim.upperRightLon;
rval.la2 = trim.upperRightLat;
rval.nx = trim.nx;
rval.ny = trim.ny;
rval.setId(rval.hashCode());
rval.lo1 = subGrid.getLowerLeftLon();
rval.la1 = subGrid.getLowerLeftLat();
rval.lo2 = subGrid.getUpperRightLon();
rval.la2 = subGrid.getUpperRightLat();
rval.nx = subGrid.getNX();
rval.ny = subGrid.getNY();
rval.setName(SUBGRID_TOKEN + this.getId());
} else {
statusHandler.handle(
Priority.PROBLEM,
"Error creating sub grid definition ["
+ subGrid.getModelName()
statusHandler.handle(Priority.PROBLEM,
"Error creating sub grid definition [" + this.name
+ "], units are not compatible with meter ["
+ spacingUnit + "]");
rval = null;
@ -396,6 +374,26 @@ public class MercatorGridCoverage extends GridCoverage {
return true;
}
public boolean spatialEquals(GridCoverage other) {
if (super.spatialEquals(other)) {
MercatorGridCoverage otherMercator = (MercatorGridCoverage) other;
if (Math.abs(latin - otherMercator.latin) > SPATIAL_TOLERANCE) {
return false;
}
return true;
}
return false;
}
@Override
public String spatialKey() {
StringBuilder key = new StringBuilder(96);
key.append(super.spatialKey());
key.append(DataURI.SEPARATOR);
key.append(latin);
return key.toString();
}
public MercatorGridCoverage() {
}

View file

@ -18,7 +18,7 @@
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.SI;
@ -34,11 +34,11 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.TrimUtil.Trim;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGrid;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
import com.raytheon.uf.common.gridcoverage.subgrid.SubGrid;
import com.raytheon.uf.common.gridcoverage.subgrid.TrimUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
@ -110,23 +110,14 @@ public class PolarStereoGridCoverage extends GridCoverage {
}
@Override
public void initialize() throws GribException {
public void initialize() throws GridCoverageException {
crs = MapUtil.constructNorthPolarStereo(majorAxis, minorAxis, lad, lov);
crsWKT = crs.toWKT();
generateGeometry();
id = generateHash();
}
public void generateName() {
String nameAndDescription = "Unknown " + nx + " X " + ny + " "
+ Math.round(dx) + " " + spacingUnit + " "
+ getProjectionType() + " grid";
this.setName(nameAndDescription);
this.setDescription(nameAndDescription);
}
@Override
public GridCoverage trim(SubGridDef subGridDef, SubGrid subGrid) {
public GridCoverage trim(SubGrid subGrid) {
PolarStereoGridCoverage rval = new PolarStereoGridCoverage();
rval.description = this.description;
rval.dx = this.dx;
@ -135,7 +126,6 @@ public class PolarStereoGridCoverage extends GridCoverage {
rval.lov = this.lov;
rval.majorAxis = this.majorAxis;
rval.minorAxis = this.minorAxis;
rval.setName(this.name + SUBGRID_TOKEN + subGrid.getModelName());
try {
Unit<?> spacingUnitObj = Unit.valueOf(spacingUnit);
@ -149,35 +139,25 @@ public class PolarStereoGridCoverage extends GridCoverage {
MathTransform toLatLon = fromLatLon.inverse();
// don't check world wrap on a polar stereo grid
Trim trim = null;
try {
trim = TrimUtil.trimMeterSpace(getLowerLeftLat(),
getLowerLeftLon(), subGridDef, this.nx, this.ny,
TrimUtil.trimMeterSpace(getLowerLeftLat(),
getLowerLeftLon(), subGrid, this.nx, this.ny,
dxMeter, dyMeter, fromLatLon, toLatLon, false);
} catch (GribException e) {
} catch (GridCoverageException e) {
statusHandler.handle(Priority.WARN, "Grib coverage ["
+ this.getName() + "] not applicable to this site");
return null;
}
subGrid.setUpperLeftX(trim.upperLeftX);
subGrid.setUpperLeftY(trim.upperLeftY);
subGrid.setNX(trim.nx);
subGrid.setNY(trim.ny);
rval.firstGridPointCorner = Corner.LowerLeft;
rval.lo1 = trim.lowerLeftLon;
rval.la1 = trim.lowerLeftLat;
rval.nx = trim.nx;
rval.ny = trim.ny;
rval.setId(rval.hashCode());
rval.lo1 = subGrid.getLowerLeftLon();
rval.la1 = subGrid.getLowerLeftLat();
rval.nx = subGrid.getNX();
rval.ny = subGrid.getNY();
rval.setName(SUBGRID_TOKEN + this.getId());
} else {
statusHandler.handle(
Priority.PROBLEM,
"Error creating sub grid definition ["
+ subGrid.getModelName()
statusHandler.handle(Priority.PROBLEM,
"Error creating sub grid definition [" + this.name
+ "], units are not compatible with meter ["
+ spacingUnit + "]");
rval = null;
@ -312,6 +292,30 @@ public class PolarStereoGridCoverage extends GridCoverage {
return true;
}
public boolean spatialEquals(GridCoverage other) {
if (super.spatialEquals(other)) {
PolarStereoGridCoverage otherPolar = (PolarStereoGridCoverage) other;
if (Math.abs(lad - otherPolar.lad) > SPATIAL_TOLERANCE) {
return false;
} else if (Math.abs(lov - otherPolar.lov) > SPATIAL_TOLERANCE) {
return false;
}
return true;
}
return false;
}
@Override
public String spatialKey() {
StringBuilder key = new StringBuilder(96);
key.append(super.spatialKey());
key.append(DataURI.SEPARATOR);
key.append(lov);
key.append(DataURI.SEPARATOR);
key.append(lad);
return key.toString();
}
public PolarStereoGridCoverage() {
}

View file

@ -0,0 +1,76 @@
/**
* 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.gridcoverage.convert;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.lookup.GridCoverageLookup;
/**
* Convert an integer or a string representing a grid coverage id to a grid
* coverage using the GridCoverageLookup.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridCoverageConverter implements Converter {
@Override
@SuppressWarnings("rawtypes")
public GridCoverage convert(Class clazz, Object value) {
Integer intValue = null;
if (value instanceof Integer) {
intValue = (Integer) value;
} else if (value instanceof String) {
try {
intValue = Integer.parseInt((String) value);
} catch (NumberFormatException e) {
;// ignore and throw conversion exception later.
}
}
if (intValue != null) {
GridCoverage result = GridCoverageLookup.getInstance().getCoverage(
intValue);
if (result != null) {
return result;
}
throw new ConversionException(
"Cannot find GridCoverage with id of "
+ String.valueOf(intValue));
}
throw new ConversionException("Cannot convert " + String.valueOf(value)
+ " of type " + value.getClass().getSimpleName()
+ " to a GridCoverage.");
}
}

View file

@ -0,0 +1,71 @@
/**
* 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.gridcoverage.exception;
import com.raytheon.uf.common.dataplugin.PluginException;
/**
*
* An exception that occurs when there are errors intializing grid coverages.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 31, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridCoverageException extends PluginException {
/**
* Default serial version id
*/
private static final long serialVersionUID = 1L;
/**
* Parser exception set with a cause.
*
* @param aCause
* The cause of the exception
*/
public GridCoverageException(String aCause) {
super(aCause);
}
/**
* Parser exception set with a cause and an existing exception. Used for
* exception chaining to preserve state.
*
* @param aCause
* The cause of the exception
* @param anException
* The exception object
*/
public GridCoverageException(String aCause, Exception anException) {
super(aCause, anException);
}
}

View file

@ -0,0 +1,144 @@
/**
* 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.gridcoverage.lookup;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.request.GetGridCoverageRequest;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Caching and convenience for finding coverages in the Database.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 12, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridCoverageLookup {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GridCoverageLookup.class);
private static GridCoverageLookup instance;
public static GridCoverageLookup getInstance() {
if (instance == null) {
instance = new GridCoverageLookup();
}
return instance;
}
// Maps id to coverage, this is a mirror of what is in the database.
private Map<Integer, GridCoverage> idToCoverage;
private Map<GridCoverage, Integer> coverageToId;
private GridCoverageLookup() {
initializeMaps();
DbQueryRequest query = new DbQueryRequest();
query.setEntityClass(GridCoverage.class.getName());
try {
DbQueryResponse resp = (DbQueryResponse) RequestRouter.route(query);
for (Map<String, Object> map : resp.getResults()) {
GridCoverage coverage = (GridCoverage) map.get(null);
coverageToId.put(coverage, coverage.getId());
idToCoverage.put(coverage.getId(), coverage);
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving coverages from server.", e);
}
}
private void initializeMaps() {
idToCoverage = Collections
.synchronizedMap(new HashMap<Integer, GridCoverage>());
coverageToId = Collections
.synchronizedMap(new GridCoverageSpatialMap());
}
public GridCoverage getCoverage(int id) {
GridCoverage result = idToCoverage.get(id);
if (result != null) {
return result;
}
HashMap<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
constraints.put("id", new RequestConstraint(Integer.toString(id)));
DbQueryRequest query = new DbQueryRequest();
query.setConstraints(constraints);
query.setEntityClass(GridCoverage.class.getName());
try {
DbQueryResponse resp = (DbQueryResponse) RequestRouter.route(query);
if (!resp.getResults().isEmpty()) {
result = (GridCoverage) resp.getResults().get(0).get(null);
if (result != null) {
coverageToId.put(result, result.getId());
idToCoverage.put(result.getId(), result);
}
return result;
}
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,
"Error occurred retrieving GridCoverage information from server.",
e);
}
return null;
}
public GridCoverage getCoverage(GridCoverage coverage, boolean create) {
Integer id = coverageToId.get(coverage);
if (id != null) {
return getCoverage(id);
}
try {
GridCoverage result = (GridCoverage) RequestRouter
.route(new GetGridCoverageRequest(coverage, create));
if (result != null) {
coverageToId.put(result, result.getId());
idToCoverage.put(result.getId(), result);
}
return result;
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error occured checking GridCoverage.", e);
}
return null;
}
}

View file

@ -0,0 +1,201 @@
/**
* 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.gridcoverage.lookup;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
/**
* A map for GridCoverages that does not require them to be completely equal but
* instead uses the spatialEquals, also uses softreferences to coverages, so
* entries may dissappear if memory is needed.
*
* This map is not thread safe and must be externally synchronized.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 7, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridCoverageSpatialMap implements Map<GridCoverage, Integer> {
private static class GridCoverageSpatialKey extends
SoftReference<GridCoverage> {
private final int hash;
public GridCoverageSpatialKey(GridCoverage coverage,
ReferenceQueue<GridCoverage> q) {
super(coverage, q);
HashCodeBuilder hashBuilder = new HashCodeBuilder();
hashBuilder.append(coverage.getProjectionType());
hashBuilder.append(coverage.getNx());
hashBuilder.append(coverage.getNy());
// this hash is not very unique and will lead to a fairly large
// number of collisions under some circumstances, the hashmap should
// be able to handle these collisions so there won't be errors and
// hopefully the performance loss due to bad hashing is negligible,
// but this may require further testing.
hash = hashBuilder.toHashCode();
}
@Override
public int hashCode() {
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
} else if (obj instanceof GridCoverageSpatialKey) {
GridCoverage thisCoverage = this.get();
GridCoverage otherCoverage = ((GridCoverageSpatialKey) obj)
.get();
return thisCoverage != null && otherCoverage != null
&& thisCoverage.spatialEquals(otherCoverage);
}
return false;
}
}
private Map<GridCoverageSpatialKey, Integer> internalMap = new HashMap<GridCoverageSpatialKey, Integer>();
private ReferenceQueue<GridCoverage> refQueue = new ReferenceQueue<GridCoverage>();
@Override
public int size() {
clearStaleReferences();
return internalMap.size();
}
@Override
public boolean isEmpty() {
clearStaleReferences();
return internalMap.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return get(key) != null;
}
@Override
public boolean containsValue(Object value) {
clearStaleReferences();
return internalMap.containsValue(value);
}
@Override
public Integer get(Object key) {
if (!(key instanceof GridCoverage)) {
return null;
}
clearStaleReferences();
GridCoverageSpatialKey coverageKey = new GridCoverageSpatialKey(
(GridCoverage) key, null);
return internalMap.get(coverageKey);
}
@Override
public Integer put(GridCoverage key, Integer value) {
clearStaleReferences();
GridCoverageSpatialKey coverageKey = new GridCoverageSpatialKey(key,
refQueue);
return internalMap.put(coverageKey, value);
}
@Override
public Integer remove(Object key) {
if (!(key instanceof GridCoverage)) {
return null;
}
clearStaleReferences();
GridCoverageSpatialKey coverageKey = new GridCoverageSpatialKey(
(GridCoverage) key, null);
return internalMap.remove(coverageKey);
}
@Override
public void putAll(Map<? extends GridCoverage, ? extends Integer> m) {
for (Entry<? extends GridCoverage, ? extends Integer> entry : m
.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
}
@Override
public void clear() {
internalMap.clear();
}
/**
* this method is not implemented
*/
@Override
public Set<GridCoverage> keySet() {
// TODO in order to fully comply with the map API this method should be
// implemented
return null;
}
@Override
public Collection<Integer> values() {
clearStaleReferences();
return internalMap.values();
}
/**
* this method is not implemented
*/
@Override
public Set<Entry<GridCoverage, Integer>> entrySet() {
// TODO in order to fully comply with the map API this method should be
// implemented
return null;
}
private void clearStaleReferences() {
GridCoverageSpatialKey key = (GridCoverageSpatialKey) refQueue.poll();
while (key != null) {
internalMap.remove(key);
key = (GridCoverageSpatialKey) refQueue.poll();
}
}
}

View file

@ -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.gridcoverage.request;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
* Request to lookup a grid coverage that is spatially equivelant to the
* provided coverage, also provides option for creating the coverage in the
* database if it does not already exist.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@DynamicSerialize
public class GetGridCoverageRequest implements IServerRequest {
@DynamicSerializeElement
private GridCoverage coverage;
@DynamicSerializeElement
private boolean create = false;
public GetGridCoverageRequest() {
}
public GetGridCoverageRequest(GridCoverage coverage) {
this.coverage = coverage;
this.create = false;
}
public GetGridCoverageRequest(GridCoverage coverage, boolean create) {
this.coverage = coverage;
this.create = create;
}
public GridCoverage getCoverage() {
return coverage;
}
public void setCoverage(GridCoverage coverage) {
this.coverage = coverage;
}
public boolean getCreate() {
return create;
}
public void setCreate(boolean create) {
this.create = create;
}
}

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.subgrid;
package com.raytheon.uf.common.gridcoverage.subgrid;
/**
* A sub grid definition
@ -35,8 +35,6 @@ package com.raytheon.uf.common.dataplugin.grib.subgrid;
* @version 1.0
*/
public class SubGrid {
/** The model name */
private String modelName;
/** the upper left x the subgrid will start with */
private int upperLeftX;
@ -50,13 +48,17 @@ public class SubGrid {
/** the height of the sub grid */
private int nY;
public String getModelName() {
return modelName;
}
/** lower left latitude of the subgrid area */
private double lowerLeftLat;
public void setModelName(String modelName) {
this.modelName = modelName;
}
/** lower left longitude of the subgrid area */
private double lowerLeftLon;
/** upper right latitude of the subgrid area */
private double upperRightLat;
/** upper right longitude of the subgrid area */
private double upperRightLon;
public int getUpperLeftX() {
return upperLeftX;
@ -89,4 +91,37 @@ public class SubGrid {
public void setNY(int ny) {
nY = ny;
}
public double getLowerLeftLat() {
return lowerLeftLat;
}
public void setLowerLeftLat(double lowerLeftLat) {
this.lowerLeftLat = lowerLeftLat;
}
public double getLowerLeftLon() {
return lowerLeftLon;
}
public void setLowerLeftLon(double lowerLeftLon) {
this.lowerLeftLon = lowerLeftLon;
}
public double getUpperRightLat() {
return upperRightLat;
}
public void setUpperRightLat(double upperRightLat) {
this.upperRightLat = upperRightLat;
}
public double getUpperRightLon() {
return upperRightLon;
}
public void setUpperRightLon(double upperRightLon) {
this.upperRightLon = upperRightLon;
}
}

View file

@ -17,16 +17,15 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.dataplugin.grib.spatial.projections;
package com.raytheon.uf.common.gridcoverage.subgrid;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
import com.raytheon.uf.common.dataplugin.grib.subgrid.SubGridDef;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
/**
* TODO Add Description
* Provides utility methods for trimming grids into subgrids.
*
* <pre>
*
@ -42,29 +41,28 @@ import com.raytheon.uf.common.geospatial.MapUtil;
*/
public class TrimUtil {
static class Trim {
public int nx;
public int ny;
public double lowerLeftLat;
public double lowerLeftLon;
public double upperRightLat;
public double upperRightLon;
public int upperLeftX;
public int upperLeftY;
}
public static Trim trimMeterSpace(double parentLLLat, double parentLLLon,
SubGridDef subGrid, int nx, int ny, double dxMeter, double dyMeter,
/**
* Uses the lat/lon values in subGrid to calculate a valid overlapping area
* to the parent grid and then sets the nx,ny and the lower Left x and y in
* the subgrid object.
*
* @param parentLLLat
* @param parentLLLon
* @param subGrid
* @param nx
* @param ny
* @param dxMeter
* @param dyMeter
* @param fromLatLon
* @param toLatLon
* @param checkGridWrap
* @throws Exception
*/
public static void trimMeterSpace(double parentLLLat, double parentLLLon,
SubGrid subGrid, int nx, int ny, double dxMeter, double dyMeter,
MathTransform fromLatLon, MathTransform toLatLon,
boolean checkGridWrap) throws Exception {
Trim rval = new Trim();
double[] lonLats = new double[8];
double[] lonLatsInMeters = new double[8];
lonLats[0] = parentLLLon;
@ -115,7 +113,7 @@ public class TrimUtil {
lonLatsInMeters[6] = lonLatsInMeters[2];
}
if (lonLatsInMeters[6] < lonLatsInMeters[4]) {
throw new GribException(
throw new GridCoverageException(
"Model does not contain area defined by sub grid.");
}
}
@ -134,40 +132,53 @@ public class TrimUtil {
lonLatsInMeters[5] = lonLatsInMeters[1] + (ny - lowerY) * dyMeter;
// determine number points, round down to be inside sub grid, inclusive
rval.nx = (int) ((lonLatsInMeters[6] - lonLatsInMeters[4]) / dxMeter) + 1;
rval.ny = (int) ((lonLatsInMeters[7] - lonLatsInMeters[5]) / dyMeter) + 1;
subGrid.setNX((int) ((lonLatsInMeters[6] - lonLatsInMeters[4]) / dxMeter) + 1);
subGrid.setNY((int) ((lonLatsInMeters[7] - lonLatsInMeters[5]) / dyMeter) + 1);
// just double check possible rounding error, in case of using
// subgridding to shift a world wide grid
if (rval.nx > nx) {
rval.nx = nx;
if (subGrid.getNX() > nx) {
subGrid.setNX(nx);
}
if (rval.ny > ny) {
rval.ny = ny;
if (subGrid.getNY() > ny) {
subGrid.setNY(ny);
}
// sub gridding needs the upper left x/y to pull out the data
// X/Y is 0/0 at UR and NX/NY at LL
rval.upperLeftX = leftX;
rval.upperLeftY = lowerY - rval.ny;
subGrid.setUpperLeftX(leftX);
subGrid.setUpperLeftY(lowerY - subGrid.getNY());
// determine exact UR in meter
lonLatsInMeters[6] = lonLatsInMeters[4] + (rval.nx - 1) * dxMeter;
lonLatsInMeters[7] = lonLatsInMeters[5] + (rval.ny - 1) * dyMeter;
lonLatsInMeters[6] = lonLatsInMeters[4] + (subGrid.getNX() - 1)
* dxMeter;
lonLatsInMeters[7] = lonLatsInMeters[5] + (subGrid.getNY() - 1)
* dyMeter;
toLatLon.transform(lonLatsInMeters, 4, lonLats, 4, 1);
rval.lowerLeftLon = MapUtil.correctLon(lonLats[4]);
rval.lowerLeftLat = MapUtil.correctLat(lonLats[5]);
rval.upperRightLon = MapUtil.correctLon(lonLats[6]);
rval.upperRightLat = MapUtil.correctLat(lonLats[7]);
return rval;
subGrid.setLowerLeftLon(MapUtil.correctLon(lonLats[4]));
subGrid.setLowerLeftLat(MapUtil.correctLat(lonLats[5]));
subGrid.setUpperRightLon(MapUtil.correctLon(lonLats[6]));
subGrid.setUpperRightLat(MapUtil.correctLat(lonLats[7]));
}
public static Trim trimLatLonSpace(double parentLLLat, double parentLLLon,
SubGridDef subGrid, int nx, int ny, double dx, double dy)
/**
* Uses the lat/lon values in subGrid to calculate a valid overlapping area
* to the parent grid and then sets the nx,ny and the lower Left x and y in
* the subgrid object.
*
* @param parentLLLat
* @param parentLLLon
* * @param subGrid
* @param nx
* @param ny
* @param dx
* @param dy
* @throws Exception
*/
public static void trimLatLonSpace(double parentLLLat, double parentLLLon,
SubGrid subGrid, int nx, int ny, double dx, double dy)
throws Exception {
Trim rval = new Trim();
double lonLats[] = new double[8];
lonLats[0] = parentLLLon;
@ -217,37 +228,35 @@ public class TrimUtil {
lonLats[5] = lonLats[1] + (ny - lowerY) * dy;
// determine number points, round up and inclusive
rval.nx = (int) ((lonLats[6] - lonLats[4]) / dx + 0.5) + 1;
rval.ny = (int) ((lonLats[7] - lonLats[5]) / dy + 0.5) + 1;
subGrid.setNX((int) ((lonLats[6] - lonLats[4]) / dx + 0.5) + 1);
subGrid.setNY((int) ((lonLats[7] - lonLats[5]) / dy + 0.5) + 1);
// just double check possible rounding error, in case of using
// subgridding to shift a world wide grid
if (rval.nx > nx) {
rval.nx = nx;
if (subGrid.getNX() > nx) {
subGrid.setNX(nx);
}
if (rval.ny > ny) {
rval.ny = ny;
if (subGrid.getNY() > ny) {
subGrid.setNY(ny);
}
// sub gridding needs the upper left x/y to pull out the data
// X/Y is 0/0 at UR and NX/NY at LL
rval.upperLeftX = leftX;
rval.upperLeftY = lowerY - rval.ny;
subGrid.setUpperLeftX(leftX);
subGrid.setUpperLeftY(lowerY - subGrid.getNY());
// determine exact UR
lonLats[6] = lonLats[4] + (rval.nx - 1) * dx;
lonLats[7] = lonLats[5] + (rval.ny - 1) * dy;
lonLats[6] = lonLats[4] + (subGrid.getNX() - 1) * dx;
lonLats[7] = lonLats[5] + (subGrid.getNY() - 1) * dy;
rval.lowerLeftLon = MapUtil.correctLon(lonLats[4]);
rval.lowerLeftLat = MapUtil.correctLat(lonLats[5]);
rval.upperRightLon = MapUtil.correctLon(lonLats[6]);
rval.upperRightLat = MapUtil.correctLat(lonLats[7]);
return rval;
subGrid.setLowerLeftLon(MapUtil.correctLon(lonLats[4]));
subGrid.setLowerLeftLat(MapUtil.correctLat(lonLats[5]));
subGrid.setUpperRightLon(MapUtil.correctLon(lonLats[6]));
subGrid.setUpperRightLat(MapUtil.correctLat(lonLats[7]));
}
private static void validateLongitudes(double lonLats[])
throws GribException {
throws GridCoverageException {
// check > 180 and wrap back around
if (lonLats[2] > 180) {
lonLats[2] -= 360;
@ -282,7 +291,7 @@ public class TrimUtil {
// verify LL is before UR of parent
if (lonLats[4] > lonLats[2]) {
// invalid grid
throw new GribException(
throw new GridCoverageException(
"Model does not contain area defined by sub grid.");
}
@ -302,7 +311,7 @@ public class TrimUtil {
// verify UR is after LL of parent
if (lonLats[6] < lonLats[0]) {
// invalid grid
throw new GribException(
throw new GridCoverageException(
"Model does not contain area defined by sub grid.");
}

View file

@ -14,7 +14,7 @@
<constructor-arg value="com.raytheon.uf.common.geospatial.request.SpatialDbQueryRequest"/>
<constructor-arg ref="querySpatialData"/>
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<bean id="queryDataRegistered" factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataquery.requests.DbQueryRequest"/>
<constructor-arg ref="queryData"/>
</bean>

View file

@ -31,4 +31,18 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.gridcoverage"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.edex.gridcoverage"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View 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>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.edex.gridcoverage</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

@ -0,0 +1,8 @@
#Tue Jan 31 14:13:40 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

@ -0,0 +1,23 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Grid Coverage
Bundle-SymbolicName: com.raytheon.uf.edex.gridcoverage
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.edex.db.dao,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.gridcoverage.exception,
com.raytheon.uf.common.gridcoverage.lookup,
com.raytheon.uf.common.gridcoverage.request,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.status,
com.raytheon.uf.edex.database.dao,
org.hibernate,
org.hibernate.criterion,
org.springframework.orm.hibernate3.support
Export-Package: com.raytheon.uf.edex.gridcoverage

View file

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

View file

@ -0,0 +1,45 @@
<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="getGridCoverageHandler"
class="com.raytheon.uf.edex.gridcoverage.GetGridCoverageHandler" />
<bean id="getGridCoverageHandlerRegistered" factory-bean="handlerRegistry"
factory-method="register" depends-on="gridcoverageRegistered">
<constructor-arg
value="com.raytheon.uf.common.gridcoverage.request.GetGridCoverageRequest" />
<constructor-arg ref="getGridCoverageHandler" />
</bean>
<bean id="gridcoverageProperties" class="com.raytheon.uf.edex.database.DatabasePluginProperties">
<property name="pluginName" value="gridcoverage" />
<property name="pluginFQN" value="com.raytheon.uf.common.gridcoverage" />
<property name="database" value="metadata" />
</bean>
<bean id="gridcoverageConverterRegistered" class="com.raytheon.uf.common.dataplugin.convert.ConvertUtil"
factory-method="registerConverter" depends-on="gridcoverageRegistered">
<constructor-arg>
<bean
class="com.raytheon.uf.common.gridcoverage.convert.GridCoverageConverter" />
</constructor-arg>
<constructor-arg>
<value>com.raytheon.uf.common.gridcoverage.GridCoverage
</value>
</constructor-arg>
</bean>
<bean id="gridcoveragelookup"
class="com.raytheon.uf.common.gridcoverage.lookup.GridCoverageLookup"
factory-method="getInstance"
depends-on="serializeServer,getGridCoverageHandlerRegistered,queryDataRegistered"
lazy-init="true" />
<bean id="gridcoverageRegistered" factory-bean="dbPluginRegistry"
factory-method="register">
<constructor-arg value="com.raytheon.uf.common.gridcoverage" />
<constructor-arg ref="gridcoverageProperties" />
</bean>
</beans>

View file

@ -0,0 +1,157 @@
/**
* 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.gridcoverage;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.request.GetGridCoverageRequest;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
/**
* Handles database access of grid coverage, GetGridCoverageRequest can be used
* to do spatial lookup and creation.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GetGridCoverageHandler implements
IRequestHandler<GetGridCoverageRequest> {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GetGridCoverageHandler.class);
private final CoreDao dao;
public GetGridCoverageHandler() {
dao = new CoreDao(DaoConfig.forClass(GridCoverage.class));
}
@Override
public GridCoverage handleRequest(GetGridCoverageRequest request)
throws Exception {
return checkDatabase(request.getCoverage(), request.getCreate());
}
private GridCoverage checkDatabase(GridCoverage coverage, boolean create) {
GridCoverage rval = null;
Session sess = null;
Transaction trans = null;
try {
sess = dao.getSessionFactory().openSession();
trans = sess.beginTransaction();
Criteria crit = sess.createCriteria(coverage.getClass());
crit.add(Restrictions.eq("nx", coverage.getNx()));
crit.add(Restrictions.eq("ny", coverage.getNx()));
crit.add(Restrictions.between("dx", coverage.getDx()
- GridCoverage.SPATIAL_TOLERANCE, coverage.getDx()
+ GridCoverage.SPATIAL_TOLERANCE));
crit.add(Restrictions.between("dy", coverage.getDy()
- GridCoverage.SPATIAL_TOLERANCE, coverage.getDy()
+ GridCoverage.SPATIAL_TOLERANCE));
crit.add(Restrictions.between("la1", coverage.getLa1()
- GridCoverage.SPATIAL_TOLERANCE, coverage.getLa1()
+ GridCoverage.SPATIAL_TOLERANCE));
crit.add(Restrictions.between("lo1", coverage.getLo1()
- GridCoverage.SPATIAL_TOLERANCE, coverage.getLo1()
+ GridCoverage.SPATIAL_TOLERANCE));
List<?> vals = crit.list();
for (Object val : vals) {
if (((GridCoverage) val).spatialEquals(coverage)) {
rval = (GridCoverage) val;
}
}
if (rval == null
&& (Math.abs(coverage.getLo1()) > 179 || Math.abs(coverage
.getLa1()) > 89)) {
// if we got here nothing matches, try a query with no la1, and
// lo1 in case there are world wrap issues.
crit = sess.createCriteria(coverage.getClass());
crit.add(Restrictions.eq("nx", coverage.getNx()));
crit.add(Restrictions.eq("ny", coverage.getNx()));
crit.add(Restrictions.between("dx", coverage.getDx()
- GridCoverage.SPATIAL_TOLERANCE, coverage.getDx()
+ GridCoverage.SPATIAL_TOLERANCE));
crit.add(Restrictions.between("dy", coverage.getDy()
- GridCoverage.SPATIAL_TOLERANCE, coverage.getDy()
+ GridCoverage.SPATIAL_TOLERANCE));
vals = crit.list();
for (Object val : vals) {
if (((GridCoverage) val).spatialEquals(coverage)) {
return (GridCoverage) val;
}
}
}
if (rval == null && create) {
// if it still does not exist, create it if requested
coverage.initialize();
sess.saveOrUpdate(coverage);
rval = coverage;
}
trans.commit();
} catch (Exception e) {
statusHandler.error("Error occurred looking up GridCoverage["
+ coverage.getName() + "]", e);
if (trans != null) {
try {
trans.rollback();
} catch (Exception e1) {
statusHandler.error(
"Error occurred rolling back transaction", e);
}
}
} finally {
if (sess != null) {
try {
sess.close();
} catch (Exception e) {
statusHandler.error("Error occurred closing session", e);
}
}
}
return rval;
}
}

View file

@ -23,8 +23,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.cache;bundle-version="1.12.1174"
Import-Package: com.raytheon.edex.plugin.grib,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.scan.data,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.ohd,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.status,

View file

@ -24,7 +24,8 @@ Require-Bundle: com.raytheon.edex.uengine,
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174",
gov.noaa.nws.ncep.edex.plugin.ncgrib;bundle-version="1.0.0",
gov.noaa.nws.ncep.common.dataplugin.ncuair;bundle-version="1.0.0"
gov.noaa.nws.ncep.common.dataplugin.ncuair;bundle-version="1.0.0",
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0"
Export-Package: gov.noaa.nws.ncep.edex.uengine.output,
gov.noaa.nws.ncep.edex.uengine.tasks.radar,
gov.noaa.nws.ncep.edex.uengine.tasks.response,

View file

@ -14,6 +14,11 @@ import java.util.HashMap;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LambertConformalGridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.gridcoverage.MercatorGridCoverage;
import com.raytheon.uf.common.gridcoverage.PolarStereoGridCoverage;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
@ -24,11 +29,6 @@ import com.raytheon.uf.common.serialization.DynamicSerializationManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LambertConformalGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.MercatorGridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.PolarStereoGridCoverage;
import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;

View file

@ -55,9 +55,9 @@ Export-Package: gov.noaa.nws.ncep.viz.rsc.ncgrid,
gov.noaa.nws.ncep.viz.rsc.ncgrid.rsc
Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.derivparam.tree,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.viz.derivparam.data,
com.raytheon.uf.viz.derivparam.inv,

View file

@ -24,10 +24,10 @@ import org.opengis.referencing.datum.PixelInCell;
import com.raytheon.edex.meteoLib.Controller;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.LatLonGridCoverage;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;