Issue #189 checkin of grid dataplugin

Change-Id: I49b57915d90e6f5b347960046fa4c97a27a93375

Former-commit-id: 0b026f5d9d5d86d464cb0ec2b411a59666939276
This commit is contained in:
Ben Steffensmeier 2012-09-11 11:58:17 -05:00
parent bd8eb7fc15
commit ccc2ae2108
33 changed files with 4883 additions and 0 deletions

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.dataplugin.grid</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 @@
#Fri Feb 03 13:18:16 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
Bundle-SymbolicName: com.raytheon.uf.common.dataplugin.grid
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Eclipse-BuddyPolicy: registered, ext, global
Import-Package: com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.annotations,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.datastorage.records,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.localization,
com.raytheon.uf.common.parameter,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.annotations,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.status,
com.raytheon.uf.common.time,
com.vividsolutions.jts.geom,
javax.measure.unit,
javax.persistence,
org.hibernate.annotations,
org.opengis.metadata.spatial
Export-Package: com.raytheon.uf.common.dataplugin.grid,
com.raytheon.uf.common.dataplugin.grid.dataset,
com.raytheon.uf.common.dataplugin.grid.request,
com.raytheon.uf.common.dataplugin.grid.units,
com.raytheon.uf.common.dataplugin.grid.util

View file

@ -0,0 +1,4 @@
com.raytheon.uf.common.dataplugin.grid.GridRecord
com.raytheon.uf.common.dataplugin.grid.GridInfoRecord
com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfo
com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfoSet

View file

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

View file

@ -0,0 +1,34 @@
/**
* 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.
**/
CREATE INDEX "gridDatasetReftime_idx"
ON grid
USING btree
(info_id, reftime, forecasttime);
CREATE INDEX "gridinfoNameParamLevel_idx"
ON grid_info
USING btree
(datasetid, parameter_abbreviation, level_id);
CREATE INDEX "gridinfoSecondryId_idx"
ON grid_info
USING btree
(secondaryid);

View file

@ -0,0 +1,91 @@
/**
* 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.dataplugin.grid;
/**
*
* Contains some useful constants for dealing with grid data, mostly just
* hibernate names of attributes.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 11, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridConstants {
public static final String GRID = "grid";
public static final String PLUGIN_NAME = "pluginName";
public static final String INFO = "info";
public static final String INFO_ID = INFO + "." + GridInfoConstants.ID;
public static final String DATASET_ID = INFO + "."
+ GridInfoConstants.DATASET_ID;
public static final String SECONDARY_ID = INFO + "."
+ GridInfoConstants.SECONDARY_ID;
public static final String ENSEMBLE_ID = INFO + "."
+ GridInfoConstants.ENSEMBLE_ID;
public static final String LOCATION = INFO + "."
+ GridInfoConstants.LOCATION;
public static final String LOCATION_ID = INFO + "."
+ GridInfoConstants.LOCATION_ID;
public static final String PARAMETER = INFO + "."
+ GridInfoConstants.PARAMETER;
public static final String PARAMETER_ABBREVIATION = INFO + "."
+ GridInfoConstants.PARAMETER_ABBREVIATION;
public static final String PARAMETER_NAME = INFO + "."
+ GridInfoConstants.PARAMETER_NAME;
public static final String PARAMETER_UNIT = INFO + "."
+ GridInfoConstants.PARAMETER_UNIT;
public static final String LEVEL = INFO + "." + GridInfoConstants.LEVEL;
public static final String LEVEL_ID = INFO + "."
+ GridInfoConstants.LEVEL_ID;
public static final String MASTER_LEVEL_NAME = INFO + "."
+ GridInfoConstants.MASTER_LEVEL_NAME;
public static final String LEVEL_ONE = INFO + "."
+ GridInfoConstants.LEVEL_ONE;
public static final String LEVEL_TWO = INFO + "."
+ GridInfoConstants.LEVEL_TWO;
}

View file

@ -0,0 +1,73 @@
/**
* 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.dataplugin.grid;
/**
*
* Contains some useful constants for dealing with grid info objects, mostly
* just hibernate names of attributes.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 11, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridInfoConstants {
public static final String ID = "id";
public static final String DATASET_ID = "datasetId";
public static final String SECONDARY_ID = "secondaryId";
public static final String ENSEMBLE_ID = "ensembleId";
public static final String LOCATION = "location";
public static final String LOCATION_ID = LOCATION + ".id";
public static final String PARAMETER = "parameter";
public static final String PARAMETER_ABBREVIATION = PARAMETER
+ ".abbreviation";
public static final String PARAMETER_NAME = PARAMETER + ".name";
public static final String PARAMETER_UNIT = PARAMETER + ".unitString";
public static final String LEVEL = "level";
public static final String LEVEL_ID = LEVEL + ".id";
public static final String MASTER_LEVEL_NAME = LEVEL + ".masterLevel.name";
public static final String LEVEL_ONE = LEVEL + ".levelonevalue";
public static final String LEVEL_TWO = LEVEL + ".leveltwovalue";
}

View file

@ -0,0 +1,248 @@
/**
* 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.dataplugin.grid;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
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.parameter.Parameter;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* Contains all attributes of a grid record except time. This is done to save
* space in the db since across time most grid data has the same
* level/parameter/etc so having all other information in a separate table saves
* space and improves theoretical performance.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 21, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@Entity
@Table(name = "grid_info")
@SequenceGenerator(name = "GRIDINFO_GENERATOR", sequenceName = "gridinfo_seq", allocationSize = 1)
@DynamicSerialize
public class GridInfoRecord extends PersistableDataObject {
private static final long serialVersionUID = 1L;
/** The id */
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GRIDINFO_GENERATOR")
@DynamicSerializeElement
private Integer id;
@Column
@DataURI(position = 0)
@DynamicSerializeElement
private String datasetId;
/**
* Any string which can differentiate this record from other records with
* the same datasetId, examples of this would be for different versions of
* the same grid or for different events from the same model.
*/
@Column
@DataURI(position = 1)
@DynamicSerializeElement
private String secondaryId;
@Column
@DynamicSerializeElement
@DataURI(position = 2)
private String ensembleId;
/** The spatial information */
@ManyToOne
@PrimaryKeyJoinColumn
@DataURI(position = 3)
@DynamicSerializeElement
private GridCoverage location;
@ManyToOne
@PrimaryKeyJoinColumn
@DataURI(position = 4, embedded = true)
@DynamicSerializeElement
private Parameter parameter;
@ManyToOne
@PrimaryKeyJoinColumn
@DynamicSerializeElement
@DataURI(position = 5, embedded = true)
private Level level;
public GridInfoRecord() {
}
public GridInfoRecord(GridInfoRecord record) {
this.datasetId = record.getDatasetId();
this.level = record.getLevel();
this.location = record.getLocation();
this.parameter = record.getParameter();
this.ensembleId = record.getEnsembleId();
this.secondaryId = record.getSecondaryId();
this.id = record.getId();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDatasetId() {
return datasetId;
}
public void setDatasetId(String datasetId) {
this.datasetId = datasetId;
}
public String getSecondaryId() {
return secondaryId;
}
public void setSecondaryId(String secondaryId) {
this.secondaryId = secondaryId;
}
public String getEnsembleId() {
return ensembleId;
}
public void setEnsembleId(String ensembleId) {
this.ensembleId = ensembleId;
}
public GridCoverage getLocation() {
return location;
}
public void setLocation(GridCoverage location) {
this.location = location;
}
public Parameter getParameter() {
return parameter;
}
public void setParameter(Parameter parameter) {
this.parameter = parameter;
}
public Level getLevel() {
return level;
}
public void setLevel(Level level) {
this.level = level;
}
@Override
public String toString() {
return "/" + datasetId + "/" + secondaryId + "/" + ensembleId + "/"
+ location + "/" + parameter + "/" + level;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((datasetId == null) ? 0 : datasetId.hashCode());
result = prime * result
+ ((ensembleId == null) ? 0 : ensembleId.hashCode());
result = prime * result + ((level == null) ? 0 : level.hashCode());
result = prime * result
+ ((location == null) ? 0 : location.hashCode());
result = prime * result
+ ((parameter == null) ? 0 : parameter.hashCode());
result = prime * result
+ ((secondaryId == null) ? 0 : secondaryId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
GridInfoRecord other = (GridInfoRecord) obj;
if (datasetId == null) {
if (other.datasetId != null)
return false;
} else if (!datasetId.equals(other.datasetId))
return false;
if (ensembleId == null) {
if (other.ensembleId != null)
return false;
} else if (!ensembleId.equals(other.ensembleId))
return false;
if (level == null) {
if (other.level != null)
return false;
} else if (!level.equals(other.level))
return false;
if (location == null) {
if (other.location != null)
return false;
} else if (!location.equals(other.location))
return false;
if (parameter == null) {
if (other.parameter != null)
return false;
} else if (!parameter.equals(other.parameter))
return false;
if (secondaryId == null) {
if (other.secondaryId != null)
return false;
} else if (!secondaryId.equals(other.secondaryId))
return false;
return true;
}
}

View file

@ -0,0 +1,128 @@
/**
* 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.dataplugin.grid;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.raytheon.uf.common.dataplugin.persist.DefaultPathProvider;
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
/**
* Path provider for storing gridded data to HDF5
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/24/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class GridPathProvider extends DefaultPathProvider {
private static final DecimalFormat forecastHourFormat = new DecimalFormat(
"000");
private static final int SECONDS_PER_HOUR = 3600;
public static final String FORECAST_HR_TOKEN = "-FH-";
private static GridPathProvider instance = new GridPathProvider();
public static final List<String> STATIC_PARAMETERS;
static {
STATIC_PARAMETERS = new ArrayList<String>();
STATIC_PARAMETERS.add("staticTopo");
STATIC_PARAMETERS.add("staticXspacing");
STATIC_PARAMETERS.add("staticYspacing");
STATIC_PARAMETERS.add("staticCoriolis");
STATIC_PARAMETERS.add("staticSpacing");
}
public static GridPathProvider getInstance() {
return instance;
}
protected GridPathProvider() {
}
@Override
public String getHDFFileName(String pluginName, IPersistable persistable) {
if (persistable == null) {
throw new IllegalArgumentException(
"Expected argument persistable is null");
}
if (!(persistable instanceof GridRecord)) {
throw new IllegalArgumentException(
"Argument persistable is of wrong type. Expected "
+ GridRecord.class + " but got "
+ persistable.getClass());
} else if (pluginName == null) {
throw new IllegalArgumentException(
"Expected argument pluginName not set on object "
+ persistable.toString());
}
GridRecord pdo = (GridRecord) persistable;
StringBuffer sb = new StringBuffer(64);
sb.append(pdo.getDatasetId());
Date refTime = pdo.getDataTime().getRefTime();
String refTimeString = null;
synchronized (fileNameFormat) {
refTimeString = fileNameFormat.format(refTime);
}
sb.append(refTimeString);
sb.append(FORECAST_HR_TOKEN);
if (STATIC_PARAMETERS.contains(pdo.getParameter().getAbbreviation())) {
sb.append("000");
} else {
long number = pdo.getDataTime().getFcstTime() / SECONDS_PER_HOUR;
String numberString = null;
synchronized (forecastHourFormat) {
numberString = forecastHourFormat.format(number);
}
sb.append(numberString);
}
sb.append(".h5");
return sb.toString();
}
public String formatTime(Date date) {
String retVal = null;
synchronized (fileNameFormat) {
retVal = fileNameFormat.format(date);
}
return retVal;
}
}

View file

@ -0,0 +1,239 @@
/**
* 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.dataplugin.grid;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import com.raytheon.uf.common.dataplugin.IDecoderGettable;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.persist.IHDFFilePathProvider;
import com.raytheon.uf.common.dataplugin.persist.PersistablePluginDataObject;
import com.raytheon.uf.common.geospatial.ISpatialEnabled;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.gridcoverage.GridCoverage;
import com.raytheon.uf.common.parameter.Parameter;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
*
* Record for storing generic gridded data. Everything interesting is stored in
* the info object since it allows us to reuse the info object for identical
* records at different times which saves db and improves theoretical
* performance.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 21, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@Entity
@Table(name = "grid", uniqueConstraints = { @UniqueConstraint(columnNames = { "dataURI" }) })
@DynamicSerialize
public class GridRecord extends PersistablePluginDataObject implements
ISpatialEnabled {
private static final long serialVersionUID = 1L;
@ManyToOne(cascade = { CascadeType.REFRESH })
@PrimaryKeyJoinColumn
@DataURI(position = 1, embedded = true)
@DynamicSerializeElement
private GridInfoRecord info;
/**
* Holds any extra attributes which may be specific to this data. These are
* not stored to the database or to hdf5 but they can be useful for passing
* additional parameters from a decoder to a post processor.
*/
@Transient
private Map<String, Object> extraAttributes;
public GridRecord() {
super();
}
public GridRecord(GridRecord record) {
this.pluginName = record.getPluginName();
this.dataTime = record.getDataTime();
this.info = new GridInfoRecord(record.getInfoNotNull());
if (record.getExtraAttributes() != null) {
this.extraAttributes = new HashMap<String, Object>(
record.getExtraAttributes());
}
}
public GridRecord(String uri) {
super(uri);
}
public GridInfoRecord getInfo() {
return info;
}
public void setInfo(GridInfoRecord info) {
this.info = info;
}
protected GridInfoRecord getInfoNotNull() {
if (info == null) {
info = new GridInfoRecord();
}
return info;
}
public String getDatasetId() {
return getInfoNotNull().getDatasetId();
}
public void setDatasetId(String datasetId) {
getInfoNotNull().setDatasetId(datasetId);
}
public String getSecondaryId() {
return getInfoNotNull().getSecondaryId();
}
public void setSecondaryId(String secondaryId) {
getInfoNotNull().setSecondaryId(secondaryId);
}
public GridCoverage getLocation() {
return getInfoNotNull().getLocation();
}
public void setLocation(GridCoverage location) {
getInfoNotNull().setLocation(location);
}
public Parameter getParameter() {
return getInfoNotNull().getParameter();
}
public void setParameter(Parameter parameter) {
getInfoNotNull().setParameter(parameter);
}
public Level getLevel() {
return getInfoNotNull().getLevel();
}
public void setLevel(Level level) {
getInfoNotNull().setLevel(level);
}
public String getEnsembleId() {
return getInfoNotNull().getEnsembleId();
}
public void setEnsembleId(String ensembleId) {
getInfoNotNull().setEnsembleId(ensembleId);
}
@Override
public IDecoderGettable getDecoderGettable() {
return null;
}
@Override
public ISpatialObject getSpatialObject() {
return getLocation();
}
@Override
public IHDFFilePathProvider getHDFPathProvider() {
return GridPathProvider.getInstance();
}
public Map<String, Object> getExtraAttributes() {
return extraAttributes;
}
public void setExtraAttributes(Map<String, Object> extraAttributes) {
this.extraAttributes = extraAttributes;
}
/**
* Add an attribute to the data, if there are no attributes then the
* attribute map is created.
*
* @param key
* @param value
* @return the previous value of the attribute or null if there was none.
*/
public Object addExtraAttribute(String key, Object value) {
if (extraAttributes == null) {
extraAttributes = new HashMap<String, Object>();
}
return extraAttributes.put(key, value);
}
public Object getExtraAttribute(String key) {
if (extraAttributes == null) {
return null;
}
return extraAttributes.get(key);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((info == null) ? 0 : info.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
GridRecord other = (GridRecord) obj;
if (info == null) {
if (other.info != null)
return false;
} else if (!info.equals(other.info))
return false;
return true;
}
}

View file

@ -0,0 +1,95 @@
/**
* 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.dataplugin.grid.dataset;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
/**
*
* Contains static information about a grid dataset.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class DatasetInfo {
/** The title of the model */
@XmlElement
private String title;
/** The model name */
@XmlElement
private String datasetId;
@XmlElement
private String alias;
/**
* The intrinsic temporal resolution of the data.
*/
@XmlElement
private Integer dt;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDatasetId() {
return datasetId;
}
public void setDatasetId(String datasetId) {
this.datasetId = datasetId;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public Integer getDt() {
return dt;
}
public void setDt(Integer dt) {
this.dt = dt;
}
}

View file

@ -0,0 +1,117 @@
/**
* 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.dataplugin.grid.dataset;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
*
* Provides logic to read datasetInfo files from localization and provide lookup
* by datasetId.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class DatasetInfoLookup {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DatasetInfoLookup.class);
private static DatasetInfoLookup instance;
public static DatasetInfoLookup getInstance() {
if (instance == null) {
instance = new DatasetInfoLookup();
}
return instance;
}
private Map<String, DatasetInfo> infoMap = new HashMap<String, DatasetInfo>();
private DatasetInfoLookup() {
init();
}
private void init() {
JAXBManager manager = null;
try {
manager = new JAXBManager(DatasetInfoSet.class);
} catch (JAXBException e) {
statusHandler
.error("Error loading context for DatasetInfo, no datasetInfo will be loaded.",
e);
}
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext commonStaticBase = pathMgr.getContext(
LocalizationContext.LocalizationType.COMMON_STATIC,
LocalizationContext.LocalizationLevel.BASE);
LocalizationContext commonStaticSite = pathMgr.getContext(
LocalizationContext.LocalizationType.COMMON_STATIC,
LocalizationContext.LocalizationLevel.SITE);
LocalizationFile[] files = pathMgr.listFiles(new LocalizationContext[] {
commonStaticSite, commonStaticBase }, "grid"
+ IPathManager.SEPARATOR + "datasetInfo",
new String[] { ".xml" }, true, true);
for (LocalizationFile file : files) {
if (file == null || !file.exists()) {
return;
}
try {
Object obj = manager.jaxbUnmarshalFromXmlFile(file.getFile());
DatasetInfoSet set = (DatasetInfoSet) obj;
for (DatasetInfo info : set.getInfos()) {
infoMap.put(info.getDatasetId(), info);
}
} catch (SerializationException e) {
statusHandler.error(
"Error reading dataset info: " + file.getName()
+ " has been ignored.", e);
}
}
}
public DatasetInfo getInfo(String datasetId) {
return infoMap.get(datasetId);
}
}

View file

@ -0,0 +1,62 @@
/**
* 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.dataplugin.grid.dataset;
import java.util.ArrayList;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* JAXB compatible root element for a list of datasetInfo objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class DatasetInfoSet {
@XmlElements({ @XmlElement(name = "info", type = DatasetInfo.class) })
private ArrayList<DatasetInfo> infos;
public ArrayList<DatasetInfo> getInfos() {
return infos;
}
public void setInfos(ArrayList<DatasetInfo> infos) {
this.infos = infos;
}
}

View file

@ -0,0 +1,45 @@
/**
* 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.dataplugin.grid.request;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
*
* Request for the Grid DataTree.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 5, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
@DynamicSerialize
public class GetGridTreeRequest implements IServerRequest {
}

View file

@ -0,0 +1,66 @@
/**
* 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.dataplugin.grid.units;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.UnitFormat;
/**
* Provide alias for common units used in grid.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 20, 2009 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class GridUnits {
public static boolean register() {
UnitFormat.getInstance().alias(SI.METER, "gpm");
UnitFormat.getUCUMInstance().alias(SI.METER, "gpm");
UnitFormat.getInstance().alias(SI.MILLI(NonSI.BAR), "mb");
UnitFormat.getUCUMInstance().alias(SI.MILLI(NonSI.BAR), "mb");
UnitFormat.getInstance().alias(SI.CELSIUS, "C");
UnitFormat.getUCUMInstance().alias(SI.CELSIUS, "C");
UnitFormat.getInstance().alias(NonSI.FAHRENHEIT, "F");
UnitFormat.getUCUMInstance().alias(NonSI.FAHRENHEIT, "F");
UnitFormat.getInstance().alias(NonSI.DEGREE_ANGLE, "deg");
UnitFormat.getUCUMInstance().alias(NonSI.DEGREE_ANGLE, "deg");
UnitFormat.getInstance().alias(NonSI.DEGREE_ANGLE, "Degree");
UnitFormat.getUCUMInstance().alias(NonSI.DEGREE_ANGLE, "Degree");
UnitFormat.getInstance().alias(NonSI.KNOT, "kt");
UnitFormat.getUCUMInstance().alias(NonSI.KNOT, "kt");
UnitFormat.getInstance().alias(SI.SECOND, "sec");
UnitFormat.getUCUMInstance().alias(SI.SECOND, "sec");
UnitFormat.getInstance().alias(SI.METER, "meters");
UnitFormat.getUCUMInstance().alias(SI.METER, "meters");
return true;
}
}

View file

@ -0,0 +1,169 @@
/**
* 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.dataplugin.grid.util;
import java.util.HashMap;
import java.util.Map;
import org.opengis.metadata.spatial.PixelOrientation;
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;
/**
* A class for calculating and caching static data for grids.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 24, 2008 brockwoo Initial creation
*
* </pre>
*
* @author brockwoo
* @version 1.0
*/
public class StaticGridData {
private static Map<GridCoverage, StaticGridData> instanceMap = new HashMap<GridCoverage, StaticGridData>();
private static final double R_EARTH = 6370.0;
private FloatDataRecord dx;
private FloatDataRecord dy;
private FloatDataRecord coriolis;
private StaticGridData(GridCoverage gridCoverage) {
initStaticData(gridCoverage);
}
public static synchronized StaticGridData getInstance(
GridCoverage gridCoverage) {
StaticGridData rval = instanceMap.get(gridCoverage);
if (rval == null) {
rval = new StaticGridData(gridCoverage);
instanceMap.put(gridCoverage, rval);
}
return rval;
}
public FloatDataRecord getCoriolis() {
return this.coriolis;
}
public FloatDataRecord getDx() {
return this.dx;
}
public FloatDataRecord getDy() {
return this.dy;
}
private void initStaticData(GridCoverage gridCoverage) {
int nx = gridCoverage.getNx();
int ny = gridCoverage.getNy();
int n = nx * ny;
float[] _coriolis = new float[n];
float[] dxPtr = new float[n];
float[] dyPtr = new float[n];
float[] avgPtr = new float[n];
double[] xx = new double[n];
double[] yy = new double[n];
double[] zz = new double[n];
int i, j, k;
for (j = k = 0; j < ny; j++) {
for (i = 0; i < nx; i++, k++) {
Coordinate location = new Coordinate(i, j);
Coordinate latLon = MapUtil.gridCoordinateToLatLon(location,
PixelOrientation.CENTER, gridCoverage);
latLon.x = Math.toRadians(latLon.x);
latLon.y = Math.toRadians(latLon.y);
xx[k] = Math.cos(latLon.y);
yy[k] = xx[k] * Math.sin(latLon.x);
xx[k] *= Math.cos(latLon.x);
zz[k] = Math.sin(latLon.y);
_coriolis[k] = (float) (zz[k] * 1.458e-4);
}
}
this.coriolis = newRecord(_coriolis, nx, ny);
int up, dn, lft, rgt;
long _nxm = nx - 1;
double d;
double icomp, jcomp, kcomp;
double dmax = 0.0;
dn = 0;
up = nx;
for (j = k = 0; j < ny; j++) {
if (up >= n) {
up -= nx;
}
lft = k;
for (i = 0; i < nx; i++, k++) {
rgt = (i < _nxm ? k + 1 : k);
icomp = yy[lft] * zz[rgt] - zz[lft] * yy[rgt];
jcomp = zz[lft] * xx[rgt] - xx[lft] * zz[rgt];
kcomp = xx[lft] * yy[rgt] - yy[lft] * xx[rgt];
d = Math.sqrt(icomp * icomp + jcomp * jcomp + kcomp * kcomp);
dxPtr[k] = (float) (Math.asin(d) * 1000.0 * R_EARTH / (rgt - lft));
icomp = yy[dn] * zz[up] - zz[dn] * yy[up];
jcomp = zz[dn] * xx[up] - xx[dn] * zz[up];
kcomp = xx[dn] * yy[up] - yy[dn] * xx[up];
d = Math.sqrt(icomp * icomp + jcomp * jcomp + kcomp * kcomp);
dyPtr[k] = (float) (Math.asin(d) * 1000.0 * R_EARTH * nx / (up - dn));
avgPtr[k] = (dxPtr[k] + dyPtr[k]) / 2.0f;
d = dxPtr[k] - dyPtr[k];
if (d < 0) {
d = -d;
}
d /= avgPtr[k];
if (d > dmax) {
dmax = d;
}
dn++;
up++;
lft = k;
}
if (j == 0) {
dn = 0;
}
}
if (dmax > 0.01) {
this.dx = newRecord(dxPtr, nx, ny);
this.dy = newRecord(dyPtr, nx, ny);
} else {
this.dx = this.dy = newRecord(avgPtr, nx, ny);
}
}
private FloatDataRecord newRecord(float[] data, int nx, int ny) {
return new FloatDataRecord("DATA", "", data, 2, new long[] { nx, ny });
}
}

View file

@ -0,0 +1,56 @@
/**
* 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.dataplugin.grid.util;
import java.util.ArrayList;
import java.util.List;
/**
* The static grid data types are the same values for a coverage and can be
* calculated based off the coverage/model.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 17, 2010 rjpeter Initial creation
*
* </pre>
*
* @author rjpeter
* @version 1.0
*/
public enum StaticGridDataType {
dx, dy, coriolis, _dt;
private static List<String> stringValues;
public static List<String> getStringValues() {
if (stringValues == null) {
stringValues = new ArrayList<String>(values().length);
for (StaticGridDataType type : values()) {
stringValues.add(type.toString());
}
}
return stringValues;
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<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.plugin.grid</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 @@
#Fri Feb 03 13:25:55 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,66 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Grid
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.grid
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.edex.site,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.grid,
com.raytheon.uf.common.dataplugin.grid.dataset,
com.raytheon.uf.common.dataplugin.grid.request,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.dataquery.db,
com.raytheon.uf.common.datastorage,
com.raytheon.uf.common.datastorage.records,
com.raytheon.uf.common.derivparam.tree,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.geospatial.interpolation,
com.raytheon.uf.common.gridcoverage,
com.raytheon.uf.common.gridcoverage.lookup,
com.raytheon.uf.common.parameter,
com.raytheon.uf.common.parameter.mapping,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.status,
com.raytheon.uf.common.util,
com.raytheon.uf.common.util.registry,
com.raytheon.uf.edex.core,
com.raytheon.uf.edex.core.dataplugin,
com.raytheon.uf.edex.core.props,
com.raytheon.uf.edex.database,
com.raytheon.uf.edex.database.cluster,
com.raytheon.uf.edex.database.dao,
com.raytheon.uf.edex.database.plugin,
com.raytheon.uf.edex.database.query,
com.raytheon.uf.edex.parameter,
com.vividsolutions.jts.geom,
javax.measure.converter,
javax.measure.unit,
org.apache.commons.logging,
org.geotools.coverage,
org.geotools.coverage.grid,
org.geotools.factory,
org.geotools.geometry,
org.geotools.geometry.jts,
org.geotools.referencing,
org.geotools.referencing.operation,
org.geotools.referencing.operation.builder,
org.geotools.referencing.operation.transform,
org.hibernate,
org.hibernate.criterion,
org.opengis.coverage.grid,
org.opengis.geometry,
org.opengis.metadata.spatial,
org.opengis.parameter,
org.opengis.referencing,
org.opengis.referencing.crs,
org.opengis.referencing.datum,
org.opengis.referencing.operation,
org.springframework.dao.support,
org.springframework.orm.hibernate3.support
Export-Package: com.raytheon.uf.edex.plugin.grid.dao,
com.raytheon.uf.edex.plugin.grid.handler,
com.raytheon.uf.edex.plugin.grid.topo

View file

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

View file

@ -0,0 +1,60 @@
<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="gridPathProvider" class="com.raytheon.uf.common.dataplugin.grid.GridPathProvider" />
<bean id="gridProperties" class="com.raytheon.uf.common.dataplugin.PluginProperties">
<property name="pluginName" value="grid" />
<property name="pluginFQN" value="com.raytheon.uf.common.dataplugin.grid" />
<property name="dao" value="com.raytheon.uf.edex.plugin.grid.dao.GridDao" />
<property name="record"
value="com.raytheon.uf.common.dataplugin.grid.GridRecord" />
<property name="dependencyFQNs">
<list>
<value>com.raytheon.uf.common.dataplugin.level</value>
<value>com.raytheon.uf.common.parameter</value>
<value>com.raytheon.uf.common.gridcoverage</value>
</list>
</property>
<property name="pathProvider">
<ref bean="gridPathProvider" />
</property>
<property name="compression" value="LZF" />
</bean>
<bean id="gridRegistered" factory-bean="pluginRegistry"
factory-method="register"
depends-on="levelRegistered,parameterRegistered,gridcoverageRegistered">
<constructor-arg value="grid" />
<constructor-arg ref="gridProperties" />
</bean>
<bean id="gridUnitsRegisterd"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass">
<value>com.raytheon.uf.common.dataplugin.grid.units.GridUnits</value>
</property>
<property name="targetMethod">
<value>register</value>
</property>
</bean>
<bean id="gridInfoCache" class="com.raytheon.uf.edex.plugin.grid.dao.GridInfoCache"
factory-method="getInstance" />
<bean class="com.raytheon.uf.edex.plugin.grid.dao.GridDao"
factory-method="setPurgeModelCacheTopic">
<constructor-arg value="jms-generic:topic:purgeGridInfoCache" />
</bean>
<camelContext id="grid-common-camel" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<route id="purgeGridInfoCache">
<from uri="jms-generic:topic:purgeGridInfoCache" />
<bean ref="gridInfoCache" method="purgeCache" />
</route>
</camelContext>
</beans>

View file

@ -0,0 +1,16 @@
<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="gridTreeHandler"
class="com.raytheon.uf.edex.plugin.grid.handler.GridTreeHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.dataplugin.grid.request.GetGridTreeRequest" />
<constructor-arg ref="gridTreeHandler" />
</bean>
</beans>

View file

@ -0,0 +1,406 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grid.dao;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.measure.converter.UnitConverter;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
import com.raytheon.uf.common.dataplugin.grid.GridPathProvider;
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
import com.raytheon.uf.common.dataquery.db.QueryResult;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.StorageProperties;
import com.raytheon.uf.common.datastorage.StorageStatus;
import com.raytheon.uf.common.datastorage.records.AbstractStorageRecord;
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.gridcoverage.lookup.GridCoverageLookup;
import com.raytheon.uf.common.parameter.Parameter;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.core.dataplugin.PluginRegistry;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.plugin.PluginDao;
import com.raytheon.uf.edex.parameter.ParameterLookup;
/**
* Data access object for accessing Grid records from the database
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 4/7/09 1994 bphillip Initial Creation
*
* </pre>
*
* @author bphillip
* @version 1
*/
public class GridDao extends PluginDao {
private static String purgeModelCacheTopic = null;
public static String setPurgeModelCacheTopic(String purgeModelCacheTopic) {
GridDao.purgeModelCacheTopic = purgeModelCacheTopic;
return purgeModelCacheTopic;
}
public GridDao() throws PluginException {
super(GridConstants.GRID);
}
public GridDao(String pluginName) throws PluginException {
super(pluginName);
}
@Override
protected IDataStore populateDataStore(IDataStore dataStore,
IPersistable obj) throws Exception {
GridRecord gridRec = (GridRecord) obj;
Object messageData = gridRec.getMessageData();
GridCoverage location = gridRec.getLocation();
if (location != null && messageData instanceof float[]) {
long[] sizes = new long[] { location.getNx(), location.getNy() };
String abbrev = gridRec.getParameter().getAbbreviation();
String group = gridRec.getDataURI();
if (GridPathProvider.STATIC_PARAMETERS.contains(abbrev)) {
group = "/" + location.getName();
}
AbstractStorageRecord storageRecord = new FloatDataRecord("Data",
group, (float[]) messageData, 2, sizes);
storageRecord.setCorrelationObject(gridRec);
StorageProperties sp = new StorageProperties();
String compression = PluginRegistry.getInstance()
.getRegisteredObject(pluginName).getCompression();
if (compression != null) {
sp.setCompression(StorageProperties.Compression
.valueOf(compression));
}
sp.setChunked(true);
dataStore.addDataRecord(storageRecord, sp);
} else {
throw new Exception("Cannot create data record, spatialData = "
+ location + " and messageData = " + messageData);
}
return dataStore;
}
@Override
public void persistRecords(PluginDataObject... records)
throws PluginException {
List<PluginDataObject> toPersist = new ArrayList<PluginDataObject>(
records.length);
for (PluginDataObject record : records) {
GridRecord rec = (GridRecord) record;
if (rec.getParameter() == null
|| rec.getParameter().getName() == null
|| rec.getParameter().getName().equals("Missing")) {
logger.info("Discarding record due to missing or unknown parameter mapping: "
+ record);
} else {
boolean validLevel = false;
Level level = rec.getLevel();
if (level != null) {
MasterLevel ml = level.getMasterLevel();
if (ml != null
&& !LevelFactory.UNKNOWN_LEVEL.equals(ml.getName())) {
validLevel = true;
}
}
if (validLevel) {
toPersist.add(rec);
} else {
logger.info("Discarding record due to missing or unknown level mapping: "
+ record);
}
}
}
super.persistRecords(toPersist.toArray(new PluginDataObject[toPersist
.size()]));
}
@Override
public PluginDataObject[] persistToDatabase(PluginDataObject... records) {
return super.persistToDatabase(verifyRecords(records));
}
@Override
public StorageStatus persistToHDF5(PluginDataObject... records)
throws PluginException {
return super.persistToHDF5(verifyRecords(records));
}
@Override
public List<IDataRecord[]> getHDF5Data(List<PluginDataObject> objects,
int tileSet) throws PluginException {
List<IDataRecord[]> retVal = new ArrayList<IDataRecord[]>(
objects.size());
for (PluginDataObject rec : objects) {
if (rec instanceof GridRecord) {
try {
GridRecord obj = (GridRecord) rec;
IDataStore dataStore = getDataStore(obj);
String abbrev = obj.getParameter().getAbbreviation();
if (GridPathProvider.STATIC_PARAMETERS.contains(abbrev)) {
IDataRecord[] record = new IDataRecord[4];
record[0] = dataStore.retrieve("/"
+ obj.getLocation().getName(), abbrev,
Request.ALL);
retVal.add(record);
} else {
/* connect to the data store and retrieve the data */
IDataRecord[] record = new IDataRecord[4];
record[0] = dataStore.retrieve(obj.getDataURI(),
"Data", Request.ALL);
retVal.add(record);
}
} catch (StorageException e) {
throw new PluginException("Error getting HDF5 data", e);
} catch (FileNotFoundException e) {
throw new PluginException("Error getting HDF5 data", e);
}
}
}
return retVal;
}
private PluginDataObject[] verifyRecords(PluginDataObject... records) {
List<PluginDataObject> toPersist = new ArrayList<PluginDataObject>(
records.length);
for (PluginDataObject record : records) {
GridRecord rec = (GridRecord) record;
if (validateDataset(rec)) {
toPersist.add(rec);
}
}
return toPersist.toArray(new GridRecord[toPersist.size()]);
}
private boolean validateDataset(GridRecord record) {
if (!validateParameter(record)) {
return false;
}
if (!validateLevel(record)) {
return false;
}
if (!validateCoverage(record)) {
return false;
}
record.setInfo(GridInfoCache.getInstance()
.getGridInfo(record.getInfo()));
return true;
}
private boolean validateParameter(GridRecord record) {
Parameter parameter = record.getParameter();
boolean result = true;
if (parameter == null) {
result = false;
} else if (parameter.getName() == null) {
result = false;
} else if (parameter.getName().equals("Missing")) {
result = false;
} else {
Parameter dbParameter = ParameterLookup.getInstance()
.lookupParameter(parameter, true);
if (!parameter.equals(dbParameter)) {
// This check is for debugging purposes
// if (!parameter.getName().equals(dbParameter.getName())) {
// logger.info("Record parameter name(" + parameter.getName()
// + ") does not match database("
// + dbParameter.getName() + ") "
// + record.getDataURI());
// }
UnitConverter converter = Parameter.compareUnits(parameter,
dbParameter);
// if (converter == null) {
// logger.info("Record parameter unit("
// + parameter.getUnitString()
// + ") does not match database("
// + dbParameter.getUnitString() + ") "
// + record.getDataURI());
// // For absolute accuracy we should abort if units don't
// // match, but currently we will persist it anyway.
// // result = false;
// } else
if (converter != null && converter != UnitConverter.IDENTITY) {
Object messageData = record.getMessageData();
if (messageData instanceof float[]) {
float[] data = (float[]) messageData;
for (int i = 0; i < data.length; i++) {
data[i] = (float) converter.convert(data[i]);
}
} else {
logger.info("Unable to convert grid data to correct units: "
+ record.getDataURI());
}
}
}
record.setParameter(dbParameter);
}
if (!result) {
logger.info("Discarding record due to missing or unknown parameter mapping: "
+ record);
}
return result;
}
private boolean validateCoverage(GridRecord record) {
GridCoverage coverage = record.getLocation();
if (coverage == null) {
logger.info("Discarding record due to missing location: " + record);
return false;
}
GridCoverage dbCoverage = GridCoverageLookup.getInstance().getCoverage(
coverage, false);
if (coverage == dbCoverage) {
return true;
}
if (dbCoverage == null) {
dbCoverage = GridCoverageLookup.getInstance().getCoverage(coverage,
true);
logger.error("Unable to persist " + record
+ " because storing the location failed.");
if (dbCoverage == null) {
return false;
}
}
record.setLocation(dbCoverage);
if (!coverage.getId().equals(dbCoverage.getId())) {
record.setDataURI(null);
try {
record.constructDataURI();
} catch (PluginException e) {
logger.info("Error constructing dataURI: " + record);
return false;
}
}
return true;
}
private boolean validateLevel(GridRecord record) {
boolean result = false;
Level level = record.getLevel();
if (level != null) {
MasterLevel ml = level.getMasterLevel();
if (ml != null && !LevelFactory.UNKNOWN_LEVEL.equals(ml.getName())) {
result = true;
}
}
if (!result) {
logger.info("Discarding record due to missing or unknown level mapping: "
+ record);
}
return result;
}
/**
* Overridden to clean up orphan GridInfoRecords.
*/
@Override
public void delete(List<PluginDataObject> objs) {
super.delete(objs);
Set<Integer> orphanedIds = new HashSet<Integer>(objs.size());
StringBuilder sqlString = new StringBuilder(objs.size() * 15 + 80);
sqlString
.append("select distinct info_id from awips.grid where info_id in (");
for (PluginDataObject pdo : objs) {
if (pdo instanceof GridRecord) {
Integer id = ((GridRecord) pdo).getInfo().getId();
if (orphanedIds.add(id)) {
if (orphanedIds.size() > 1) {
sqlString.append(", ");
}
sqlString.append(id);
}
}
}
sqlString.append(");");
try {
QueryResult result = (QueryResult) this.executeNativeSql(sqlString
.toString());
for (int i = 0; i < result.getResultCount(); i++) {
orphanedIds.remove((Integer) result.getRowColumnValue(i, 0));
}
if (!orphanedIds.isEmpty()) {
sqlString = new StringBuilder(orphanedIds.size() * 15 + 60);
sqlString.append("delete from awips.grid_info where id in (");
boolean first = true;
for (Integer id : orphanedIds) {
if (!first) {
sqlString.append(", ");
} else {
first = false;
}
sqlString.append(id);
}
sqlString.append(");");
if (purgeModelCacheTopic != null) {
this.executeNativeSql(sqlString.toString());
EDEXUtil.getMessageProducer().sendAsyncUri(
purgeModelCacheTopic, orphanedIds);
} else {
GridInfoCache.getInstance().purgeCache(
new ArrayList<Integer>(orphanedIds));
statusHandler
.warn("Unable to purge model cache of clustered edices");
}
}
} catch (DataAccessLayerException e1) {
statusHandler.error("Error purging orphaned grid info entries", e1);
} catch (EdexException e) {
statusHandler.error(
"Error sending message to purge grid info topic", e);
}
}
}

View file

@ -0,0 +1,112 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grid.dao;
import java.lang.ref.SoftReference;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
/**
* Cache the gridInfo objects from the database to avoid repeated lookups.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 21, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridInfoCache {
private static GridInfoCache instance = new GridInfoCache();
public static GridInfoCache getInstance() {
return instance;
}
private CoreDao dao;
// A weak hashmap of soft references is used as a SoftSet.
private Map<GridInfoRecord, SoftReference<GridInfoRecord>> cache = null;
private GridInfoCache() {
cache = Collections
.synchronizedMap(new WeakHashMap<GridInfoRecord, SoftReference<GridInfoRecord>>());
dao = new CoreDao(DaoConfig.forClass(GridInfoRecord.class));
}
public GridInfoRecord getGridInfo(GridInfoRecord record) {
GridInfoRecord result = checkLocalCache(record);
if (result == null) {
synchronized (this) {
// It is possible that this query will return multiple results,
// for example if the record we are looking for has a null
// secondaryId but some db entries have a secondaryId set then
// this query will return all matching models ignoring
// secondaryId. In general these cases should be rare and small.
// So we handle it by caching everything returned and then
// double checking the cache.
List<PersistableDataObject> dbList = dao.queryByExample(record);
if (dbList != null && !dbList.isEmpty()) {
for (PersistableDataObject pdo : dbList) {
GridInfoRecord gir = (GridInfoRecord) pdo;
cache.put(gir, new SoftReference<GridInfoRecord>(gir));
}
}
result = checkLocalCache(record);
if (result == null) {
dao.saveOrUpdate(record);
result = record;
}
}
}
return result;
}
private GridInfoRecord checkLocalCache(GridInfoRecord record) {
GridInfoRecord result = null;
SoftReference<GridInfoRecord> ref = cache.get(record);
if (ref != null) {
result = ref.get();
}
return result;
}
public void purgeCache(List<Integer> modelKeys) {
for (Integer key : modelKeys) {
cache.remove(key);
}
}
}

View file

@ -0,0 +1,107 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grid.handler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.raytheon.uf.common.dataplugin.grid.GridInfoConstants;
import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord;
import com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfo;
import com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfoLookup;
import com.raytheon.uf.common.dataplugin.grid.request.GetGridTreeRequest;
import com.raytheon.uf.common.derivparam.tree.DataTree;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
/**
* Build a DataTree representing all the grid data in the db.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 5, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GridTreeHandler implements IRequestHandler<GetGridTreeRequest> {
private static final String[] GRIDFIELDS = { GridInfoConstants.DATASET_ID,
GridInfoConstants.PARAMETER_ABBREVIATION,
GridInfoConstants.PARAMETER_NAME, GridInfoConstants.PARAMETER_UNIT,
GridInfoConstants.LEVEL_ID };
@Override
public DataTree handleRequest(GetGridTreeRequest request) throws Exception {
DataTree gridTree = null;
CoreDao gribDao = null;
List<?> queryResults = null;
gribDao = new CoreDao(DaoConfig.forClass(GridInfoRecord.class));
// if we do not get a table back, just return an empty list
gridTree = new DataTree();
DatabaseQuery query = new DatabaseQuery(GridInfoRecord.class.getName());
List<String> distinctFields = Arrays.asList(GRIDFIELDS);
query.addOrder(distinctFields.get(0), true);
query.addDistinctParameter(distinctFields);
queryResults = gribDao.queryByCriteria(query);
if (queryResults.size() > 0) {
for (Object gridField : queryResults) {
if (gridField.getClass().isArray()) {
ArrayList<Object> gridFields = new ArrayList<Object>(
Arrays.asList((Object[]) gridField));
String model = gridFields.get(0).toString();
gridTree.addBranch(model, getDt(model), gridFields.get(1)
.toString(), gridFields.get(2).toString(),
gridFields.get(3).toString(), gridFields.get(4)
.toString());
}
}
}
return gridTree;
}
private int getDt(String modelName) {
DatasetInfo info = DatasetInfoLookup.getInstance().getInfo(modelName);
if (info != null && info.getDt() != null) {
int dTinSeconds = info.getDt();
// dT <= 24 is in hours, need to convert to seconds
if (Math.abs(dTinSeconds) <= 24) {
dTinSeconds *= 3600;
}
return dTinSeconds;
}
return -1;
}
}

View file

@ -0,0 +1,189 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.grid.topo;
import java.util.HashMap;
import java.util.Map;
import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Static class used for holding the attributes of the static topo data
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/09/2010 6394 bphillip Initial creation
* </pre>
*
* @author bphillip
* @version 1.0
*/
public class TopoAttributes {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(TopoAttributes.class);
/** Lower left latitude attribute name */
public static final String LL_LAT = "llLat";
/** Lower left longitude attribute name */
public static final String LL_LON = "llLon";
/** Upper right latitude attribute name */
public static final String UR_LAT = "urLat";
/** Upper right longitude attribute name */
public static final String UR_LON = "urLon";
/** Nx attribute name */
public static final String NX = "nx";
/** Ny attribute name */
public static final String NY = "ny";
/** Central meridian attribute name */
public static final String CENTRAL_MERIDIAN = "central_meridian";
/** Latitude of origin attribute name */
public static final String LAT_OF_ORIGIN = "latOfOrigin";
/** CRS attribute name */
public static final String CRS = "CRS";
/** Map containing the attributes for the static topo data */
public static Map<String, Map<String, Object>> attributeMap = new HashMap<String, Map<String, Object>>();
static {
createAttributeMap("ak", 61.968945f, 150.32922f, 47.7384f, -128.74811f,
4270, 2800, -150f, 90f);
createAttributeMap("carib", 26.831362f, -75.716293f, 8.909350f,
-56.794250f, 2271, 2151, 0f, 0f);
createAttributeMap("us", 16.114336f, -127.13067f, 51.825356f,
-49.03707f, 6138, 4610, -100f, 45f);
createAttributeMap("pac", -34.99583f, 120.004166f, 39.995834f,
-120.004166f, 14400, 9000, 0f, 0f);
createAttributeMap("world", -89.979164f, -180.0f, 89.979164f, 180.0f,
8642, 4320, 0f, 0f);
}
/**
* Retrieves the attributes for a static topo data set
*
* @param name
* The name of the static topo data set
* @return The attribute for the requested data set
*/
public static Map<String, Object> getAttributes(String name) {
return attributeMap.get(name);
}
/**
* Creates an attribute map with the provided parameters
*
* @param name
* The name of the static topo data set
* @param llLat
* The lower left latitude
* @param llLon
* The lower left longitude
* @param urLat
* The upper right latitude
* @param urLon
* The upper right longitude
* @param nx
* Number of points on the x axis
* @param ny
* Number of points on the y axis
* @param central_meridian
* The central meridian
* @param latOfOrigin
* The latitude of origin
*/
private static void createAttributeMap(String name, float llLat,
float llLon, float urLat, float urLon, int nx, int ny,
float central_meridian, float latOfOrigin) {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(LL_LAT, new Float(llLat));
attributes.put(LL_LON, new Float(llLon));
attributes.put(UR_LAT, new Float(urLat));
attributes.put(UR_LON, new Float(urLon));
attributes.put(NX, new Integer(nx));
attributes.put(NY, new Integer(ny));
attributes.put(CENTRAL_MERIDIAN, new Float(central_meridian));
attributes.put(LAT_OF_ORIGIN, new Float(latOfOrigin));
if (name.equals("us")) {
try {
attributes.put(
CRS,
initUSProjectionData("US", latOfOrigin,
central_meridian).toWKT());
} catch (Exception e) {
statusHandler.handle(Priority.INFO, "Error creating US CRS");
}
} else if (name.equals("ak")) {
attributes.put(
CRS,
MapUtil.constructStereographic(6371200.0, 6371200.0,
latOfOrigin, central_meridian).toWKT());
} else {
attributes.put(
CRS,
MapUtil.constructEquidistantCylindrical(6371200.0,
6371200.0, 0, 0).toWKT());
}
attributeMap.put(name, attributes);
}
/**
* Initializes the CRS for the us data set
*
* @param name
* The name
* @param latCenter
* The central latitude
* @param lonCenter
* The central longitude
* @return The constructed CRS
* @throws Exception
*/
private static CoordinateReferenceSystem initUSProjectionData(String name,
float latCenter, float lonCenter) throws Exception {
ParameterValueGroup parameters = new DefaultMathTransformFactory()
.getDefaultParameters("Lambert_Azimuthal_Equal_Area");
parameters.parameter("semi_major").setValue(6371200.0);
parameters.parameter("semi_minor").setValue(6371200.0);
parameters.parameter("latitude_of_center").setValue(latCenter);
parameters.parameter("longitude_of_center").setValue(lonCenter);
return MapUtil.constructProjection(name, parameters);
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<pathKeySet>
<pathKey>
<key>info.datasetId</key>
<order>0</order>
</pathKey>
</pathKeySet>