-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -47,23 +25,5 @@
-
-
-
-
-
-
-
- java.lang.Throwable
-
-
-
-
-
-
-
-
diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java
deleted file mode 100644
index 991d6a98e2..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataArchiver.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/**
- * This software was developed and / or modified by Raytheon Company,
- * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
- *
- * U.S. EXPORT CONTROLLED TECHNICAL DATA
- * This software product contains export-restricted data whose
- * export/transfer/disclosure is restricted by U.S. law. Dissemination
- * to non-U.S. persons whether in the United States or abroad requires
- * an export license or other authorization.
- *
- * Contractor Name: Raytheon Company
- * Contractor Address: 6825 Pine Street, Suite 340
- * Mail Stop B8
- * Omaha, NE 68106
- * 402.291.0100
- *
- * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
- * further licensing information.
- **/
-package com.raytheon.uf.edex.maintenance.archive;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import com.raytheon.uf.common.localization.IPathManager;
-import com.raytheon.uf.common.localization.LocalizationContext;
-import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
-import com.raytheon.uf.common.localization.LocalizationFile;
-import com.raytheon.uf.common.localization.PathManagerFactory;
-import com.raytheon.uf.common.serialization.SerializationUtil;
-import com.raytheon.uf.common.status.IUFStatusHandler;
-import com.raytheon.uf.common.status.UFStatus;
-import com.raytheon.uf.common.status.UFStatus.Priority;
-import com.raytheon.uf.edex.core.dataplugin.PluginRegistry;
-import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig;
-
-/**
- * Handles archiving of data. Has two interfaces for registering data archive.
- * Data archived based on archiving for each plugin and general data archive
- * programs.
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Dec 16, 2011 rjpeter Initial creation
- *
- *
- *
- * @author rjpeter
- * @version 1.0
- */
-public class DataArchiver {
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(DataArchiver.class);
-
- private List pluginArchivers = new ArrayList();
-
- private List dataArchivers = new ArrayList();
-
- private String archivePath = null;
-
- private String defaultPlugin = "default";
-
- private String configDir = "archiver";
-
- public DataArchiver(String archivePath) {
- this.archivePath = archivePath;
- }
-
- public void archivePlugins() {
- statusHandler.info("Archival of plugin data starting");
-
- // get list of plugins, ordered by plugin
- Set availablePlugins = new TreeSet(PluginRegistry
- .getInstance().getRegisteredObjects());
-
- Map configs = getDataArchiveConfigs();
- DataArchiveConfig defaultConf = configs.get(defaultPlugin);
- File baseArchive = new File(archivePath);
-
- for (String pluginName : availablePlugins) {
- DataArchiveConfig conf = configs.get(pluginName);
- if (conf == null) {
- conf = defaultConf;
- }
-
- if (Boolean.TRUE.equals(conf.getArchivingEnabled())) {
- for (IPluginArchiver pluginArchiver : pluginArchivers) {
- pluginArchiver.archivePlugin(pluginName, archivePath, conf);
- }
- }
- }
-
- statusHandler.info("Archival of plugin data complete");
- }
-
- public Object registerPluginArchiver(IPluginArchiver archiver) {
- if (!pluginArchivers.contains(archiver)) {
- pluginArchivers.add(archiver);
- } else {
- statusHandler.warn("Plugin archiver already registered: "
- + archiver);
- }
-
- return this;
- }
-
- public Object registerDataArchiver(IDataArchiver archiver) {
- if (!dataArchivers.contains(archiver)) {
- dataArchivers.add(archiver);
- } else {
- statusHandler.warn("Data archiver already registered: " + archiver);
- }
-
- return this;
- }
-
- private Map getDataArchiveConfigs() {
- Map configs = new HashMap();
- IPathManager pathMgr = PathManagerFactory.getPathManager();
- // process in reverse order so BASE is processed before CONFIGURED
- // before SITE
- List contexts = Arrays.asList(pathMgr
- .getLocalSearchHierarchy(LocalizationType.COMMON_STATIC));
- Collections.reverse(contexts);
- String[] extensions = new String[] { "xml" };
- for (LocalizationContext ctx : contexts) {
- statusHandler.info("Loading context: " + ctx);
- LocalizationFile[] lfs = pathMgr.listFiles(ctx, configDir,
- extensions, false, true);
- if (lfs != null && lfs.length > 0) {
- for (LocalizationFile lf : lfs) {
- String fileName = lf.getName();
- try {
- File f = lf.getFile(true);
- fileName = f.getAbsolutePath();
- Object obj = SerializationUtil
- .jaxbUnmarshalFromXmlFile(f);
- if (obj instanceof DataArchiveConfig) {
- DataArchiveConfig conf = (DataArchiveConfig) obj;
- String plugin = conf.getPluginName();
- if (plugin != null) {
- plugin = plugin.trim();
- if (!plugin.isEmpty()) {
- configs.put(plugin, conf);
- } else {
- throw new Exception(
- "Configuration file does not specify pluginName");
- }
- } else {
- throw new Exception(
- "Configuration file does not specify pluginName");
- }
- } else {
- throw new Exception(
- "File in wrong format, expected "
- + DataArchiveConfig.class
- + ", found " + obj.getClass());
- }
- } catch (Throwable e) {
- statusHandler.error(
- "Failed to load archive configuration file: "
- + fileName, e);
- }
- }
- }
- }
-
- DataArchiveConfig defaultConf = configs.get(defaultPlugin);
- if (defaultConf == null) {
- // default plugin didn't load from disk, force a default config
- statusHandler
- .warn("Failed to find default configuration, using internal defaults");
- defaultConf = new DataArchiveConfig();
- defaultConf.setPluginName(defaultPlugin);
- configs.put(defaultPlugin, defaultConf);
- }
-
- if (!defaultConf.isArchivingEnabledSet()) {
- defaultConf.setArchivingEnabled(Boolean.TRUE);
- }
-
- if (!defaultConf.isCompressionEnabledSet()) {
- defaultConf.setCompressionEnabled(Boolean.TRUE);
- }
-
- if (!defaultConf.isHoursToKeepSet()) {
- defaultConf.setHoursToKeep(6);
- }
-
- // override unset fields with default
- for (DataArchiveConfig pluginConf : configs.values()) {
- if (pluginConf.getPluginName().equals(defaultPlugin)) {
- // skip default conf
- continue;
- }
-
- if (!pluginConf.isArchivingEnabledSet()) {
- pluginConf.setArchivingEnabled(defaultConf
- .getArchivingEnabled());
- }
-
- if (!pluginConf.isCompressionEnabledSet()) {
- pluginConf.setCompressionEnabled(defaultConf
- .getArchivingEnabled());
- }
-
- if (!pluginConf.isHoursToKeepSet()) {
- pluginConf.setHoursToKeep(defaultConf.getHoursToKeep());
- }
- }
-
- try {
- statusHandler.info("DefaultConfiguration:\n"
- + SerializationUtil.marshalToXml(defaultConf));
- } catch (Exception e) {
- statusHandler.handle(Priority.WARN, "Failed to deserialize config",
- e);
- }
- return configs;
- }
-}
diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java
deleted file mode 100644
index ba7ea799da..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/DataStoreArchiver.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * This software was developed and / or modified by Raytheon Company,
- * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
- *
- * U.S. EXPORT CONTROLLED TECHNICAL DATA
- * This software product contains export-restricted data whose
- * export/transfer/disclosure is restricted by U.S. law. Dissemination
- * to non-U.S. persons whether in the United States or abroad requires
- * an export license or other authorization.
- *
- * Contractor Name: Raytheon Company
- * Contractor Address: 6825 Pine Street, Suite 340
- * Mail Stop B8
- * Omaha, NE 68106
- * 402.291.0100
- *
- * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
- * further licensing information.
- **/
-package com.raytheon.uf.edex.maintenance.archive;
-
-import java.io.File;
-
-import com.raytheon.uf.common.datastorage.DataStoreFactory;
-import com.raytheon.uf.common.datastorage.IDataStore;
-import com.raytheon.uf.common.datastorage.StorageException;
-import com.raytheon.uf.common.datastorage.StorageProperties.Compression;
-import com.raytheon.uf.common.status.IUFStatusHandler;
-import com.raytheon.uf.common.status.UFStatus;
-import com.raytheon.uf.common.status.UFStatus.Priority;
-import com.raytheon.uf.edex.maintenance.archive.config.DataArchiveConfig;
-
-/**
- * Uses the repack feature of IDataStore to archive data by repacking it to a
- * specified compression at the hdf5 dataset level and moving the resulting file
- * to the archive dir.
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Dec 8, 2011 njensen Initial creation
- * Jan 14, 2013 1469 bkowal Removed the hdf5 data directory.
- * Jul 23, 2013 2216 rferrel Removed the time stamp filter in hdf5 copy.
- *
- *
- *
- * @author njensen
- * @version 1.0
- */
-
-public class DataStoreArchiver {
-
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(DataStoreArchiver.class);
-
- private Compression compression = Compression.NONE;
-
- public DataStoreArchiver(String compression) {
- this.compression = Compression.valueOf(compression);
- }
-
- public void archiveFiles(String[] hdf5Files, String archiveDir,
- DataArchiveConfig conf) {
- for (String hdf5File : hdf5Files) {
- IDataStore ds = DataStoreFactory.getDataStore(new File(hdf5File));
- String outputDir = archiveDir; // + dirs of hdf5 file
-
- try {
- // Do not perform time stamp check.
- ds.copy(outputDir, compression, null, 0, 0);
- } catch (StorageException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage());
- }
- }
- }
-}
diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java b/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java
deleted file mode 100644
index 406e9536a6..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.maintenance/src/com/raytheon/uf/edex/maintenance/archive/config/DataArchiveConfig.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/**
- * This software was developed and / or modified by Raytheon Company,
- * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
- *
- * U.S. EXPORT CONTROLLED TECHNICAL DATA
- * This software product contains export-restricted data whose
- * export/transfer/disclosure is restricted by U.S. law. Dissemination
- * to non-U.S. persons whether in the United States or abroad requires
- * an export license or other authorization.
- *
- * Contractor Name: Raytheon Company
- * Contractor Address: 6825 Pine Street, Suite 340
- * Mail Stop B8
- * Omaha, NE 68106
- * 402.291.0100
- *
- * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
- * further licensing information.
- **/
-package com.raytheon.uf.edex.maintenance.archive.config;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Data archive configuration. Configuration should be pulled from common_static
- * localization. Configuration with a pluginName of default will all to all
- * plugins.
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Jan 14, 2012 rjpeter Initial creation
- *
- *
- *
- * @author rjpeter
- * @version 1.0
- */
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class DataArchiveConfig {
- @XmlElement
- private String pluginName;
-
- @XmlElement
- private Integer hoursToKeep;
-
- @XmlElement
- private Boolean archivingEnabled;
-
- @XmlElement
- private Boolean compressionEnabled;
-
- /**
- * @return the pluginName
- */
- public String getPluginName() {
- return pluginName;
- }
-
- /**
- * @param pluginName
- * the pluginName to set
- */
- public void setPluginName(String pluginName) {
- this.pluginName = pluginName;
- }
-
- /**
- * @return the hoursToKeep
- */
- public Integer getHoursToKeep() {
- return hoursToKeep;
- }
-
- /**
- * @param hoursToKeep
- * the hoursToKeep to set
- */
- public void setHoursToKeep(Integer hoursToKeep) {
- this.hoursToKeep = hoursToKeep;
- }
-
- /**
- * @return the archivingEnabled
- */
- public Boolean getArchivingEnabled() {
- return archivingEnabled;
- }
-
- /**
- * @param archivingEnabled
- * the archivingEnabled to set
- */
- public void setArchivingEnabled(Boolean archivingEnabled) {
- this.archivingEnabled = archivingEnabled;
- }
-
- /**
- * @param compressionEnabled
- * the compressionEnabled to set
- */
- public void setCompressionEnabled(Boolean compressionEnabled) {
- this.compressionEnabled = compressionEnabled;
- }
-
- /**
- * @return the compressionEnabled
- */
- public Boolean getCompressionEnabled() {
- return compressionEnabled;
- }
-
- public boolean isArchivingEnabledSet() {
- return archivingEnabled != null;
- }
-
- public boolean isHoursToKeepSet() {
- return hoursToKeep != null;
- }
-
- public boolean isCompressionEnabledSet() {
- return (compressionEnabled != null);
- }
-}
diff --git a/edexOsgi/com.raytheon.uf.edex.maintenance/utility/common_static/base/archiver/defaultArchiveConfig.xml b/edexOsgi/com.raytheon.uf.edex.maintenance/utility/common_static/base/archiver/defaultArchiveConfig.xml
deleted file mode 100644
index 5f69229316..0000000000
--- a/edexOsgi/com.raytheon.uf.edex.maintenance/utility/common_static/base/archiver/defaultArchiveConfig.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- default
- 6
- false
- true
-
diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/InternalReport.java b/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/InternalReport.java
index e2d3642815..6a9582572c 100644
--- a/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/InternalReport.java
+++ b/edexOsgi/com.raytheon.uf.edex.plugin.lsr/src/com/raytheon/uf/edex/plugin/lsr/decoder/InternalReport.java
@@ -41,6 +41,7 @@ import org.apache.commons.logging.LogFactory;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 26, 2009 jkorman Initial creation
+ * Oct 23, 2013 DR 16674 D. Friedman Prevent infinite loop
*
*
*
@@ -238,8 +239,8 @@ public class InternalReport {
case DATE : {
if(currRpt != null) {
currRpt.subLines.add(r);
- reports.remove(r);
}
+ reports.remove(r);
break;
}
case REMARK : {
diff --git a/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml
index 49bff7ab36..10df591fb1 100644
--- a/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml
+++ b/edexOsgi/com.raytheon.uf.edex.text.feature/feature.xml
@@ -19,6 +19,7 @@
+
$NRLDBTMPFILE
-mv $NRLDBTMPFILE $NRLDBLOGFILE
-
-${WHFS_BIN}/nrldb.pl -t wfo -u
-
-#
diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/nrldb.pl b/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/nrldb.pl
deleted file mode 100644
index 409152e903..0000000000
--- a/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/nrldb.pl
+++ /dev/null
@@ -1,1415 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use DBI;
-use AppConfig qw(:expand :argcount);
-
-
-#Set/define command line args
-my %cfg = ( DEBUG => 0); # debug mode on or off
-my $config = AppConfig->new(\%cfg); # create config object
-$config->define('type',{ARGCOUNT => ARGCOUNT_ONE, VALIDATE => '(WFO|RFC|HQ|wfo|rfc|hq)', ALIAS => 'T'});
-$config->define('local-control-file',{ARGCOUNT => ARGCOUNT_ONE, ALIAS => 'L',DEFAULT => 0});
-$config->define('upload',{ARGCOUNT => ARGCOUNT_NONE, ALIAS => 'U', DEFAULT => 0});
-$config->define('wfo-id',{ARGCOUNT => ARGCOUNT_ONE, ALIAS => 'W', DEFAULT => 0});
-$config->define('rfc-id',{ARGCOUNT => ARGCOUNT_ONE, ALIAS => 'R', DEFAULT => 0});
-$config->define('out-xmlfile',{ARGCOUNT => ARGCOUNT_ONE, ALIAS => 'O', DEFAULT => 0});
-$config->define('input-xmlfile',{ARGCOUNT => ARGCOUNT_ONE, ALIAS => 'I', DEFAULT => 0});
-$config->define('check',{ARGCOUNT => ARGCOUNT_NONE, ALIAS => 'C', DEFAULT => 0});
-$config->define('verbose',{ARGCOUNT => ARGCOUNT_NONE, ALIAS => 'V', DEFAULT => 0});
-$config->define('dbname',{ARGCOUNT => ARGCOUNT_ONE, ALIAS => 'D', DEFAULT => 0});
-$config->define('extract',{ARGCOUNT => ARGCOUNT_NONE, ALIAS => 'E', DEFAULT => 0});
-$config->define('delete',{ARGCOUNT => ARGCOUNT_NONE, ALIAS => 'A', DEFAULT => 0});
-$config->getopt(\@ARGV);
-
-our $type = uc($config->get('type'));
-our $localControlFile = $config->get('local-control-file');
-our $Upload = $config->get('upload');
-our $wfoID = uc($config->get('wfo-id'));
-our $rfcID = uc($config->get('rfc-id'));
-our $outFile = $config->get('out-xmlfile');
-our $inFile = $config->get('input-xmlfile');
-our $check = $config->get('check');
-our $verbose = $config->get('verbose');
-our $dbname_flag = $config->get('dbname');
-our $extract = $config->get('extract');
-our $delete = $config->get('delete');
-our $office;
-our $update_count = 0;
-our $insert_count = 0;
-our $error_count = 0;
-our $total_count = 0;
-our $file_name;
-our $conf_dir;
-my ($dbname, $host, $user, $pass, $nrldb_host, $backup_host);
-my @delete_list;
-my $delete_listRef;
-print "db name flag: $dbname_flag\n";
-if($check) {
- warn "-----Starting NRLDB installation check-----\nInstallation Complete.\n";
- print "Installation Complete.\n";
- exit 0;
-}
-
-
-#Get config file info
-($dbname, $host, $user, $pass, $nrldb_host, $office, $backup_host) = read_config_file();
-
-if(!$dbname_flag)
-{
- if( -e "/awips/hydroapps/public/bin/get_apps_defaults")
- {
- $dbname = `/awips/hydroapps/public/bin/get_apps_defaults.LX db_name`;
- }
-}
-else{
- $dbname = $dbname_flag;
-}
-# Do parameter checks
-if($type eq "")
-{
- print "No office type specified.\nusage: --type WFO|RFC|HQ\n\n";
- exit 1;
-}
-if($type eq "HQ")
-{
- if($inFile eq 0)
- {
- print "No xml input file specified.\nusage: --type HQ --input-xmlfile 'file'\n\n";
- exit 1;
- }
- if($rfcID eq 0 && $wfoID eq 0)
- {
- print "You must specify a WFO/RFC office identifier with the HQ type.\n";
- exit 1;
- }
-
- unless($rfcID eq 0) {
- $office = $rfcID;
- }
- unless($wfoID eq 0) {
- $office = $wfoID;
- }
-
-}
-
-if($type eq "RFC")
-{
- if($rfcID eq 0)
- {
- print "You must specify an RFC office identifier with the rfc option.\nusage: --type RFC --rfc-id IDRFC\n\n";
- exit 1;
- }
-}
-
-
-#Connect to database
-our $db = db_connect($dbname, $host, $user, $pass);
-
-my $date = getdate();
-print "---Starting NRLDB process at $office\, running as $type\---\n---$date\n\n" if($verbose);
-warn "---Starting NRLDB process at $office\, running as $type\---\n---$date\n\n";
-print "Connected to database: $dbname\n" if($verbose);
-warn "Connected to database: $dbname\n";
-#Determine what type of office is running nrldb software
-if(($type eq "WFO") | ($type eq "RFC"))
-{
- if($localControlFile eq 0)
- {
- download_control_file($type);
- }
- create_xml();
- if($Upload)
- {
- upload_xml($nrldb_host);
- upload_xml($backup_host);
- }
-}
-elsif($type eq "HQ")
-{
- if($delete)
- {
- $delete_listRef = get_delete_list();
- @delete_list = @$delete_listRef;
- foreach my $delete_table (@delete_list)
- {
- deleteValues($delete_table);
- }
- }
- xml_parse();
-}
-
-print "\n-----------------------------\n\n" if($verbose);
-warn "\n-----------------------------\n\n";
-exit 0;
-
-
-# sub 'create_xml' is responsible for querying the database and putting the info into xml format.
-sub create_xml
-{
-
-my $table_name;
-my ($select_string, $field_string);
-my $xml_string;
-my $record_count;
-my ($st, $at);
-my $table_query;
-my $query_error_flag;
-my $numrows;
-my $lid_flag;
-my $pkey;
-my ($pk_name, $field_name);
-my $row;
-my $extract_detail;
-my %infohash;
-my @tables;
-my @fields;
-my @fields_all;
-my @select_array;
-my @PK;
-my @keys;
-my (@pk_output, @fields_output);
-
-#read control file and put specified fields into array
-my ($tables_ref, $fields_all_ref) = read_control_file();
-@tables = @$tables_ref;
-@fields_all = @$fields_all_ref;
-
- $extract_detail = '';
-# print "EXTRACT: $extract\n";
- unless($extract eq 0)
- {
- $extract_detail = extract_detail();
- }
-
-# Start creating xml
-$xml_string = "\n\n";
-foreach $table_name (@tables)
-{
-
- print "TABLE: $table_name\n" if($verbose);
- warn "TABLE: $table_name\n";
- $select_string = "";
- $lid_flag = 1;
- # Get primary key list for specified tables
- @keys = $db->primary_key(undef, undef, $table_name);
-
- foreach $pkey (@keys)
- {
- # The following 6 lines were by mark Armstrong (HSD) on 2/26/09
- # to remove the quotes from primary keys.
- # When primary keys occurred with quotes, the update queries
- # were not successful.
- if ($pkey =~ /"/){
- my $length_pkey = length $pkey;
- $length_pkey -= 2;
- my $new_pkey = substr($pkey,1,$length_pkey);
- $pkey=$new_pkey;
- }
- push(@PK, "$table_name.$pkey");
- }
-
- @pk_output = grep(/$table_name\.\w*/, @PK);
- print "\tPK: @pk_output\n" if($verbose);
- warn "\tPK: @pk_output\n";
- @fields_output = grep(/$table_name\.\w*/, @fields_all);
- print "\tFIELDS: @fields_output\n" if($verbose);
- warn "\tFIELDS: @fields_output\n";
-
- my $pk_count = @pk_output;
- if($pk_count == 0)
- {
- print "No Primary Keys found for Table: $table_name\nContinuing\n\n" if($verbose);
- warn "No Primary Keys found for Table: $table_name\nContinuing\n\n";
- next;
- }
-
- #loop through arrays and put together a select string for specified table
- foreach my $pk (@pk_output)
- {
- if($pk =~ /$table_name\.\w*/)
- {
- if($select_string eq "")
- {
- $select_string = "$pk";
- }
- else
- {
- $select_string .= ",$pk";
- }
- }
- }
-
-
- foreach my $fields (@fields_output)
- {
- if($select_string =~ /.*$fields.*/)
- {
- if($field_string eq "")
- {
- $field_string = "$fields";
- }
- else
- {
- $field_string .= ",$fields";
- }
- next;
- }
- elsif($fields =~ /.*ALL.*/)
- {
- $select_string = "*";
- last;
- }
- else
- {
- if($field_string eq "")
- {
- $field_string = "$fields";
- }
- else
- {
- $field_string .= ",$fields";
- }
- $select_string .= ",$fields";
- }
- }
-
-
- #print select string to be used
- print "\n" if($verbose);
- warn "\n";
- $query_error_flag = 0;
- #if select string equal 'ALL' get a list of all fields in specified table by querying database info tables.
- if($select_string eq "*")
- {
-
- my $query_column1 = "SELECT c.oid
- FROM pg_catalog.pg_class c
- LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
- WHERE pg_catalog.pg_table_is_visible(c.oid)
- AND c.relname ~ '^$table_name\$'";
-
- my $attribute_query = "SELECT a.attname
- FROM pg_catalog.pg_attribute a
- WHERE a.attnum > 0 AND NOT a.attisdropped
- AND a.attrelid = ($query_column1)
- ORDER BY a.attnum;";
-
- eval
- {
- $at = $db->prepare($attribute_query);
- $at->execute() or die "Cannot execute: ".$at->errstr();
- };
- if($@)
- {print "$@\n" if($verbose); warn "$@\n";}
-
- my $att_count = 0;
- while ( defined ( my $attribues = $at->fetchrow_arrayref() ) )
- {
- if($att_count > 0)
- {
- $select_string .= ",$table_name.@$attribues[0]";
- }
- else
- {
- $select_string = "$table_name.@$attribues[0]";
- }
- $att_count++;
- }
- $field_string = $select_string;
- }
-
- #Check for lid in table
- if($select_string !~ /$table_name\.lid/)
- {
- $lid_flag = lid_check($table_name);
- }
-
- # Determine query depending on office type and other parameters
- ## Revised query to properly select only counties from primary HSA or identified WFO - Ernie Wells February 09 ##
- if($type eq "WFO")
- {
- if($wfoID eq 0) {
- if($table_name =~ /location/)
- {
- $table_query = "SELECT $select_string FROM location, admin WHERE location.hsa = admin.hsa $extract_detail ORDER BY lid;";
- } elsif($table_name =~ /counties/) {
- $table_query = "SELECT $select_string FROM counties, admin WHERE counties.wfo = admin.hsa;";
- } elsif($table_name =~ /rpffcstgroup/) {
- $table_query = "SELECT distinct $select_string from rpffcstgroup join rpffcstpoint rp on rp.group_id = rpffcstgroup.group_id join location l on l.lid = rp.lid join admin on l.hsa = admin.hsa;";
- } elsif($table_name =~ /vtecevent/) {
- $table_query = "SELECT $select_string FROM vtecevent WHERE vtecevent.geoid in (select location.lid from location, admin where location.hsa = admin.hsa) $extract_detail;";
- } elsif($table_name eq "height" || $table_name =~ /temperature/ || $table_name =~ /curpp/ || $table_name =~ /curpc/ || $table_name eq "discharge"){
- my $cutoff_dtime = getcutoffdate();
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location, admin WHERE location.lid = $table_name.lid AND location.hsa = admin.hsa) and obstime > '$cutoff_dtime' $extract_detail ORDER BY lid;";
- } elsif($table_name =~ /fcstheight/ || $table_name =~ /fcstdischarge/) {
- my $cutoff_dtime = getcutoffdate();
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location, admin WHERE location.lid = $table_name.lid AND location.hsa = admin.hsa) and basistime > '$cutoff_dtime' $extract_detail ORDER BY lid;";
- } elsif($lid_flag == 1){
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location, admin WHERE location.lid = $table_name.lid AND location.hsa = admin.hsa) $extract_detail ORDER BY lid;";
- }
- else {
- $table_query = "SELECT $select_string FROM $table_name\;";
- }
- }
- else {
- if($table_name =~ /location/)
- {
- if($extract eq 0) {
- $table_query = "SELECT $select_string FROM location WHERE location.hsa = '$wfoID' $extract_detail ORDER BY lid;";
- } else {
- $table_query = "SELECT $select_string FROM location WHERE location.hsa like '%' $extract_detail ORDER BY lid;";
- }
- } elsif($table_name =~ /counties/) {
- if($extract eq 0) {
- $table_query = "SELECT $select_string FROM counties WHERE counties.wfo = '$wfoID';";
- } else {
- $table_query = "SELECT $select_string FROM counties WHERE counties.wfo in (select hsa from location where hsa is not null $extract_detail) ;";
- }
- } elsif($table_name =~ /rpffcstgroup/) {
- if($extract eq 0) {
- $table_query = "SELECT distinct $select_string from rpffcstgroup join rpffcstpoint rp on rp.group_id = rpffcstgroup.group_id join location l on l.lid = rp.lid where l.hsa = '$wfoID';";
- } else {
- my $rpgroup_extract_detail = $extract_detail;
- $rpgroup_extract_detail =~ s/lid/l.lid/g;
- $table_query = "SELECT distinct $select_string from rpffcstgroup join rpffcstpoint rp on rp.group_id = rpffcstgroup.group_id join location l on l.lid = rp.lid where l.hsa is not null $rpgroup_extract_detail;";
- }
- } elsif($table_name =~ /vtecevent/) {
- if($extract eq 0) {
- $table_query = "SELECT $select_string FROM vtecevent WHERE vtecevent.geoid in (select location.lid from location where location.hsa = '$wfoID') ;";
- } else {
- my $vtec_extract_detail = $extract_detail;
- $vtec_extract_detail =~ s/lid/geoid/g;
- print "vtec_extract_detail: $vtec_extract_detail\n";
- $table_query = "SELECT $select_string FROM vtecevent WHERE vtecevent.geoid in (select location.lid from location where location.hsa is not null) $vtec_extract_detail;";
- }
- } elsif($table_name eq "height" || $table_name =~ /temperature/ || $table_name =~ /curpp/ || $table_name =~ /curpc/ || $table_name eq "discharge"){
- my $cutoff_dtime = getcutoffdate();
- if($extract eq 0) {
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location WHERE location.lid = $table_name.lid AND location.hsa = '$wfoID') and obstime > '$cutoff_dtime' ORDER BY lid;";
- } else {
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location WHERE location.lid = $table_name.lid ) and obstime > '$cutoff_dtime' $extract_detail ORDER BY lid;";
- }
- } elsif($table_name =~ /fcstheight/ || $table_name =~ /fcstdischarge/) {
- my $cutoff_dtime = getcutoffdate();
- if($extract eq 0) {
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location WHERE location.lid = $table_name.lid AND location.hsa = '$wfoID') and basistime > '$cutoff_dtime' ORDER BY lid;";
- } else {
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location WHERE location.lid = $table_name.lid) and basistime > '$cutoff_dtime' $extract_detail ORDER BY lid;";
- }
- } elsif($lid_flag == 1) {
- if($extract eq 0) {
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location WHERE location.lid = $table_name.lid AND location.hsa = '$wfoID') $extract_detail ORDER BY lid;";
- } else {
- $table_query = "SELECT $select_string FROM $table_name WHERE exists (SELECT lid FROM location WHERE location.lid = $table_name.lid) $extract_detail ORDER BY lid;";
- }
- } else {
- $table_query = "SELECT $select_string FROM $table_name\;";
- }
- }
- } elsif($type eq "RFC") {
- if($table_name =~ /location/) {
- $table_query = "SELECT $select_string FROM location WHERE location.rfc='$rfcID' $extract_detail ORDER BY lid;";
- } elsif($lid_flag == 1) {
- $table_query = "SELECT $select_string from $table_name where exists (select lid from location where
-location.lid = $table_name.lid and location.rfc='$rfcID') $extract_detail ORDER BY lid;";
- # $table_query = "SELECT $select_string from $table_name where exists (select lid from location where
-#location.lid=rating.lid and location.rfc='$rfcID') $extract_detail ORDER BY lid;";
- } else {
- $table_query = "SELECT $select_string FROM $table_name\;";
- }
- }
-
- # print the query for log purpose and execute the query
- print "$table_query\n\n" if($verbose);
- warn "$table_query\n\n";
- $record_count = 0;
- eval
- {
- $st = $db->prepare($table_query);
- $row = $db->selectall_arrayref($st,{Slice => {}});
- #$st->execute() or die "Cannot execute: ".$st->errstr();
- };
- if ($@)
- {
- print "$@\n" if($verbose);
- warn "$@\n";
- $xml_string .= " \n";
- $query_error_flag = 1;
- }
-
- # if no db error continue adding info to xml file for the table.
- if($query_error_flag == 0)
- {
- $numrows = $st->rows;
- print "Number of records obtained: $numrows\n" if($verbose);
- warn "Number of records obtained: $numrows\n";
- if ($numrows == 0)
- {
- $xml_string .= " \n";
- }
- else
- {
- $xml_string .= " \n";
- }
-
- foreach my $sref (@$row)
- {
- %infohash=%{$sref};
- #print record number to xml file
- $xml_string .= " \n \n";
-
- #print primary key to xml file
- my $pk_count = 0;
- foreach my $pk (@pk_output)
- {
- if($pk =~ /$table_name\.(.*)/)
- {
- $pk_name=$1;
- #$infohash{$pk_name}=~ s/\r|\n//g;
- $xml_string .= " <$pk>$infohash{$pk_name}$pk>\n";
- $pk_count++;
- }
- }
- $xml_string .= " \n \n";
- @select_array = split(/,/, $field_string);
- #start printing fields to xml file
- my $field_count = 0;
- foreach my $select (@select_array)
- {
- if($select =~ /.*$table_name\.(.*)/)
- {
- $field_name = $1;
- if($infohash{$field_name} !~/^\s*$/)
- {
- #$infohash{$field_name} =~ s/\r|\n//g;
- $xml_string .= " <$select>$infohash{$field_name}$select>\n";
- }
- else
- {
- $xml_string .= " <$select/>\n";
- }
- $field_count++;
- }
- }
- $xml_string .=" \n";
- $xml_string .=" \n";
- $record_count++;
- }
-
- }
- if($numrows != 0 && $query_error_flag == 0)
- {
- $xml_string .="
\n";
- }
- @select_array = ();
- $field_string = "";
-
- print "\n---------------\n" if($verbose);
- warn "\n---------------\n";
-
-}
-$xml_string .="\n";
-
-if ($type eq "WFO" && $wfoID eq 0)
-{
- my $hsa_admin_query = "SELECT admin.hsa FROM admin;";
- my $st_admin;
- eval
- {
- $st_admin = $db->prepare($hsa_admin_query);
- $st_admin->execute() or die "Cannot execute: ".$st_admin->errstr();
- };
- if ($@)
- {
- print "$@\n" if($verbose);
- warn "$@\n";
- }
- while ( defined ( my $row = $st_admin->fetchrow_arrayref() ) )
- {
- $wfoID = @$row[0];
- }
-
-}
-
-if($type eq "WFO")
-{
- $file_name = "$wfoID\_from-$office\_nrldb.xml";
-}
-elsif($type eq "RFC")
-{
- $file_name = "$rfcID\_from-$office\_nrldb.xml";
-}
-
-
-#determine output file
-if($outFile eq 0)
-{
- $outFile = $file_name;
-}
-
-my $outDir;
-
-if( -e "/awips/hydroapps/public/bin/get_apps_defaults"){
- $outDir = `/awips/hydroapps/public/bin/get_apps_defaults.LX nrldb_data`;
-
- chomp($outDir);
-} else {
- print "Could not access /awips/hydroapps/public/bin/get_apps_defaults.LX. Exiting";
- exit -1;
-}
-
-$outFile = $outDir . "/" . $outFile;
-open(XMLFILE, ">$outFile") || die "Could not open $outFile for writing.\n$!\nExiting\n";
-printf XMLFILE "$xml_string";
-close(XMLFILE);
-
-my $end = $db->disconnect;
-zip_xml($outFile);
-}
-
-sub zip_xml
-{
-my $filename = shift;
-my $zip_string;
-
- $zip_string = "zip $filename.zip $filename";
- print "$zip_string\n" if($verbose);
- warn "$zip_string\n";
- my $zip_exe = `$zip_string`;
- print "$zip_exe\n" if($verbose);
- warn "$zip_exe\n";
- print "Failed: \"$zip_string\"\n" if ($? && $verbose);
- warn "Failed: \"$zip_string\"\n" if $?;
-}
-
-
-sub read_control_file
-{
-my @fields_all;
-my @tables;
-my @fields;
-my $table_name;
-my $control_file;
-
-if($localControlFile eq 0)
-{
- if($type eq "WFO")
- {
- $control_file = "${conf_dir}/nrldb_control_wfo";
- }
- elsif($type eq "RFC")
- {
- $control_file = "${conf_dir}/nrldb_control_rfc";
- }
-}
-else
-{
- $control_file = $localControlFile;
-}
-open(FILE, "$control_file") || die "Could not open control file: $control_file\n$!\nExiting\n";
-my @infile = ;
-close(FILE);
-
-foreach my $line (@infile)
-{
-chomp($line);
- if($line =~ /^#.*$/)
- {
- next;
- }
- elsif($line =~ /\[(.*)\]/)
- {
- $table_name = $1;
- push (@tables, $table_name);
- }
- elsif($line =~ /^(fields)/)
- {
- $line =~ /fields = (.*)/;
- @fields = split(/,/, $1);
-
- foreach my $tmp_field (@fields)
- {
- $tmp_field =~ s/\s*//;
- push(@fields_all, "$table_name.$tmp_field");
- }
- }
-}
-
-
-return (\@tables, \@fields_all);
-}
-
-sub extract_detail()
-{
-
-my $wfo = $office;
-my $wfo_fh_pointer = 0;
-my $info_found = 0;
-my ($ex_type, $ex_list);
-my @extract_lid;
-my $uclid;
-my $compare_symbol;
-my $extract_query = '';
-
-open(FILE, "nrldb_extract") || die "Could not open detail extract file nrldb_extract:\n$!\nExiting\n";
-my @infile = ;
-close(FILE);
-
- foreach my $line (@infile)
- {
- chomp($line);
- if($line =~ m/type:\s*(\w*)/)
- {$ex_type= $1;}
- if($line =~ m/list:\s*(.*)/)
- {
- $ex_list= $1;
- if(defined($ex_type) && defined($ex_list))
- {$info_found = 1;}
- }
-
- if($info_found eq 1)
- {last;}
- }
- if($info_found eq 1)
- {
- print "EXTRACT: $ex_type, [$ex_list]\n" if($verbose);
- warn "EXTRACT: $ex_type, [$ex_list]\n";
- @extract_lid = split(/,/,$ex_list);
-
- if(lc($ex_type) eq 'only')
- {$compare_symbol = '=';}
- elsif(lc($ex_type) eq 'except')
- {$compare_symbol = '!=';}
- else
- {
- print "Undefined extraction type '$ex_type', should be only|except\n" if($verbose);
- warn "Undefined extraction type '$ex_type', should be only|except\n";
- return($extract_query);
- }
- # The following has been modified by Mark Armstrong HSD
- # Originally, the query for multiple lids using the "only" extract
- # was incorrect. It used the AND condition for each lid which
- # would never be true. I added another if condition and a new
- # for loop to handle this case.
- if(lc($ex_type) eq 'only'){
- my $count = 0;
- $extract_query=" AND (";
- foreach my $lid (@extract_lid)
- {
- if($lid eq '')
- {next;}
-
- $uclid=uc($lid);
- $uclid =~ s/\s*//g;
- if ( $count eq 0)
- {
- $extract_query .= " lid $compare_symbol '$uclid'";
- }
- else
- {
- $extract_query .= " OR lid $compare_symbol '$uclid'";
- }
- $count = $count + 1;
- }
- $extract_query .= ") ";
- }
- else{
- foreach my $lid (@extract_lid)
- {
- if($lid eq '')
- {next;}
-
- $uclid=uc($lid);
- $uclid =~ s/\s*//g;
- $extract_query .= " AND lid $compare_symbol '$uclid'";
-
- }
- }
- }
- return($extract_query);
-}
-
-sub read_config_file()
-{
-
-my $dbname;
-my $host;
-my $pass;
-my $user;
-my $nrldb_host;
-my $site_conf;
-my $backup_host;
-my $conf_file;
-
-if( -e "/awips/hydroapps/public/bin/get_apps_defaults")
-{
- $conf_dir = `/awips/hydroapps/public/bin/get_apps_defaults.LX nrldb_config`;
- chomp($conf_dir);
- $conf_file = "${conf_dir}/nrldb.conf";
-}
-else
-{
- print "nrldb_conf token not specified. Exiting";
- exit -1;
-}
-open(FILE, "${conf_file}") || die "Could not open configuration ${conf_file}:\n$!\nExiting\n";
-my @infile = ;
-close(FILE);
-
- foreach my $line (@infile)
- {
- chomp($line);
- if($line =~ /(^\s*dbname\s*=\s*"(.*)")/)
- {
- $dbname = "$2";
- }
- elsif($line =~ /(^\s*dbhost\s*=\s*"(.*)")/)
- {
- $host = "$2";
- }
- elsif($line =~ /(^\s*dbpass\s*=\s*"(.*)")/)
- {
- $pass = "$2";
- }
- elsif($line =~ /(^\s*dbuser\s*=\s*"(.*)")/)
- {
- $user = "$2";
- }
- elsif($line =~ /(^\s*nrldb_host\s*=\s*"(.*)")/)
- {
- $nrldb_host = "$2";
- }
- elsif($line =~ /(^\s*site\s*=\s*"(.*)")/)
- {
- $site_conf = "$2";
- }
- elsif($line =~ /(^\s*backup_host\s*=\s*"(.*)")/)
- {
- $backup_host = "$2";
- }
-
- }
- return($dbname, $host, $user, $pass, $nrldb_host, $site_conf, $backup_host);
-}
-
-
-sub xml_parse
-{
-my $xmlfile = $inFile; # the file to parse
-my $lineCount = 0;
-my @rawLine;
-my $last_f;
-my $record_num;
-my $table;
-my ($i, $j, $k);
-my ($PK_name, $PK_value, $Field_name, $Field_value);
-sub insertValues($table, $record_num, $PK_name, $PK_value, $Field_name, $Field_value);
-
-print "Parsing and Inserting Values from $xmlfile into database\n\n" if($verbose);
-warn "Parsing and Inserting Values from $xmlfile into database\n\n";
-
-open(XML_FH, "$xmlfile") or die("Cant open file $xmlfile for reading: $!\nExiting\n");
-while ()
-{
- # $_ is the line that has set.
- $rawLine[$lineCount] = "$_";
- $lineCount++;
-}
-
-
-
-close(XML_FH);
-
-$i=0;
-
- while (!$last_f)
- {
- if ($rawLine[$i] =~ m//)
- {
- print "Current Table: $1\n" if($verbose);
- warn "Current Table: $1\n";
- $table = $1;
- while($rawLine[$i] !~ m/<\/Table>/)
- {
- if($rawLine[$i] =~ //)
- {
- $record_num = $1;
- while ($rawLine[$i] !~ m/<\/Record>/)
- {
- if($rawLine[$i] =~ //)
- { $i++;
- $j = 0;
- while($rawLine[$i] !~ m/<\/PK>/)
- {
- if($rawLine[$i] =~ m/<$table\.(.*?)>(.*)<\/$table\..*>/)
- {
- $$PK_name[$j] = $1;
- $$PK_value[$j] = $2;
- $j++;
- }
- elsif($rawLine[$i] =~ m/<$table\.(.*)\/>/)
- {
- $$PK_name[$j] = $1;
- $$PK_value[$j] = "NULL";
- $j++;
- }
- elsif($rawLine[$i] =~ m/<$table\.(.*?)>.*/)
- {
-
- {$$PK_name[$k] = $1;}
- $$PK_value[$j] = '';
- do
- {
- $$PK_value[$j] .= $rawLine[$i];
- $i++;
- } until ($rawLine[$i] =~ m/<\/$table\..*>$/);
- $$PK_value[$j] .= $rawLine[$i];
- $$PK_value[$j] =~ s/^\s*<$table\.(.*)>//g;
- $$PK_value[$j] =~ s/<\/$table\..*>$//g; #/
- $j++;
- }
- $i++;
- }
- }
- if($rawLine[$i] =~ //)
- { $i++;
- $k = 0;
- while($rawLine[$i] !~ m/<\/Fields>/)
- {
- if($rawLine[$i] =~ m/<$table\.(.*?)>(.*)<\/$table\..*>/)
- {
- $$Field_name[$k] = $1;
- $$Field_value[$k] = $2;
- $k++;
- }
- elsif($rawLine[$i] =~ m/<$table\.(.*)\/>/)
- {
- $$Field_name[$k] = $1;
- $$Field_value[$k] = "NULL";
- $k++;
- }
- elsif($rawLine[$i] =~ m/<$table\.(.*?)>.*/)
- {
-
- {$$Field_name[$k] = $1;}
- $$Field_value[$k] = '';
- do
- {
- $$Field_value[$k] .= $rawLine[$i];
- $i++;
- } until ($rawLine[$i] =~ m/<\/$table\..*>$/);
- $$Field_value[$k] .= $rawLine[$i];
- $$Field_value[$k] =~ s/^\s*<$table\.(.*)>//g;
- $$Field_value[$k] =~ s/<\/$table\..*>$//g; #/
- $k++;
- }
- $i++;
- }
- }
- $i++;
- }
- &insertValues($table, $record_num, $PK_name, $PK_value, $Field_name, $Field_value);
- $#$PK_name = -1; $#$PK_value = -1; $#$Field_name = -1; $#$Field_value = -1;
- $total_count++;
- }
- $i++;
- }
- print "\tTotal Inserts: $insert_count\n" if($verbose);
- warn "\tTotal Inserts: $insert_count\n";
- print "\tTotal Updates: $update_count\n" if($verbose);
- warn "\tTotal Updates: $update_count\n";
- print "\tTotal Errors: $error_count\n" if($verbose);
- warn "\tTotal Errors: $error_count\n";
- print "\tTOTAL: $total_count\n\n" if($verbose);
- warn "\tTOTAL: $total_count\n\n";
- $insert_count = 0;
- $update_count = 0;
- $error_count = 0;
- $total_count = 0;
- }
- elsif ($rawLine[$i] =~ /<\/NRLDB>/)
- {$last_f = 1;}
- else
- {$i++;}
- }
-
-}
-
-sub get_delete_list
-{
- my @list;
- my $table;
-
- open(FILE, "${conf_dir}/nrldb_control_delete") || die "Could not open detail extract file ${conf_dir}/nrldb_control_delete:\n$!\nExiting\n";
- my @infile = ;
- close(FILE);
-
- foreach my $line (@infile)
- {
- chomp($line);
- if($line =~ m/^\s*#/)
- {next;}
-
- if($line =~ m/^\s*\w+\s*$/)
- {
- $line =~ s/\s*//g;
- $table=lc($line);
- push(@list, $table);
- }
- }
-
- return(\@list);
-}
-
-sub deleteValues
-{
- my $deleteTable = shift;
- my $deleteWFO = $office;
- my $lid_flag = lid_check($deleteTable);
- my ($delete_query, $st);
-
- my ($delete_detail, $total);
-
- if($lid_flag == 1)
- {
- ($delete_detail, $total)=getDeleteLid($deleteTable);
- if($total !=0)
- {
- $delete_query = "DELETE FROM $deleteTable $delete_detail\;";
- print "DELETE: $delete_query\n";
- }
- }
- else
- {
- $delete_query = "DELETE FROM $deleteTable\;";
- }
-
- eval
- {
- $st = $db->prepare($delete_query);
- $st->execute() or die "Cannot execute: ".$st->errstr();
- };
- if($@)
- {print "$@\n" if($verbose); warn "$@\n";}
-
-}
-
-
-sub getDeleteLid
-{
-
-my $xmlfile = $inFile; # the file to parse
-my $lineCount = 0;
-my @rawLine;
-my $last_f;
-my $record_num;
-my $table;
-my ($i, $j, $k);
-my $lid_name;
-
-my $deleteTable = shift;
-my $total_count = 0;
-
-open(XML_FH, "$xmlfile") or die("Cant open file $xmlfile for reading: $!\nExiting\n");
-while ()
-{
- # $_ is the line that has set.
- $rawLine[$lineCount] = "$_";
- $lineCount++;
-}
-
-close(XML_FH);
-
-$i=0;
-my $delete_str = "";
-my $last_lid = -1;
- while (!$last_f)
- {
- if ($rawLine[$i] =~ m//)
- {
- print "Delete Table: $1\n" if($verbose);
- warn "Delete Table: $1\n";
- $table = $1;
- while($rawLine[$i] !~ m/<\/Table>/)
- {
- if($rawLine[$i] =~ //)
- {
- $record_num = $1;
- while ($rawLine[$i] !~ m/<\/Record>/)
- {
- if($rawLine[$i] =~ //)
- { $i++;
- while($rawLine[$i] !~ m/<\/PK>/)
- {
- if($rawLine[$i] =~ m/<$table\.lid>(.*)<\/$table\.lid>/)
- {
- if(($last_lid != -1) && ($last_lid eq $1))
- {$i++; next;}
- #print "$1\n";
- if ($total_count == 0)
- {
- $delete_str .= "WHERE $table.lid = '$1'";
- }
- else
- {
- $delete_str .= " OR $table.lid = '$1'";
- }
-
- $last_lid = $1;
-
- }
- $i++;
- }
- }
- $i++;
- }
- $total_count++;
- }
- $i++;
- }
- print "\tTotal Delete LIDs: $total_count\n" if($verbose);
- warn "\tTotal Delete LIDs: $total_count\n";
- $last_f = 1;
- }
- elsif ($rawLine[$i] =~ /<\/NRLDB>/)
- {$last_f = 1;}
- else
- {$i++;}
- }
- #print "$delete_str, $total_count\n";
- return ($delete_str, $total_count);
-
-}
-
-
-sub insertValues($table, $record_num, $PK_name, $PK_value, $Field_name, $Field_value)
-{
- my $num;
- my ($fields, $values);
- my ($update_set, $update_where);
- my $Field_value_quoted;
- my $table = shift;
- my $record_num = shift;
- my $PK_name = shift;
- my $PK_value = shift;
- my $Field_name = shift;
- my $Field_value = shift;
- my $update_flag = 0;
- my $st_handle;
- my $insertrows;
-
- for($num = 0; $num <= $#$Field_value; $num++)
- {
- if($num == 0)
- {
- $fields = "($$Field_name[$num]";
- if($$Field_value[$num] ne "NULL")
- {
- $$Field_value[$num] = $db->quote($$Field_value[$num]);
- $values = "($$Field_value[$num]";
- $update_set = "$$Field_name[$num]=$$Field_value[$num]";
- }
- else
- {
- $values = "($$Field_value[$num]";
- $update_set = "$$Field_name[$num]=$$Field_value[$num]";
- }
- }
- else
- {
- $fields .= ", $$Field_name[$num]";
- if($$Field_value[$num] ne "NULL")
- {
- $$Field_value[$num] =~ s/\n//g;
- $$Field_value[$num] =~ s/\r//g;
- $$Field_value[$num] = $db->quote($$Field_value[$num]);
- $values .= ", $$Field_value[$num]";
- $update_set .= ", $$Field_name[$num]=$$Field_value[$num]";
- }
- else
- {
- $values .= ", $$Field_value[$num]";
- $update_set .= ", $$Field_name[$num]=$$Field_value[$num]";
- }
- }
- }
- for($num = 0; $num <= $#$PK_name; $num++)
- {
- if($num == 0)
- {
- $$PK_value[$num] = $db->quote($$PK_value[$num]);
- $update_where = "$$PK_name[$num]=$$PK_value[$num] ";
- }
- else
- {
- $$PK_value[$num] = $db->quote($$PK_value[$num]);
- $update_where .= "AND $$PK_name[$num]=$$PK_value[$num]";
- }
- }
-
- $fields .= ")";
- $values .= ")";
- my $insert_cmd = "INSERT INTO $table $fields VALUES $values\;";
- my $update_cmd = "UPDATE $table SET $update_set WHERE $update_where\;";
-
- eval {
- $insert_count++;
- $st_handle = $db->prepare($insert_cmd);
- $st_handle->execute() or die "Cannot execute: ".$st_handle->errstr();
- $insertrows = $st_handle->rows();
- if($insertrows == 0)
- {
- $insert_count--;
- $error_count++;
- print "ZERO ROWS FOR QUERY: $insert_cmd\n\n" if($verbose);
- warn "ZERO ROWS FOR QUERY: $insert_cmd\n\n";
- }
- };
-
- if ($@) {
- if($@ =~ /duplicate key/)
- {
- $update_flag = 1;
- $insert_count--;
- }
- else
- {
- print "$@\n" if($verbose);
- warn "$@\n";
- $insert_count--;
- $error_count++;
- print "INSERT ERROR ON QUERY: $insert_cmd\n\n" if($verbose);
- warn "INSERT ERROR ON QUERY: $insert_cmd\n\n";
-
- }
- }
-
- if($update_flag == 1)
- {
- eval {
- $update_count++;
- $st_handle = $db->prepare($update_cmd);
- $st_handle->execute() or die "Cannot execute: ".$st_handle->errstr();
- $insertrows = $st_handle->rows();
- if($insertrows == 0)
- {
- $update_count--;
- $error_count++;
- print "ZERO ROWS FOR QUERY: $update_cmd\n\n" if($verbose);
- warn "ZERO ROWS FOR QUERY: $update_cmd\n\n";
- }
- };
-
- if ($@) {
- print "$@\n" if($verbose);
- warn "$@\n";
- $update_count--;
- $error_count++;
- print "UPDATE ERROR ON QUERY: $update_cmd\n\n" if($verbose);
- warn "UPDATE ERROR ON QUERY: $update_cmd\n\n";
- }
- }
-
-}
-
-
-sub db_connect
-{
-my $dbname = shift;
-my $host = shift;
-my $user = shift;
-my $pass = shift;
-
-my %db_attr = (
- PrintError => 0,
- RaiseError => 0,
-);
-
-my $dsn = "DBI:Pg:dbname=$dbname;host=$host";
-my $db = DBI->connect($dsn, $user, $pass, \%db_attr) or die "Can't connect() to database $dbname: $DBI::errstr";
-return ($db);
-}
-
-sub upload_xml
-{
- print "---UPLOAD XML FILE----\n" if($verbose);
- warn "---UPLOAD XML FILE----\n";
- my $upload_string = "rsync -av --chmod=ugo+rw $outFile.zip $nrldb_host\::nrldb_xml/";
- print "$upload_string\n" if($verbose);
- warn "$upload_string\n";
- my $upload_exe = `$upload_string`;
- print "$upload_exe\n" if($verbose);
- warn "$upload_exe\n";
- print "Failed: \"$upload_string\"\n" if ($? && $verbose);
- warn "Failed: \"$upload_string\"\n" if $?;
- return;
-}
-sub download_control_file
-{
- my $office_type = shift;
- my $download_string;
- print "---DOWNLOAD $office_type CONTROL FILE----\n" if($verbose);
- warn "---DOWNLOAD $office_type CONTROL FILE----\n";
-
- if ($office_type eq "WFO")
- {
- $download_string = "rsync -av $nrldb_host\::nrldb_control/nrldb_control_wfo ${conf_dir}/";
- }
- elsif ($office_type eq "RFC")
- {
- $download_string = "rsync -av $nrldb_host\::nrldb_control/nrldb_control_rfc ${conf_dir}/";
- }
- print "$download_string\n" if($verbose);
- warn "$download_string\n";
- my $download_exe = `$download_string`;
- print "$download_exe\n" if($verbose);
- warn "$download_exe\n";
- print "Failed: \"$download_string\"\n" if ($? && $verbose);
- warn "Failed: \"$download_string\"\n" if $?;
- return;
-}
-
-sub getdate()
-{
-my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time) ;
-my $RealMonth = $Month + 1 ; # Months of the year are not zero-based
-my $FixedYear;
-
-if ($Hour < 10)
-{
- $Hour = "0" . $Hour
-}
-
-if ($Minute < 10)
-{
- $Minute = "0" . $Minute
-}
-
-if ($Second < 10)
-{
- $Second = "0" . $Second
-}
-
-if ($RealMonth < 10)
-{
- $RealMonth = "0" . $RealMonth;
-}
-
-if ($Day < 10)
-{
- $Day = "0" . $Day;
-}
-
-if ($Year >= 100)
-{
- $FixedYear = $Year - 100;
-}
-else
-{
- $FixedYear = $Year;
-}
-
-if ($FixedYear < 10)
-{
- $FixedYear = "0" . $FixedYear;
-}
-
-my $clean_date = "$Hour:$Minute:$Second $RealMonth/$Day/$FixedYear";
-
-return($clean_date);
-}
-
-sub lid_check {
- my $table_name = shift;
- my $at;
- my $lid_flag = 0;
-
- my $query_column1 = "SELECT c.oid
- FROM pg_catalog.pg_class c
- LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
- WHERE pg_catalog.pg_table_is_visible(c.oid)
- AND c.relname ~ '^$table_name\$'";
-
- my $attribute_query = "SELECT a.attname
- FROM pg_catalog.pg_attribute a
- WHERE a.attnum > 0 AND NOT a.attisdropped
- AND a.attrelid = ($query_column1)
- ORDER BY a.attnum;";
-
- eval {
- $at = $db->prepare($attribute_query);
- $at->execute() or die "Cannot execute: ".$at->errstr();
- };
- if($@) {
- print "$@\n";
- }
-
- while ( defined ( my $attribues = $at->fetchrow_arrayref() ) ) {
- if(@$attribues[0] =~ /^lid$/) {
- $lid_flag = 1;
- }
- }
-
-return ($lid_flag);
-}
-
-BEGIN {
- use CGI::Carp qw(carpout);
- my $logDir;
- if( -e "/awips/hydroapps/public/bin/get_apps_defaults"){
- $logDir = `/awips/hydroapps/public/bin/get_apps_defaults.LX nrldb_log`;
- chomp($logDir);
- } else {
- print "Could not access /awips/hydroapps/public/bin/get_apps_defaults.LX. Exiting\n";
- exit -1;
- }
- print "log dirlogDir\n";
- my $log = "${logDir}/nrldb.log";
- open(LOG, ">>$log") or die "Unable to open $log. $! ";
- carpout(*LOG);
-}
-
-END {
- my $date = `date`;
- print LOG "End $0 at $date\tElapsed time: " . (time - $^T) . " seconds\n\n";
- close LOG;
-}
-
-sub getcutoffdate()
-{
-my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = gmtime(time-172800) ;
-my $RealMonth = $Month + 1 ; # Months of the year are not zero-based
-my $FixedYear;
-
-if ($Hour < 10)
-{
- $Hour = "0" . $Hour
-}
-
-if ($Minute < 10)
-{
- $Minute = "0" . $Minute
-}
-
-if ($Second < 10)
-{
- $Second = "0" . $Second
-}
-
-if ($RealMonth < 10)
-{
- $RealMonth = "0" . $RealMonth;
-}
-
-if ($Day < 10)
-{
- $Day = "0" . $Day;
-}
-
- $FixedYear = $Year + 1900;
-
-my $clean_date = "$FixedYear-$RealMonth-$Day $Hour:$Minute";
-
-return($clean_date);
-}
diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/send_nrldb_update.sh b/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/send_nrldb_update.sh
deleted file mode 100644
index 4710156c93..0000000000
--- a/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/send_nrldb_update.sh
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/bin/sh
-###############################################################################
-# This script is run at the field office to send ad-hoc updates to the NRLDB
-# server, then on to the AHPS CMS. It can be run at any time. It is designed
-# to send small, time-sensitive updates to the CMS. It takes two argument
-# lists:-table table names (comma-separated) and -lid lid names
-# (comma-separated). It parses the arguments, selects the updated data from
-# the database and builds an SQL formatted text file for use on the nrldb and
-# CMS databases. The SQL file contains a delete staement that deletes the
-# pre-existing data for the lid/table combinations, before running the inserts
-#
-# Usage: send_nrldb_update.sh -table ,,... -lid ,,...
-# Example: send_nrldb_update.sh -table rating,floodstmt -lid BRKM2,CBEM2
-#
-if [ $# -ne 4 ]
-then
- echo "Incorrect number of arguments entered: $#"
- echo "Correct Arguments are:"
- echo "send_nrldb_update.sh -table table1,table2 -lid lid1,lid2"
- echo "Any number of tables and lids may be specified, but they need to be in a comma separated list with no spaces between commas and table/lid names"
- exit 0
-fi
-# set up SOME environment variables for NRLDB applications
-export apps_dir=/awips2/edex/data/share/hydroapps
-export EDEX_HOME=/awips2/edex
-export NRLDB_DATA=`get_apps_defaults nrldb_data`
-export NRLDB_LOG=$(get_apps_defaults nrldb_log)
-export NRLDB_CONFIG=$(get_apps_defaults nrldb_config)
-export db_name=$(get_apps_defaults db_name)
-export NRLDB_TMP=$(get_apps_defaults nrldb_tmp)
-export PGUSER=awips
-
-# get the nrldb host and wfo from the nrldb.conf file/database
-nrldb_host=`grep nrldb_host $NRLDB_CONFIG/nrldb.conf | cut -d= -f2 | sed 's/"//g' | sed 's/ //g'`
-wfo=`psql -d $db_name -c "select hsa from admin;" | tail -3 | head -1 | sed -e 's/ //g'`
-echo `date`
-
-# create the final SQL file that will be sent to the NRLDB host
-timestamp=`date +%Y%m%d%H%N`
-sql_file="${wfo}_update_${timestamp}.sql"
-if [ -f $sql_file ]
-then
- rm $sql_file
-fi
-
-# build the list of tables/lids to send
-lid_list="XXXXX"
-table_list="XXXXX"
-while [ $# -gt 0 ]
-do
- case "$1" in
- -lid) lid_list="$2,";shift;;
- -table) table_list="$2,";shift;;
- *) break;;
- esac
- shift
-done
-
-# set the last update information for update_nrldb.pl to use
-echo `date` > ${NRLDB_LOG}/last_nrldb_update.txt
-up_lid_list=`echo $lid_list | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
-echo "lid list: $up_lid_list" >> ${NRLDB_LOG}/last_nrldb_update.txt
-echo "table_list: $table_list" >> ${NRLDB_LOG}/last_nrldb_update.txt
-
-#loop through the tables/lids
-if [ $table_list != "XXXXX" ]
-then
- pos=1
- table="XXXXX"
- ltable=`echo $table | wc -m`
- while [ $ltable -gt 4 ]
- do
- table=`echo $table_list | cut -d"," -f$pos`
- pos=`expr $pos + 1`
- ltable=`echo $table | wc -m`
- if [ $ltable -gt 4 ]
- then
- lid="XXXXX"
- lpos=1
- llid=`echo $lid | wc -m`
- while [ $llid -gt 3 ]
- do
- lid=`echo $up_lid_list | cut -d"," -f$lpos`
- lpos=`expr $lpos + 1`
- llid=`echo $lid | wc -m`
- if [ $llid -gt 3 ]
- then
- # fetch the values from the DB and edit them
- export PGUSER=awips
- touch $NRLDB_TMP/update.txt
- chmod ugo+rw $NRLDB_TMP/update.txt
- ls -l $NRLDB_TMP/update.txt
- psql -d $db_name -c "copy (select * from $table where lid = '$lid') to '$NRLDB_TMP/update.txt' with delimiter '|';"
- cp $NRLDB_TMP/update.txt ${NRLDB_DATA}/update.txt
- sed -f ${NRLDB_CONFIG}/sed_script.txt ${NRLDB_TMP}/update.txt > ${NRLDB_DATA}/update11.txt
- sed -e "s/|/'|'/g" ${NRLDB_DATA}/update11.txt > ${NRLDB_DATA}/update1.txt
- sed -e "s/^/insert into $table values('/g" ${NRLDB_DATA}/update1.txt > ${NRLDB_DATA}/update2.txt
- sed -e "s/$/');/g" ${NRLDB_DATA}/update2.txt > ${NRLDB_DATA}/update3.txt
- sed -e "s/|/,/g" ${NRLDB_DATA}/update3.txt > ${NRLDB_DATA}/update4.txt
- if [ -f "${NRLDB_DATA}/update.txt" ]
- then
- update_lines=`wc -l "${NRLDB_DATA}/update.txt" | cut -d" " -f1`
- else
- echo "No update file found".
- update_lines=0
- fi
- if [ $update_lines -gt 0 ]
- then
- if [ $table != "location" -a $table != "riverstat" ]
- then
- echo "delete from $table where lid = '$lid';" >> ${NRLDB_DATA}/$sql_file
- fi
- cat ${NRLDB_DATA}/update4.txt >> ${NRLDB_DATA}/$sql_file
- fi
- # location and riverstat require a special forecast since they have dependent tables via foreign keys
- if [ $table = "location" ]
- then
- sql_stmt="update location set lid = '$lid'"
- for col in county coe cpm detail elev hdatum hsa hu lat lon lremark lrevise name network rb rfc sbd sn state waro wfo wsfo type des det post stntype tzone
- do
- psql -d $db_name -c "select $col from location where lid = '$lid' and $col is not null;" > ${NRLDB_DATA}/update.txt
- ct_zero=`grep -c "0 row" ${NRLDB_DATA}/update.txt`
- if [ $ct_zero -eq 0 ]
- then
- export val=`cat ${NRLDB_DATA}/update.txt | head -3 | tail -1 | cut -c2-80`
- new_val=`echo "$val" | sed -f ${NRLDB_CONFIG}/sed_script.txt`
- sql_stmt="$sql_stmt, $col = '$new_val'"
- fi
- done
- sql_stmt="$sql_stmt where lid = '$lid';"
- echo $sql_stmt >> ${NRLDB_DATA}/$sql_file
-
- elif [ $table = "riverstat" ]
- then
- sql_stmt="update riverstat set lid = '$lid'"
- for col in primary_pe bf cb da response_time threshold_runoff fq fs gsno level mile pool por rated lat lon remark rrevise rsource stream tide backwater vdatum action_flow wstg zd ratedat usgs_ratenum uhgdur use_latest_fcst
- do
- psql -d $db_name -c "select $col from riverstat where lid = '$lid' and $col is not null;" > ${NRLDB_DATA}/update.txt
- ct_zero=`grep -c "0 row" ${NRLDB_DATA}/update.txt`
- if [ $ct_zero -eq 0 ]
- then
- export val=`cat ${NRLDB_DATA}/update.txt | head -3 | tail -1 | cut -c2-80`
- new_val=`echo "$val" | sed -f ${NRLDB_CONFIG}/sed_script.txt`
- sql_stmt="$sql_stmt, $col = '$new_val'"
- fi
- done
- sql_stmt="$sql_stmt where lid = '$lid';"
- echo $sql_stmt >> ${NRLDB_DATA}/$sql_file
- fi
- fi
- done
- fi
-
- done
-
- # send the SQL file to the NRLDB server
- if [ -f ${NRLDB_DATA}/$sql_file ]
- then
- rsync -av ${NRLDB_DATA}/$sql_file ${nrldb_host}\::nrldb_update/
- echo "SQL file: $sql_file created for lids: $up_lid_list and tables: $table_list"
- else
- echo "No SQL file created. Database contained no entries for lids: $up_lid_list and tables: $table_list"
- fi
-fi
-
-# remove the temp files to keep the directory clean
-for temp_file in ${NRLDB_DATA}/update.txt ${NRLDB_DATA}/update11.txt ${NRLDB_DATA}/update1.txt ${NRLDB_DATA}/update2.txt ${NRLDB_DATA}/update3.txt ${NRLDB_DATA}/update4.txt
-do
- if [ -f $temp_file ]
- then
- rm $temp_file
- fi
-done
diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/update_nrldb.pl b/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/update_nrldb.pl
deleted file mode 100644
index 0a0a08728c..0000000000
--- a/nativeLib/files.native/awipsShare/hydroapps/whfs/bin/update_nrldb.pl
+++ /dev/null
@@ -1,274 +0,0 @@
-#!/usr/bin/perl
-################################################################################
-# update_nrldb.pl is the GUI for the Ad-Hoc update process. ## This process was put in place so that WFOs could update information #
-# between daily runs of the NRLDB update process. The information is #
-# collected at the WFO, sent to the NRLDB central server and then forwarded to #
-# CMS servers outside of the AWIPS firewall. #
-# #
-# Developer: Mark Armstrong (OCWWS/HSD) #
-# Developed 2011 - Modified for AWIPS2 2013 #
-################################################################################
-
-use Tk;
-use strict;
-use warnings;
-use AppConfig qw(:expand :argcount);
-use DBI;
-
-$ENV{EDEX_HOME}="/awips2/edex";
-$ENV{apps_dir}="/awips2/edex/data/share/hydroapps";
-our $BIN_DIR = `get_apps_defaults.LX whfs_bin_dir`;
-chomp($BIN_DIR);
-our $LOG_DIR = `get_apps_defaults.LX nrldb_log`;
-chomp($LOG_DIR);
-my $lids;
-my $tables;
-
-# Set up some inial configuration. Most of this comes from the hydroGen input file: hg.cfg
-$ENV{HYDROGENHOME} = "/awips/hydroapps/HydroGen" if ! defined $ENV{HYDROGENHOME};
-my %cfg = ( DEBUG => 0, # debug mode on or off
- PEDANTIC => 0, # be patient with warnings/errors
- CREATE => 1, # create variables, defining not required...
- GLOBAL => { # for all config options unless overridden...
- EXPAND => EXPAND_ALL, # expand ~, $ENV{*}, and $(var)
- ARGCOUNT => ARGCOUNT_ONE, # each config expects an arg unless overriden...
- ARGS => '=s' # each arg is a string unless overriden
- }
- );
-
-my $config = AppConfig->new(\%cfg); # create config object
-
-$config->define('version',{ ALIAS => 'V',ARGCOUNT => ARGCOUNT_NONE, ARGS => '!',DEFAULT => 0});
-$config->define('help',{ ALIAS => 'h',ARGCOUNT => ARGCOUNT_NONE, ARGS => '!',DEFAULT => 0});
-$config->define('man',{ ALIAS => 'm',ARGCOUNT => ARGCOUNT_NONE, ARGS => '!',DEFAULT => 0});
-$config->define('DBengine',{ VALIDATE => '[\w]+',DEFAULT => "Pg"});
-$config->define('DBname',{ VALIDATE => '[\w]+',DEFAULT => "hd_ob8xxx"});
-$config->define('DBhost',{ VALIDATE => '[-\w]+',DEFAULT => "dx1f"});
-$config->define('DBport',{ ARGS => '=i',DEFAULT => 5432});
-$config->define('master',{ VALIDATE => '[.\w]+',DEFAULT => "HGstation"});
-$config->define('basedir',{ VALIDATE => '[- /.\w]+',DEFAULT => $ENV{HYDROGENHOME} . "/bin"});
-
-$config->file($ENV{HYDROGENHOME} . "/input/hg.cfg"); # look in user's $HYDROGENHOME to find configured settings
-$config->args(\@ARGV); # get config settings from the command-line, overwriting any settings from the file...
-
-my $master = $config->get('master'); # name of DB table or view which holds master list of IDs for which MXD files are to be generated...
-my $DBengine = $config->get('DBengine');
-my $DBname = $config->get('DBname');
-my $DBhost = $config->get('DBhost');
-my $DBport = $config->get('DBport');
-my $baseDir = `pwd`;
-chomp $baseDir;
-my $DBstr;
-my $wildcard;
-
-#Open a database connection and get the list of LIDs from the IHFS DB
-if($DBengine eq "Pg") {
- $DBstr = "dbi:$DBengine:dbname=$DBname;host=$DBhost;port=$DBport";
- $wildcard = '%';
-} else {
- $DBstr = "dbi:$DBengine:$DBname";
- $wildcard = '*';
-}
-
-my $dbh = DBI->connect("$DBstr",undef,undef,{ChopBlanks => 1}) or warn $DBI::errstr;
-# creates the list of WFOs based on the HydroGen .xxx_backup files
-# and builds the query to create the list of LIDs
-my $wfo=`ls -a /awips/hydroapps/HydroGen/ | grep _backup | cut -c2-4`;
-my $list_len=length $wfo;
-my $num_wfos=$list_len/4;
-my $index=1;
-my $off=0;
-my $wfoid=substr($wfo,$off,3);
-my $wfoID=uc $wfoid;
-my $wfo_query = "(location.hsa = \'$wfoID\'";
-while ($index < $num_wfos){
- $off+=4;
- $wfoid=substr($wfo,$off,3);
- $wfoID=uc $wfoid;
- $wfo_query .= " or location.hsa = \'$wfoID\'";
- $index++;
-}
-$wfo_query .= ")";
-
-#my $list_type="river";
-our $mw = MainWindow->new;
-$mw->title('Ad-Hoc NRLDB Update');
-
-my $lst_lab= $mw->Label(-text => 'Add any Unlisted Locations (comma-separated): ');
-my $sql = "select distinct hgstation.lid,location.name,location.hsa from hgstation,location where hgstation.lid = location.lid and $wfo_query order by 3,1;";
-
-# get the list of LIDs
-my $qhw = $dbh->prepare("$sql") or warn $DBI::errstr;
-
-our @lid_list; # = ($wildcard);
-
-#get the data from the DB
-get_results($qhw,\@lid_list);
-#print "ct: " . @lid_list;
-
-#set up a static array with the tables that are allowed for ad-hoc updates
-#table_list is the actual name of the DB tables, while tabledesc is a friendlier description that is displayed to the user
-our @table_list = ('location','riverstat','crest','floodstmt','hgstation','floodcat','lowwater');
-my @tabledesc = ('Location','Riverstat','Crest History','Impacts','HGstation','Flood Categories','Low Water');
-
-$dbh->disconnect();
-
-#manipulate the results of the lid/hsa/name query for better display
-my @liddeschsa;
-our @lidsend;
-$index=0;
-my $num_lids=scalar(@lid_list);
-while ($index < $num_lids){
- my $line = $lid_list[$index];
-# print "line: $line\n";
- my @results = split('\|',$line);
- #my $lid = $lid_list[$index];
- my $lid_lid = $results[0];
- my $lid_name = $results[1];
- my $lid_hsa = $results[2];
-# print "lid: $lid_lid name: $lid_name hsa: $lid_hsa\n";
- push(@liddeschsa,"$lid_hsa | $lid_lid | $lid_name");
- push(@lidsend,$lid_lid);
- $index++;
-}
-
-# Create the GUI object
-#my $mw = MainWindow->new;
-#$mw->title('Ad-Hoc NRLDB Update');
-
-#my $lst_lab= $mw->Label(-text => 'Locations List: ');
-#my $lst_rad_riv = $mw-> Radiobutton(-text=>'AHPS River Points',
-# -value=>'river', -variable=>\$list_type);
-#my $lst_rad_precip = $mw-> Radiobutton(-text=>'Precip Points',
-# -value=>'precip', -variable=>\$list_type);
-# Labels for the LID and table scroll boxes
-my $misc_ent = $mw->Entry();
-my $label1 = $mw->Label(-text => 'HSA|LID|Location Name');
-my $label2 = $mw->Label(-text => 'Tables');
-
-# Create the scroll boxes for the LIDs and tables
-my $lb1 = $mw->Scrolled('Listbox',
- -scrollbars => 'osoe',-width=>50,
- -selectmode => 'multiple', -exportselection=>0);
-my $lb2 = $mw->Scrolled('Listbox',
- -scrollbars => 'osow',-width=>20,
- -selectmode => 'multiple',-exportselection=>0);
-
-# Add the arrays that we want to display in the list boxes
-$lb1->insert('end', @liddeschsa);
-$lb2->insert('end', @tabledesc);
-
-# Create the buttons
-my $exit = $mw->Button(-text => 'Exit',
- -command => [$mw => 'destroy']);
-my $send = $mw->Button(-text => 'Send',
- -command => \&send_button);
-my $show_log = $mw->Button(-text => 'Show Log',
- -command => \&show_log);
-my $update_list = $mw->Button(-text => 'Update List', -command => \&upd_list);
-# create the label and text box for the last pdate window
-my $status_box = $mw->Text(-width=>20, -height=>3);
-my $lb_status = $mw->Label(-width=>20, -height=>3,-text=>"Last Ad-Hoc Update:");
-my $last_update = `cat $LOG_DIR/last_nrldb_update.txt`;
-
-$status_box->insert('end',"$last_update");
-
-# Crate the GUI using grid to specify the physical locations of the objects
-#$lst_rad_riv->grid(-row=>1, -column=>2, -columnspan=>1);
-#$lst_rad_precip->grid(-row=>1, -column=>3, -columnspan=>1);
-$label1->grid(-row=>1, -column=>1, -columnspan=>3) ;
-$label2->grid(-row=>1, -column=>4) ;
-$lb1->grid(-row=>2, -column=>1, -columnspan=>3, -sticky=>"ew") ;#pack;
-$lb2->grid(-row=>2, -column=>4, -columnspan=>1, -sticky=>"w") ;#pack;
-$lst_lab->grid(-row=>3, -column=>1, -columnspan=>1);
-$misc_ent->grid(-row=>3, -column=>2);
-$lb_status->grid(-row=>4, -column=>1);
-$status_box->grid(-row=>4, -column=>2, -columnspan=>3, -sticky=>"ew");
-$send->grid(-row=>5, -column=>1) ;#pack;
-$show_log->grid(-row=>5,-column=>2);
-$exit->grid(-row=>5, -column=>4) ;#pack;
-
-MainLoop;
-
-# End of main
-#
-#sub upd_list {
-# $mw => 'destroy';
-# my $cmd = "${DIR}/update_nrldb.pl.exp $list_type\n";
-# print "cmd: $cmd\n";
-# system($cmd);
-#}
-
-# The Send button functionality function
-sub send_button {
- # Get the indices of the selected array items
- my @LIDindex = $lb1->curselection;
- my @Tableindex = $lb2->curselection;
- my $index=1;
- my $misc_lid = $misc_ent-> get();
- # build the lists of LIDs and tables
- $tables = $table_list[$Tableindex[0]];
- my $numLIDs=@LIDindex;
- print "numLIDs: $numLIDs\n";
- my $numTables=@Tableindex;
- if ($numLIDs > 0){
- $lids = $lidsend[$LIDindex[0]];
- while ($index < $numLIDs){
- $lids .= "," . $lidsend[$LIDindex[$index]];
- $index++;
- }
- $lids .= "," . $misc_lid;
- } else {
- $lids=$misc_lid;
- }
- $index=1;
- while ($index < $numTables){
- $tables .= "," . $table_list[$Tableindex[$index]];
- $index++;
- }
-# print "l0: ${lid_list[$LIDindex[0]]} t0: ${table_list[$Tableindex[0]]} lids: $lids tables: $tables\n";
-
- # Create the call to the script and execute it using system()
- my $cmd = "${BIN_DIR}/send_nrldb_update.sh -table $tables -lid $lids > ${LOG_DIR}/send_nrldb_update.log\n";
-# print "cmd: $cmd\n";
- system($cmd);
-
- # Create a dialog box to inform the user that their data has been sent
- my $dsend=$mw->Dialog(-title=>'Sent NRLDB Update',-buttons=>['OK']);
- my $text_field="NRLDB Update Sent for LIDs: $lids \n and tables: $tables\n";
-# my $addbox=$dsend->('Label',-text=>"$text_field")->pack(-side => 'left',-fill => 'both',-expand => 1);
- my $box=$dsend->add('Label',-text=>"$text_field")->pack(-side => 'left',-fill => 'both',-expand => 1);
- my $button = $dsend->Show;
-}
-# This subroutine, copied from Mark Fenbers bless program, takes a db query and returns an array of results
-sub get_results
-{
- my $qh = shift;
- my $array = shift;
- my $record;
-
-#print "qh: $qh\n";
- if(defined $qh) {
- if($qh->execute(@_)) {
- while($record = $qh->fetchrow_arrayref) {
- foreach (@$record) { $_ = "" if ! defined $_; }
- push @$array,(join '|',@$record);
- }
- } else {
- warn $DBI::errstr;
-# print $qh->errstr;
- }
- } else { warn "unable to prepare query \"$sql\"\n"; }
-}
-
-#This subroutine displays the log from the send script in the form of a dialog box
-sub show_log
-{
- use Tk::Dialog;
- my $text_field=`cat ${LOG_DIR}/send_nrldb_update.log`;
- my $d = $mw->Dialog(-title=>'Show Log',-buttons => ['OK']);
- my $box=$d->add('Label',-text=>"$text_field")->pack(-side => 'left',-fill => 'both',-expand => 1);
- my $button = $d->Show;
-# exit;
-}
-
diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/nrldb.conf b/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/nrldb.conf
deleted file mode 100644
index 4a3ce4eb68..0000000000
--- a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/nrldb.conf
+++ /dev/null
@@ -1,6 +0,0 @@
-dbhost = "dx1f"
-dbuser = "awips"
-dbpass = ""
-nrldb_host = "165.92.28.1"
-site = "CCC"
-dbname = "hd_ob92ccc"
diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/nrldb_control_wfo b/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/nrldb_control_wfo
deleted file mode 100644
index f76ac5221e..0000000000
--- a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/nrldb_control_wfo
+++ /dev/null
@@ -1,174 +0,0 @@
-#NRLDB national configuration file
-#
-#
-[hsa]
-fields = ALL
-
-[wfo]
-fields = ALL
-
-[state]
-fields = ALL
-
-[counties]
-fields = ALL
-
-[network]
-fields = ALL
-
-[rfc]
-fields = ALL
-
-[timezone]
-fields = ALL
-
-#[admin]
-#fields = ALL
-
-[coopcomms]
-fields = ALL
-
-[cooprecip]
-fields = ALL
-
-[coopspons]
-fields = ALL
-
-[dcpowner]
-fields = ALL
-
-#[eligzon]
-#fields = ALL
-
-[gagemaint]
-fields = ALL
-
-[gageowner]
-fields = ALL
-
-[gagetype]
-fields = ALL
-
-[proximity]
-fields = ALL
-
-[telmtype]
-fields = ALL
-
-[telmowner]
-fields = ALL
-
-[telmpayor]
-fields = ALL
-
-[resowner]
-fields = ALL
-
-[damtypes]
-fields = ALL
-
-[location]
-fields = ALL
-
-[riverstat]
-fields = ALL
-
-[benchmark]
-fields = lid, bnum, elev, remark
-
-[observer]
-fields = ALL
-
-#[zonenum]
-#fields = lid, state, zonenum
-
-[reservoir]
-fields = ALL
-
-[crest]
-fields = ALL
-
-[datum]
-fields = ALL
-
-#[dcp]
-#fields = ALL
-[dcp]
-fields = lid, criteria, owner, goes, rptfreq, rptime, notify, obsvfreq, randrept
-
-[descrip]
-fields = ALL
-
-[flood]
-fields = ALL
-
-[floodcat]
-fields = ALL
-
-[floodstmt]
-fields = ALL
-
-[gage]
-fields = ALL
-
-[lowwater]
-fields = ALL
-
-[pub]
-fields = ALL
-
-[refer]
-fields = ALL
-
-#[telem]
-#fields = ALL
-[telem]
-fields = lid, type, payor, cost, criteria, owner, phone, sensorid, rptfreq, notify, obsvfreq
-
-[rating]
-fields = ALL
-
-[ratingshift]
-fields = ALL
-
-[contacts]
-fields = ALL
-
-[countynum]
-fields = ALL
-
-[unitgraph]
-fields = ALL
-
-[hgstation]
-fields = ALL
-
-#[floodts]
-#fields = ALL
-
-[lwstmt]
-fields = ALL
-
-[rpffcstgroup]
-fields = ALL
-
-[rpffcstpoint]
-fields = ALL
-
-[locdatalimits]
-fields = lid,pe,dur,monthdaystart,monthdayend,gross_range_min,gross_range_max,reason_range_min,reason_range_max,roc_max
-
-[sshpconfig]
-fields = ALL
-
-[shefpe]
-fields = ALL
-
-[shefdur]
-fields = ALL
-
-#[ingestfilter]
-#fields = ALL
-
-[locarea]
-fields = ALL
diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/sed_script.txt b/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/sed_script.txt
deleted file mode 100644
index 99f27bad14..0000000000
--- a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/app/nrldb/sed_script.txt
+++ /dev/null
@@ -1 +0,0 @@
-s/'/\\'/g
diff --git a/nativeLib/files.native/edex/lib/native/linux32/library.ohd.pproc.so.REMOVED.git-id b/nativeLib/files.native/edex/lib/native/linux32/library.ohd.pproc.so.REMOVED.git-id
index 2291591ae6..c23b9214f2 100644
--- a/nativeLib/files.native/edex/lib/native/linux32/library.ohd.pproc.so.REMOVED.git-id
+++ b/nativeLib/files.native/edex/lib/native/linux32/library.ohd.pproc.so.REMOVED.git-id
@@ -1 +1 @@
-2d8d4c03270ef631f167570cf0c03461ff832fea
\ No newline at end of file
+bd6cb2ea1de310abb0f576998cd03a437683289f
\ No newline at end of file
diff --git a/nativeLib/rary.ohd.pproc/src/nc2grib/TEXT/main_nc2grib.c b/nativeLib/rary.ohd.pproc/src/nc2grib/TEXT/main_nc2grib.c
index 65d485b2c0..c9cab33640 100644
--- a/nativeLib/rary.ohd.pproc/src/nc2grib/TEXT/main_nc2grib.c
+++ b/nativeLib/rary.ohd.pproc/src/nc2grib/TEXT/main_nc2grib.c
@@ -34,7 +34,7 @@
* a text file requires no code change as long as the parameters don't change.
* That logic could perhaps change as well.
*
-* The routine first uses standard C calls to read the netcdf file. The structure
+* The routine first uses standard C calls to read the NetCDF file. The structure
* of that file can be reviewed by reading the GFE help reference section on the
* ifpnetCDF command.
*
@@ -61,12 +61,16 @@
*
* Version 4 allows users to combine all GRIB messages into one file. This becomes useful
* when dealing with a lot of files for a parameter such as 1 hour QPF or temperature that
-* goes out to 240 hours.
+* goes out to num_hours hours.
*
* This is still a work in progress and code can always be improved to increase efficiency.
*
* Oct 2011 - PTilles - added read of new token for defining number of days of data to process
*
+* Mar 2012 - PTilles - added functionality to allow for more than 10 days (more than 240
+* hours) of data in one file to be processed. This looks for a value of '10'
+* in the 5th parameter of gfe2grib.txt.
+*
* Sep 2012 -Dan Stein - The original nc2grib program assumed the first variable in the
* NetCDF file (variable[0]) would be the data variable to be converted to grib format. The
* nc2grib tool was hard-coded to only look at variable[0]. In AWIPS-II, GFE began putting
@@ -93,9 +97,14 @@
#include "packgrib.h"
#include "getopt.h"
-
#include "cmapf.h"
+/*#include "version_info.h"*/
+#define VERSION_NAME "AWIPS II"
+#define VERSION_NUMBER "13.5.2"
+#define VERSION_DATE "(Oct 30, 2013)"
+
+
#define SECINHR 3600.
#define PATH_LEN 500
#define FILE_LEN 300
@@ -200,23 +209,24 @@ int nc2grib_main (int argc, char *argv[])
char adayhrmin[7]={'\0'}; /* day, hour, minute info attached to WMO header */
-
-
int numgfeparms=0;
-
+ char cnum[3] = {'\0'};
+ int num_hours = 0; /* (num_days * 24) */
+ /* number of days of data to process - read from token - previously hard coded as 10 */
+ /* default value = 10 - if token not found then default value used */
+ int num_days = 0;
int numgfiles=0; /* number of grib files for combining files into one if desired */
- char *gfiles[240]; /* array of char pointers for holding grib filenames if combining files */
/* for reading the NetCDF file */
- int NetCDF_ID; /* Netcdf id */
- int ndims; /* number of dimensions */
+ int NetCDF_ID; /* NetCDF id */
+ int numDims; /* number of dimensions */
int numVars; /* number of variables */
- int ngatts; /* number of attributes */
- int recdim;
+ int numGlobalAttributes; /* number of attributes */
+ int unlimitedDimensionID;
long start[] = {0, 0, 0}; /* start at first value */
long start1r[] = {0, 0}; /* accounts for netcdf with only 1 record and 2 dimensions of y,x */
@@ -261,9 +271,9 @@ int nc2grib_main (int argc, char *argv[])
double *latlonLL, *latlonUR, lonOrigin,*domainOrigin, *domainExtent, *latLonOrigin;
int *gridPointLL, *gridPointUR;
double x1, y1, x2, y2, lat1, lon1, lat2, lon2;
- nc_type vt_type, dn_type, ll_type, d_type, g_type;
+ nc_type dataType, dn_type, ll_type, d_type, g_type;
nc_type varDataType;
- int vt_len, ll_len, d_len, g_len;
+ int attributeLength, ll_len, d_len, g_len;
int variableID, *gridSize;
int numberOfVariableDimensions;
int dimensionIDVector[MAX_VAR_DIMS];
@@ -274,7 +284,7 @@ int nc2grib_main (int argc, char *argv[])
char cdfunits[MAX_NC_NAME]={'\0'};
char projection[MAX_NC_NAME]={'\0'};
long dim_size;
- float *cdfvargrid=NULL; /* this is the main array holding the actual data values */
+ float *cdfDataArray=NULL; /* this is the main array holding the actual data values */
float arraysize;
long *validTimes;
@@ -361,7 +371,7 @@ int nc2grib_main (int argc, char *argv[])
output_buffer = (size_t *) malloc (sizeof(size_t)*odim); /* output buffer used when writing GRIB message */
- int variableFound = FALSE; /* Is the variable present in the NetCDF file? Stein Sep 2012 */
+ int variableFound = FALSE; /* Is the variable present in the NetCDF file? */
/* output_buffer = (int *) malloc (sizeof(int)*odim); /* output buffer used when writing GRIB message */
@@ -378,7 +388,7 @@ int nc2grib_main (int argc, char *argv[])
/* parse command line arguments */
- while ((c = getopt(argc, argv, ":n:i:t:o::b:p:g:Nfrqhv1")) != -1) {
+ while ((c = getopt(argc, argv, ":n:i:t:o::b:p:g:Nfrqhv1V")) != -1) {
switch (c) {
@@ -710,6 +720,10 @@ int nc2grib_main (int argc, char *argv[])
case '1': /* process only one record of NetCDF, useful for debugging */
time1flag++;
break;
+ case 'V':
+ printf("version number = %s-%s\n",VERSION_NAME,VERSION_NUMBER);
+ exit(0);
+ break;
case ':': /* for options that need an operand */
if(optopt != 'o')
{
@@ -738,7 +752,8 @@ int nc2grib_main (int argc, char *argv[])
printf("Unrecognized program command line option: -%c\n", optopt);
errflag++;
}
- }
+
+ } /* while c = getopt */
if (errflag || helpflag || argc==1 || ( iflag==0 || pflag==0) )
@@ -753,6 +768,24 @@ int nc2grib_main (int argc, char *argv[])
return USAGE;
}
+/* Print CHPS build number */
+ printf("version number = %s-%s\n",VERSION_NAME,VERSION_NUMBER);
+
+ if(getAppsDefaults("nc2g_num_days",cnum) == -1)
+ {
+ num_days = 10;
+ }
+ else
+ {
+
+ num_days = atoi(cnum);
+ }
+
+ num_hours = num_days * 24;
+
+ char *gfiles[num_hours]; /* array of char pointers for holding grib filenames if combining files */
+
+ printf("\n number of days to process = %d \n", num_days);
if(nc_getAppsDefaults("nc2g_app_dir",appsdir) == -1)
{
@@ -805,7 +838,7 @@ int nc2grib_main (int argc, char *argv[])
/**************************************************************************/
/* debugflag > 0; debug option is on */
- if(debugflag>0)
+ if(debugflag)
printf("\n Debug option on...reading from GFE to GRIB configuation file:\n" \
" %s\n\n",file_path);
@@ -817,9 +850,11 @@ int nc2grib_main (int argc, char *argv[])
if(fileline[0] != '#') /* check for comments */
{
- sscanf(fileline,"%s%s%d%d%d%d%d",gfe2grib.GFEParameterName, gfe2grib.gfename, &gfe2grib.processid,
- &gfe2grib.gribnum,&gfe2grib.decscale, &gfe2grib.timerange, &gfe2grib.timeunit);
- if(debugflag>0)
+ sscanf(fileline,"%s%s%d%d%d%d%d",gfe2grib.GFEParameterName,
+ gfe2grib.gfename, &gfe2grib.processid,
+ &gfe2grib.gribnum,&gfe2grib.decscale, &gfe2grib.timerange,
+ &gfe2grib.timeunit);
+ if(debugflag)
printf(" DEBUG: Read in from gfe2grib.txt %s %s %d %d %d %d %d \n",gfe2grib.GFEParameterName, gfe2grib.gfename, gfe2grib.processid,
gfe2grib.gribnum,gfe2grib.decscale, gfe2grib.timerange, gfe2grib.timeunit);
@@ -828,12 +863,12 @@ int nc2grib_main (int argc, char *argv[])
if (!(strcmp(gfe2grib.GFEParameterName, process)))
{
-
found = 1;
break;
}
- }
- }
+ } /* If not a comment */
+
+ } /* While we haven't reach the end of the gfe2grib.txt file */
@@ -851,13 +886,12 @@ int nc2grib_main (int argc, char *argv[])
fclose(fp);
- /* open the Netcdf file*/
+ /* open the NetCDF file*/
if(inpath==NULL)
{
inpath=(char *) malloc(sizeof(char)*(FILE_LEN+1));
-
if(inpath==NULL)
{
printf(" ERROR: Something went wrong with memory allocation for the NetCDF input directory....exiting\n");
@@ -871,12 +905,13 @@ int nc2grib_main (int argc, char *argv[])
printf(" ERROR: Invalid token value for token \"netcdf_dir\".\n\t Program exit.");
return APSDEFERR;
}
- else if (debugflag>0)
+ else if (debugflag)
{
printf(" Default path for the input NetCDF file not specified...Will use the following:\n" \
" %s\n",inpath);
}
- }
+ } /* if inpath is NULL */
+
/***************************************************************************/
else if(debugflag)
printf(" Will attempt to read NetCDF file from this path:\n" \
@@ -895,32 +930,21 @@ int nc2grib_main (int argc, char *argv[])
if (NetCDF_ID==-1)
{
- printf("\n ERROR: Could not open the netcdf file: %s\n", fn);
+ printf("\n ERROR: Could not open the NetCDF file: %s\n", fn);
return CDFERR;
}
else
{
- printf ("\n Netcdf file %s was opened successfully.\n\n",fn);
+ printf ("\n NetCDF file %s was opened successfully.\n\n",fn);
}
- /* Inquire about the Netcdf file: No.of dimensions, No.of variables,
- No. of global attributes etc.*/
+ /* Inquire about the NetCDF file: No.of dimensions, No.of variables, No.of
+ * global attributes etc.
+ */
- ncinquire (NetCDF_ID, &ndims, &numVars, &ngatts, &recdim);
-/*************************************************************************/
-/* debug */
+ ncinquire (NetCDF_ID, &numDims, &numVars, &numGlobalAttributes, &unlimitedDimensionID);
-if (debugflag >0)
-{
- printf("\n Debug option on. Debug info from reading the netcdf file follows:\n\n");
- printf (" Number of dimensions for this netcdf file is: %d\n",ndims);
- printf (" Number of variables for this netcdf file is: %d\n",numVars);
- printf (" Number of global attributes for this netcdf file is: %d\n",ngatts);
-}
-/*************************************************************************/
-
- /**************************************************************************
- * Sep 2012 - Stein The utility that takes GFE data and converts it to
+ /* Sep 2012 - Stein The utility that takes GFE data and converts it to
* NetCDF format is ifpNetCDF. To the best of my knowledge, this utility
* always puts exactly one variable and exactly one history variable into
* each NetCDF file. The section of code below originally assumed that the
@@ -930,7 +954,7 @@ if (debugflag >0)
* For whatever reason, this order was changed in AWIPS-II so that the
* history variable showed up first and the program wouldn't work. I was
* tasked with correcting this program to make it order independent. My
- * solution was to loop through all the variables to see whether the
+ * solution is to loop through all the variables to see whether the
* variable we're looking for is in the NetCDF file. If it is, variableID
* is set to it's value. If not found, the program will exit as it did
* before.
@@ -989,11 +1013,6 @@ if (debugflag >0)
* end of the section of code that I changed.
*/
-
-
-
-
-
if(numberOfVariableDimensions==3) /* in some cases, this may not be true if file is produced from MPE/DQC */
{
for (i=0; i0)
return CDFERR;
}
/*************************************************************************/
-if (debugflag >0)
+ if (debugflag)
{
printf(" DEBUG: cdfvar dimension %d: name=%s size=%ld\n",i+1,dimname,dim_size);
}
/*************************************************************************/
- }
- }
+ } /* for i */
+
+ } /* if (numberOfVariableDimensions == 3) */
+
else if (numberOfVariableDimensions==2)
{
-
for (i=0; i0)
else if (i==1)
x=dim_size;
/*************************************************************************/
-if (debugflag >0)
+if (debugflag)
{
printf(" DEBUG: cdfvar dimension %d: name=%s size=%ld\n",i+1,dimname,dim_size);
}
/*************************************************************************/
- }
- }
+ } /* for i */
+
+ } /* else if (numberOfVariableDimensions == 2) */
+
else
{
printf("\n nc2grib is not coded to handle %d number of dimensions for variable %s.\n" \
@@ -1055,17 +1077,29 @@ if (debugflag >0)
/* get variable attributes */
+ /* get the values of NetCDF attributes given the variable ID and name */
arraysize = x * y;
- cdfvargrid = (float *) malloc (sizeof(float)*arraysize);
+ cdfDataArray = (float *) malloc (sizeof(float) * arraysize);
long count[]={1,y,x};
long count1r[]={y,x};
- ncattinq(NetCDF_ID,variableID,"validTimes",&vt_type,&vt_len);
+if (debugflag)
+{
+ printf ("DEBUG: ncattinq call Before\n");
+}
- validTimes = (long *) malloc(vt_len * nctypelen(vt_type));
+ /* Get Information about an Attribute (att inquiry) */
+ ncattinq(NetCDF_ID, variableID, "validTimes", &dataType, &attributeLength);
+
+if (debugflag)
+{
+ printf ("DEBUG: ncattinq call After\n");
+}
+
+ validTimes = (long *) malloc (attributeLength * nctypelen(dataType));
ncattget(NetCDF_ID, variableID, "validTimes", validTimes);
@@ -1077,6 +1111,8 @@ if (debugflag >0)
ncattget(NetCDF_ID, variableID, "projectionType", projection);
+
+ /* Get Information about an Attribute (att inquiry) */
ncattinq(NetCDF_ID,variableID,"latLonLL",&ll_type,&ll_len);
latlonLL = (double *) malloc(ll_len * nctypelen(ll_type));
@@ -1087,30 +1123,40 @@ if (debugflag >0)
ncattget(NetCDF_ID, variableID, "latLonUR", (void *) latlonUR);
+
+ /* Get Information about an Attribute (att inquiry) */
ncattinq(NetCDF_ID,variableID,"domainOrigin",&d_type,&d_len);
domainOrigin = (double *) malloc(d_len * nctypelen(d_type));
ncattget(NetCDF_ID, variableID, "domainOrigin", (void *) domainOrigin);
+
+ /* Get Information about an Attribute (att inquiry) */
ncattinq(NetCDF_ID,variableID,"domainExtent",&d_type,&d_len);
domainExtent = (double *) malloc(d_len * nctypelen(d_type));
ncattget(NetCDF_ID, variableID, "domainExtent", (void *) domainExtent);
+
+ /* Get Information about an Attribute (att inquiry) */
ncattinq(NetCDF_ID,variableID,"gridSize",&g_type,&g_len);
gridSize = (int *) malloc(g_len * nctypelen(g_type));
ncattget(NetCDF_ID, variableID, "gridSize", (void *) gridSize);
+
+ /* Get Information about an Attribute (att inquiry) */
ncattinq(NetCDF_ID,variableID,"gridPointLL",&g_type,&g_len);
gridPointLL = (int *) malloc(g_len * nctypelen(g_type));
ncattget(NetCDF_ID, variableID, "gridPointLL", (void *) gridPointLL);
+
+ /* Get Information about an Attribute (att inquiry) */
ncattinq(NetCDF_ID,variableID,"gridPointUR",&g_type,&g_len);
gridPointUR = (int *) malloc(g_len * nctypelen(g_type));
@@ -1119,8 +1165,8 @@ if (debugflag >0)
/* initialize the array to missing value */
- for (i=0;i0)
{
printf(" DEBUG: siteID = %s\n",siteID);
- printf(" DEBUG: number of valid times = %d type = %d\n",vt_len, vt_type);
+ printf(" DEBUG: number of valid times = %d type = %d\n",attributeLength, dataType);
printf(" DEBUG: descriptName = %s\n",descriptName);
printf(" DEBUG: projection = %s\n",projection);
@@ -1344,7 +1390,7 @@ if (debugflag >0)
}
else
{
- printf(" Unknown projection read from netcdf...Exiting");
+ printf(" Unknown projection read from NetCDF...Exiting");
return CDFERR;
/* might account for this as this is a lat,lon grid */
@@ -1602,16 +1648,15 @@ if (debugflag>0)
*/
- if (time1flag>0) /* for testing only to do just the first valid time from the netcdf file */
- vt_len=2;
+ if (time1flag>0) /* for testing only to do just the first valid time from the NetCDF file */
+ attributeLength=2;
/****************************************************************************/
if (debugflag>0)
printf("\n ***Entering main loop to process NetCDF records(s) into GRIB files*** \n\n");
/****************************************************************************/
- for (m=0; m0)
fcsth=0;
- /* In the case of multiple accumulation periods in the same netcdf file, will need to attach this to the
+ /* In the case of multiple accumulation periods in the same NetCDF file, will need to attach this to the
filename in both cases. Can't reuse fcsth as it might be needed to determine the WMO header for any
future NPVU estimate/observed grids.
*/
@@ -1714,14 +1759,14 @@ if (debugflag>0)
- if (esth > 240 || esth < 0)
+ if (esth > num_hours || esth < 0)
{
- printf(" The estimated/observed time period is either less than 0 or greater than 10 days (240 hours).\n" \
+ printf(" The estimated/observed time period is either less than 0 or greater than %d hours.\n" \
" Therefore, valid times within the input NetCDF filename may not have been generated \n" \
" correctly. Or this is actually a forecast grid and the -b option should be used so it \n" \
" will be processed correctly. Check your options and ensure this is an estimate or observed grid\n" \
" You could also try to generate the file again.\n" \
- " For debug esth = %d\n",esth);
+ " For debug esth = %d\n",num_hours, esth);
return FILEERR;
}
@@ -1784,13 +1829,13 @@ if (debugflag>0)
printf(" DEBUG: fcsth = %d timediff=%f valid time = %ld basis time_t = %ld\n",fcsth, timediff,(*(validTimes+m+1)), basetime_t);
/*************************************************************/
- if (fcsth > 240 || fcsth < 0)
+ if (fcsth > num_hours || fcsth < 0)
{
- printf(" The forecast time is either less than 0 or greater than 10 days (240 hours).\n" \
+ printf(" The forecast time is either less than 0 or greater than %d hours.\n" \
" Therefore, the basis time may not be specified correctly or may need to be specified \n" \
" on the command line according to guidance. Please check your command options or \n" \
" or the NetCDF file creation and try again.\n" \
- " for debug fcsth = %d\n",fcsth);
+ " for debug fcsth = %d\n",num_hours, fcsth);
return FILEERR;
}
@@ -1816,10 +1861,12 @@ if (debugflag >0)
grib_lbl[16]=fcsth-(int)(timediff/SECINHR); /* P1 */
grib_lbl[17]=fcsth; /* P2 */
}
- else if (gfe2grib.timerange==0)
+ else if (gfe2grib.timerange==0 || gfe2grib.timerange == 10)
{
/* this is for a forecast product valid at reference time + P1 and
at present using this for PETF
+ OR
+ case of forecast hour > 255
*/
grib_lbl[16]=fcsth; /* P1 */
@@ -1842,13 +1889,13 @@ if (debugflag >0)
start[0]=(long) (m/2);
- status = ncvarget(NetCDF_ID,variableID,start,count,cdfvargrid);
+ status = ncvarget(NetCDF_ID,variableID,start,count,cdfDataArray);
}
else if (numberOfVariableDimensions==2)
{
start1r[0]=(long) (m/2);
- status = ncvarget(NetCDF_ID,variableID,start1r,count1r,cdfvargrid);
+ status = ncvarget(NetCDF_ID,variableID,start1r,count1r,cdfDataArray);
}
if (status != NC_NOERR)
@@ -1862,7 +1909,7 @@ if (debugflag >0)
for (i=0;i xmissing)
+ if((*(cdfDataArray+i))> xmissing)
{
mischek=1;
break;
@@ -1880,7 +1927,7 @@ if (debugflag >0)
for (i=0;i0)
for (i=0;i xmissing)
+ if((*(cdfDataArray+i))> xmissing)
- *(cdfvargrid+i) *= 25.4; /* convert inches to mm */
+ *(cdfDataArray+i) *= 25.4; /* convert inches to mm */
}
}
@@ -1920,9 +1967,9 @@ if (debugflag >0)
for (i=0;i xmissing)
+ if((*(cdfDataArray+i))> xmissing)
- *(cdfvargrid+i) = ((*(cdfvargrid+i)-32) * 5/9) + 273.16; /* convert F to K */
+ *(cdfDataArray+i) = ((*(cdfDataArray+i)-32) * 5/9) + 273.16; /* convert F to K */
}
@@ -1931,9 +1978,9 @@ if (debugflag >0)
{
for (i=0;i xmissing)
-
- *(cdfvargrid+i) += 273.16; /* convert C to K */
+ if((*(cdfDataArray+i))> xmissing)
+
+ *(cdfDataArray+i) += 273.16; /* convert C to K */
}
}
@@ -1953,9 +2000,9 @@ if (debugflag >0)
for (i=0;i xmissing)
+ if((*(cdfDataArray+i))> xmissing)
- *(cdfvargrid+i) *= 0.3048; /* convert feet to meters */
+ *(cdfDataArray+i) *= 0.3048; /* convert feet to meters */
}
}
@@ -1983,9 +2030,8 @@ if (debugflag >0)
}
/*************************************************************************/
-
- status = packgrib(grib_lbl,pds_ext,&iplen,cdfvargrid,&idim,&xmissing,
- output_buffer,&odim,&length);
+ status = packgrib(grib_lbl, pds_ext, &iplen, cdfDataArray, &idim,
+ &xmissing, output_buffer,&odim,&length);
if (status !=0)
{
@@ -2206,7 +2252,7 @@ if(debugflag)
sprintf(ofn,ofn,fcsth); /* standard forecast product using forecast hours past basis time */
- }
+ } /* if (bflag) */
else /* without a basis time, this has to be an estimated/observed product using the valid time in
the output file. Note that if "%%" is NULL and bflag == 0, specifying esth here is
ignored in the output filename.
@@ -2340,7 +2386,7 @@ if(debugflag>0)
- if(bflag && qflag==0) /* old - strstr(process,"QPE")==NULL && strstr(process,"qpe")==NULL) */
+ if(bflag && qflag==0) /* old - strstr(GFEParameterName,"QPE")==NULL && strstr(process,"qpe")==NULL) */
{
if(debugflag>0)
@@ -2357,6 +2403,7 @@ if(debugflag>0)
/* first write out the main GRIB file using the copygb command without the header determined above
to a temporary holding file. This file will now contain the QPF forecast on GRID218 at 10km
resolution */
+
copygb_main_(command);
/* status = system(command); */
}
@@ -2768,8 +2815,8 @@ if (debugflag >0)
if(output_buffer!=NULL)
free(output_buffer);
- if(cdfvargrid!=NULL)
- free(cdfvargrid);
+ if(cdfDataArray!=NULL)
+ free(cdfDataArray);
if(gribdir!=NULL)
free(gribdir);
@@ -2868,15 +2915,15 @@ int timet_to_userformat_ansi(time_t timet, char *ansi, char* userformat)
int display_usage(void)
{
printf("\n\n nc2grib GFE NetCDF to GRIB1 translator, usage:\n\n" \
- "./nc2grib.LX -n (input netcdf path) -i (netcdf file) -t (output grib path) -o (output grib file) \n" \
+ "./nc2grib.LX -n (input NetCDF path) -i (NetCDF file) -t (output grib path) -o (output grib file) \n" \
" -b (basis time) -p (process ID) -g (one GRIB filename) -f -N -v -h\n" \
"where:\n" \
- "-n (input netcdf path) Refers to the path containing the NetCDF file\n" \
- " Optional, requires argument generated by the GFE routine ifpnetCDF.\n" \
+ "-n (input NetCDF path) Refers to the path containing the NetCDF file\n" \
+ " Optional, requires argument generated by the GFE routine ifpNetCDF.\n" \
" If not used, the token netcdf_dir will be used \n" \
" to retrieve this information\n\n" \
- "-i (input netcdf file) Refers to the NetCDF file generated in the format\n" \
- " Required, requires argument used by the GFE routine ifpnetCDF.\n\n" \
+ "-i (input NetCDF file) Refers to the NetCDF file generated in the format\n" \
+ " Required, requires argument used by the GFE routine ifpNetCDF.\n\n" \
" NOTE that this command line option and its argument\n" \
" must be specified in the call to nc2grib.\n\n" \
"-t (output grib path) Refers to the path of the GRIB file(s) generated by nc2grib.\n" \
@@ -2893,7 +2940,7 @@ int display_usage(void)
" Required for forecast Example: -b 2009051412 \n" \
" grids and QPE grids going to \n" \
" NPVU,requires argument \n\n" \
- "-p (process ID) Refers to the parameter process ID relating to a GFE parameter\n" \
+ "-p (GFEParameterName ID) Refers to the parameter process ID relating to a GFE parameter\n" \
" Required, requires argument such as QPF. Needs to match against a process in the gfe2grib.txt\n" \
" configuration file.\n" \
" NOTE that this command line option and its argument \n" \
@@ -2935,10 +2982,6 @@ int display_usage(void)
return 0;
-/* ============== Statements containing RCS keywords: */
-{static char rcs_id1[] = "$Source: /fs/hseb/ob9d/ohd/pproc/src/nc2grib/RCS/main_nc2grib.c,v $";
- static char rcs_id2[] = "$Id: main_nc2grib.c,v 1.2 2010/06/14 15:04:32 millerd Exp $";}
-/* =================================================== */
-
}
+
diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.airmet/src/gov/noaa/nws/ncep/edex/plugin/airmet/decoder/AirmetDecoder.java b/ncep/gov.noaa.nws.ncep.edex.plugin.airmet/src/gov/noaa/nws/ncep/edex/plugin/airmet/decoder/AirmetDecoder.java
old mode 100755
new mode 100644
diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.gpd/res/spring/gpd-ingest.xml b/ncep/gov.noaa.nws.ncep.edex.plugin.gpd/res/spring/gpd-ingest.xml
deleted file mode 100644
index 2599048640..0000000000
--- a/ncep/gov.noaa.nws.ncep.edex.plugin.gpd/res/spring/gpd-ingest.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- gpd
-
-
-
-
-
-
-
-
- gpd
-
-
-
-
-
-
-
-
- java.lang.Throwable
-
-
-
-
-
-
-
-
-
diff --git a/ncep/gov.noaa.nws.ncep.edex.plugin.ntrans/src/gov/noaa/nws/ncep/edex/plugin/ntrans/decoder/NtransDecoder.java b/ncep/gov.noaa.nws.ncep.edex.plugin.ntrans/src/gov/noaa/nws/ncep/edex/plugin/ntrans/decoder/NtransDecoder.java
index 48599448f4..0a56a0693c 100644
--- a/ncep/gov.noaa.nws.ncep.edex.plugin.ntrans/src/gov/noaa/nws/ncep/edex/plugin/ntrans/decoder/NtransDecoder.java
+++ b/ncep/gov.noaa.nws.ncep.edex.plugin.ntrans/src/gov/noaa/nws/ncep/edex/plugin/ntrans/decoder/NtransDecoder.java
@@ -30,6 +30,7 @@ import com.raytheon.uf.common.time.DataTime;
* ------------ -------- ----------- -------------------------------------
* 03/2013 B. Hebbard Initial creation
* 04/2013 B. Hebbard IOC version (for OB13.4.1)
+ * 10/2013 B. Hebbard Modify model name inference from metafile name
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
*
*
@@ -366,6 +367,61 @@ public class NtransDecoder extends AbstractDecoder {
*/
}
+ private enum Model {
+ //TODO - Remove this, to make decoder agnostic w.r.t. list of available models.
+ // We do this temporarily because we don't yet know the possible formats
+ // of filename strings we're going to be fed, so for now we just look for
+ // known model names appearing anywhere in the file name.
+ // NOTE: Sequence is important only insofar as any model name must appear
+ // after all model names of which it is a proper substring.
+ // Also, OPC_ENC comes first, since its metafiles may contain other
+ // model substrings
+ OPC_ENS,
+ CMCE_AVGSPR,
+ CMCE,
+ CMCVER,
+ CMC,
+ CPC,
+ DGEX,
+ ECENS_AVGSPR,
+ ECENS,
+ ECMWFVER,
+ ECMWF_HR,
+ ECMWF,
+ ENSVER,
+ FNMOCWAVE,
+ GDAS,
+ GEFS_AVGSPR,
+ GEFS,
+ GFSP,
+ GFSVERP,
+ GFSVER,
+ GFS,
+ GHM,
+ HPCQPF,
+ HPCVER,
+ HWRF,
+ ICEACCR,
+ JMAP,
+ JMA,
+ MEDRT,
+ NAEFS,
+ NAM20,
+ NAM44,
+ NAMVER,
+ NAM,
+ NAVGEM,
+ NOGAPS,
+ NWW3P,
+ NWW3,
+ RAPP,
+ RAP,
+ SREFX,
+ SST,
+ UKMETVER,
+ UKMET,
+ VAFTAD };
+
private String inferModel(String fileName) {
// Infer the model name from the file name
@@ -383,14 +439,30 @@ public class NtransDecoder extends AbstractDecoder {
} else if (/* fileName.matches("^[A-Z]") */
fileName.contains("_GFS")) {
modelName = "vaftad";
+ /*
} else if (fileName.contains("_2")) {
modelName = fileName.substring(0, fileName.indexOf("_2"));
if (modelName.equals("jma")) {
modelName = "jmap";
}
}
-
+
return modelName;
+ */
+
+ } else {
+ for (Model model : Model.values()) {
+ if (fileName.toLowerCase().contains(model.name().toLowerCase())) {
+ modelName = model.name().toLowerCase();
+ break;
+ }
+ }
+ if (modelName.equals("jma")) {
+ modelName = "jmap";
+ }
+ return modelName;
+ }
+ return "other"; // unrecognized
}
private ByteOrder determineEndianess(ByteBuffer byteBuffer) {
diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/CMCE_AVGSPR_NT/CMCE_AVGSPR_NT.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/CMCE_AVGSPR_NT/CMCE_AVGSPR_NT.xml
index 160a8aeec8..f7b3a9f27d 100644
--- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/CMCE_AVGSPR_NT/CMCE_AVGSPR_NT.xml
+++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/CMCE_AVGSPR_NT/CMCE_AVGSPR_NT.xml
@@ -5,7 +5,7 @@
NTRANS
pluginName=ntrans
-modelName=cmce_avgspr
+modelName=cmce-avgspr
NTRANS
metafileName,productName
diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECENS_AVGSPR_NT/ECENS_AVGSPR_NT.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECENS_AVGSPR_NT/ECENS_AVGSPR_NT.xml
index 154bc1af12..db4fb80453 100644
--- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECENS_AVGSPR_NT/ECENS_AVGSPR_NT.xml
+++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECENS_AVGSPR_NT/ECENS_AVGSPR_NT.xml
@@ -5,7 +5,7 @@
NTRANS
pluginName=ntrans
-modelName=ecens_avgspr
+modelName=ecens-avgspr
NTRANS
metafileName,productName
diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECMWF_HR_NT/ECMWF_HR_NT.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECMWF_HR_NT/ECMWF_HR_NT.xml
index 5a19a7f24b..a8f444292d 100644
--- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECMWF_HR_NT/ECMWF_HR_NT.xml
+++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/ECMWF_HR_NT/ECMWF_HR_NT.xml
@@ -5,7 +5,7 @@
NTRANS
pluginName=ntrans
-modelName=ecmwf_hr
+modelName=ecmwf-hr
NTRANS
metafileName,productName
diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/GEFS_AVGSPR_NT/GEFS_AVGSPR_NT.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/GEFS_AVGSPR_NT/GEFS_AVGSPR_NT.xml
index 112e11023d..ad22a953a0 100644
--- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/GEFS_AVGSPR_NT/GEFS_AVGSPR_NT.xml
+++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/GEFS_AVGSPR_NT/GEFS_AVGSPR_NT.xml
@@ -5,7 +5,7 @@
NTRANS
pluginName=ntrans
-modelName=gefs_avgspr
+modelName=gefs-avgspr
NTRANS
metafileName,productName
diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/OPC_ENS_NT/OPC_ENS_NT.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/OPC_ENS_NT/OPC_ENS_NT.xml
index 3a37b3c19f..ec4a06d48c 100644
--- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/OPC_ENS_NT/OPC_ENS_NT.xml
+++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/NTRANS/OPC_ENS_NT/OPC_ENS_NT.xml
@@ -5,7 +5,7 @@
NTRANS
pluginName=ntrans
-modelName=opc_ens
+modelName=opc-ens
NTRANS
metafileName,productName
diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/ResourceFilters.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/ResourceFilters.xml
index d411923aca..954796c221 100644
--- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/ResourceFilters.xml
+++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/ResourceDefns/ResourceFilters.xml
@@ -345,6 +345,9 @@
Forecast,NTRANS
+
+Forecast,NTRANS
+
Forecast,NTRANS
@@ -357,6 +360,9 @@
Forecast,NTRANS
+
+Forecast,NTRANS
+
Forecast,NTRANS
diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/AbstractGriddedDisplay.java b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/AbstractGriddedDisplay.java
index 12d892f896..6b35c3c184 100644
--- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/AbstractGriddedDisplay.java
+++ b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/AbstractGriddedDisplay.java
@@ -41,12 +41,13 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
-//import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.vividsolutions.jts.geom.Coordinate;
+//import com.raytheon.uf.viz.core.drawables.IRenderable;
+
/**
* An abstract resource for displays where each grid cell is an individual
* IImage. Handles progressive disclosure algorithm.
@@ -68,10 +69,11 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0
*/
-public abstract class AbstractGriddedDisplay { //implements IRenderable
+public abstract class AbstractGriddedDisplay { // implements IRenderable
+
+ private static final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(AbstractGriddedDisplay.class);
- private static final IUFStatusHandler statusHandler = UFStatus.getHandler(AbstractGriddedDisplay.class);
-
private final Queue calculationQueue;
private CalculationJob calculationJob;
@@ -89,13 +91,15 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
protected RGB color;
protected int skipx;
+
protected int skipy;
+
protected double filter;
protected double magnification = 1.0;
private boolean async = true;
-
+
protected boolean[] isPlotted;
/**
@@ -105,22 +109,19 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
* @param size
*/
public AbstractGriddedDisplay(IMapDescriptor descriptor,
- GeneralGridGeometry gridGeometryOfGrid,int nx, int ny) {
+ GeneralGridGeometry gridGeometryOfGrid, int nx, int ny) {
this.calculationQueue = new ConcurrentLinkedQueue();
this.descriptor = descriptor;
this.gridGeometryOfGrid = gridGeometryOfGrid;
-
-// this.size = size;
- this.gridDims = new int[] {
- nx,
- ny };
-
+ // this.size = size;
+
+ this.gridDims = new int[] { nx, ny };
+
isPlotted = new boolean[gridDims[0] * gridDims[1]];
-
-
+
}
public void setASync(boolean async) {
@@ -134,106 +135,104 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
* com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core
* .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties)
*/
- // @Override
- public void paint(NcgridResourceData gridRscData, IGraphicsTarget target, PaintProperties paintProps)
- throws VizException {
-
- boolean globalModel = isGlobalModel();
-
- /**
- * Get filter attribute
+ // @Override
+ public void paint(NcgridResourceData gridRscData, IGraphicsTarget target,
+ PaintProperties paintProps) throws VizException {
+
+ boolean globalModel = isGlobalModel();
+
+ /**
+ * Get filter attribute
*/
- String den = gridRscData.getFilter();
- String noFilter = "";
- if (den != null ){
- try {
- if (den.equalsIgnoreCase("YES") || den.equalsIgnoreCase("Y")) {
- filter = 1.0;
- }
- else if (den.equalsIgnoreCase("NO") || den.equalsIgnoreCase("N") || den.equalsIgnoreCase("")) {
- filter = 0.0;
- noFilter = "NO";
- }
- else {
- filter = Double.parseDouble(den);
- }
-
- if (filter == 0)
- noFilter = "NO";
- if (filter <0.1)
- filter = 0.1;
- }
- catch (NumberFormatException e) {
- System.out.println("The filter is not a double number");
- filter = 1.0;
- }
- }
- else {
- filter = 1.0;
- }
-
-// /**
-// * Get skip attribute
-// */
-//
-// String[] skip = null;
-// int skipx = 0;
-// int skipy = 0;
-//
-// String skipString = gridRscData.getSkip(); //now for positive skip
-// if (skipString != null && noFilter.equalsIgnoreCase("NO")) {
-// int ind = skipString.indexOf("/");
-// if (ind != -1) {
-// skipString = skipString.substring(ind +1);
-//
-// if (skipString.trim().startsWith("-")) //temp fix for negative value
-// skipString = skipString.substring(1);
-//
-// skip = skipString.split(";");
-//
-// if (skip != null && skip.length !=0){
-// try {
-// skipx = Integer.parseInt(skip[0]);
-// }
-// catch (NumberFormatException e) {
-// System.out.println("The skip is not an interger");
-// skipx = 0;
-// }
-//
-// if (skip.length ==1 ) {
-// skipy = skipx;
-// }
-// if (skip.length >1 && skip[0] != skip[1]) {
-// try {
-// skipy = Integer.parseInt(skip[1]);
-// }
-// catch (NumberFormatException e) {
-// System.out.println("The skip is not an interger");
-// skipy = skipx;
-// }
-// }
-// }
-// else {
-// skipx = 0;
-// skipy = 0;
-// }
-// }
-// else {
-// skipx = 0;
-// skipy = 0;
-// }
-// }
-// else {
-// skipx = 0;
-// skipy = 0;
-// }
-//
-
- for (int i = 0; i < (gridDims[0] * gridDims[1]); i++)
- isPlotted[i] = false;
-
+ String den = gridRscData.getFilter();
+ String noFilter = "";
+ if (den != null) {
+ try {
+ if (den.equalsIgnoreCase("YES") || den.equalsIgnoreCase("Y")) {
+ filter = 1.0;
+ } else if (den.equalsIgnoreCase("NO")
+ || den.equalsIgnoreCase("N")
+ || den.equalsIgnoreCase("")) {
+ filter = 0.0;
+ noFilter = "NO";
+ } else {
+ filter = Double.parseDouble(den);
+ }
+
+ if (filter == 0)
+ noFilter = "NO";
+ if (filter < 0.1)
+ filter = 0.1;
+ } catch (NumberFormatException e) {
+ System.out.println("The filter is not a double number");
+ filter = 1.0;
+ }
+ } else {
+ filter = 1.0;
+ }
+
+ // /**
+ // * Get skip attribute
+ // */
+ //
+ // String[] skip = null;
+ // int skipx = 0;
+ // int skipy = 0;
+ //
+ // String skipString = gridRscData.getSkip(); //now for positive skip
+ // if (skipString != null && noFilter.equalsIgnoreCase("NO")) {
+ // int ind = skipString.indexOf("/");
+ // if (ind != -1) {
+ // skipString = skipString.substring(ind +1);
+ //
+ // if (skipString.trim().startsWith("-")) //temp fix for negative value
+ // skipString = skipString.substring(1);
+ //
+ // skip = skipString.split(";");
+ //
+ // if (skip != null && skip.length !=0){
+ // try {
+ // skipx = Integer.parseInt(skip[0]);
+ // }
+ // catch (NumberFormatException e) {
+ // System.out.println("The skip is not an interger");
+ // skipx = 0;
+ // }
+ //
+ // if (skip.length ==1 ) {
+ // skipy = skipx;
+ // }
+ // if (skip.length >1 && skip[0] != skip[1]) {
+ // try {
+ // skipy = Integer.parseInt(skip[1]);
+ // }
+ // catch (NumberFormatException e) {
+ // System.out.println("The skip is not an interger");
+ // skipy = skipx;
+ // }
+ // }
+ // }
+ // else {
+ // skipx = 0;
+ // skipy = 0;
+ // }
+ // }
+ // else {
+ // skipx = 0;
+ // skipy = 0;
+ // }
+ // }
+ // else {
+ // skipx = 0;
+ // skipy = 0;
+ // }
+ //
+
+ for (int i = 0; i < (gridDims[0] * gridDims[1]); i++)
+ isPlotted[i] = false;
+
// Controls whether to draw images or debugging output on the map
-// boolean debug = false;
+ // boolean debug = false;
this.target = target;
PaintProperties pp = new PaintProperties(paintProps);
@@ -242,8 +241,8 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
IExtent viewPixelExtent = paintProps.getView().getExtent();
double ratio = viewPixelExtent.getWidth()
/ paintProps.getCanvasBounds().width;
-
- //double interval = size * .75 * ratio / Math.min(2.0, filter);
+
+ // double interval = size * .75 * ratio / Math.min(2.0, filter);
double interval = size * .75 * ratio * filter;
double adjSize = size * ratio * magnification;
@@ -284,18 +283,15 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
}
jcount++;
/*
- if (debug == true) {
- // Draw a red labeled square over the area where
- // we will look for grid points
- target.drawString(null, icount + "," + jcount, i, j,
- 0.0, TextStyle.NORMAL, new RGB(255, 0, 0),
- HorizontalAlignment.CENTER,
- VerticalAlignment.MIDDLE, 0.0);
- target.drawRect(new PixelExtent(i - halfInterval, i
- + halfInterval, j - halfInterval, j
- + halfInterval), new RGB(255, 0, 0), 1, 1);
- }
- */
+ * if (debug == true) { // Draw a red labeled square over
+ * the area where // we will look for grid points
+ * target.drawString(null, icount + "," + jcount, i, j, 0.0,
+ * TextStyle.NORMAL, new RGB(255, 0, 0),
+ * HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE,
+ * 0.0); target.drawRect(new PixelExtent(i - halfInterval, i
+ * + halfInterval, j - halfInterval, j + halfInterval), new
+ * RGB(255, 0, 0), 1, 1); }
+ */
// Get a grid coordinate near i, j
ReferencedCoordinate coordToTry = new ReferencedCoordinate(
this.descriptor.getGridGeometry(), new Coordinate(
@@ -304,23 +300,27 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
gridGeometryOfGrid, PixelInCell.CELL_CORNER);
gridCell.y = Math.round(gridCell.y);
gridCell.x = Math.round(gridCell.x);
-
-
+
+ // System.out.println("Look--" + i + " , " + j);
+ // System.out.println("grid--" + gridCell.x + " , "
+ // + gridCell.y);
/*
* Convert negative longitude
*/
Coordinate coord = coordToTry.asLatLon();
double x = coord.x;
if (globalModel && x < 0) {
- x = x + 360;
+ x = x + 360;
}
-
+
Coordinate newCoord = new Coordinate(x, coord.y);
- ReferencedCoordinate newrco = new ReferencedCoordinate(newCoord);
+ // System.out.println("latlon: " + newCoord);
+ ReferencedCoordinate newrco = new ReferencedCoordinate(
+ newCoord);
Coordinate newGridCell = newrco.asGridCell(
gridGeometryOfGrid, PixelInCell.CELL_CORNER);
newGridCell.x = Math.round(newGridCell.x);
-
+
/*
* Check for bounds
*/
@@ -328,33 +328,33 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
|| (gridCell.y < 0 || gridCell.y >= gridDims[1])) {
thisRow.put(j, i);
continue;
-
+
}
-
+
ReferencedCoordinate rco = new ReferencedCoordinate(
- new Coordinate((int)gridCell.x, (int)gridCell.y),
- this.gridGeometryOfGrid, Type.GRID_CORNER);
- Coordinate plotLoc = rco.asPixel(this.descriptor.getGridGeometry());
- Coordinate gridCell2 = rco.asGridCell(
- gridGeometryOfGrid, PixelInCell.CELL_CORNER);
-
-// Coordinate plotLoc = coordToTry.asPixel(this.descriptor
-// .getGridGeometry());
-
-
+ new Coordinate((int) gridCell.x, (int) gridCell.y),
+ this.gridGeometryOfGrid, Type.GRID_CORNER);
+ Coordinate plotLoc = rco.asPixel(this.descriptor
+ .getGridGeometry());
+ Coordinate gridCell2 = rco.asGridCell(gridGeometryOfGrid,
+ PixelInCell.CELL_CORNER);
+
+ // System.out.println("gridcell: " + gridCell);
+ // System.out.println("gridcell2: " + gridCell2);
+ // Coordinate plotLoc = coordToTry.asPixel(this.descriptor
+ // .getGridGeometry());
+
/*
- if (debug == true) {
- // draw a blue dot where the gridpoints are found.
- target.drawString(null, ".", plotLoc.x, plotLoc.y, 0.0,
- TextStyle.NORMAL, new RGB(0, 0, 255),
- HorizontalAlignment.CENTER,
- VerticalAlignment.BOTTOM, 0.0);
- }
- */
+ * if (debug == true) { // draw a blue dot where the
+ * gridpoints are found. target.drawString(null, ".",
+ * plotLoc.x, plotLoc.y, 0.0, TextStyle.NORMAL, new RGB(0,
+ * 0, 255), HorizontalAlignment.CENTER,
+ * VerticalAlignment.BOTTOM, 0.0); }
+ */
// If the real loc of this grid coordinate is close to the
// loc we wanted go with it
- if (Math.abs(plotLoc.y - j) < (interval/2)
- && Math.abs(plotLoc.x - i) < (interval/2)) {
+ if (Math.abs(plotLoc.y - j) < (interval / 2)
+ && Math.abs(plotLoc.x - i) < (interval / 2)) {
j = plotLoc.y;
thisRow.put(j, plotLoc.x);
} else {
@@ -362,21 +362,24 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
continue;
}
/*
- if (debug == true) {
- // Draw a green label where the image will actually be
- // drawn
- target.drawString(null, icount + "," + jcount,
- plotLoc.x, plotLoc.y, 0.0, TextStyle.NORMAL,
- new RGB(0, 255, 0), HorizontalAlignment.CENTER,
- VerticalAlignment.MIDDLE, 0.0);
- }
- */
-
+ * if (debug == true) { // Draw a green label where the
+ * image will actually be // drawn target.drawString(null,
+ * icount + "," + jcount, plotLoc.x, plotLoc.y, 0.0,
+ * TextStyle.NORMAL, new RGB(0, 255, 0),
+ * HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE,
+ * 0.0); }
+ */
+
T oldImage = getImage(gridCell2);
if (oldImage != null) {
-// if (debug == false) {
- paintImage((int)gridCell.x, (int)gridCell.y, pp, adjSize);
-// }
+ // if (debug == false) {
+ if (globalModel)
+ paintGlobalImage((int) gridCell.x,
+ (int) gridCell.y, pp, adjSize);
+ else
+ paintImage((int) gridCell.x, (int) gridCell.y, pp,
+ adjSize);
+ // }
} else {
if (async) {
if (!this.calculationQueue.contains(gridCell2)) {
@@ -384,17 +387,22 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
}
} else {
T image = createImage(gridCell2);
- if (image != null /*&& debug == false*/) {
- paintImage((int)gridCell.x, (int)gridCell.y, pp, adjSize);
+ if (image != null /* && debug == false */) {
+ if (globalModel)
+ paintGlobalImage((int) gridCell.x,
+ (int) gridCell.y, pp, adjSize);
+ else
+ paintImage((int) gridCell.x,
+ (int) gridCell.y, pp, adjSize);
}
}
- }
+ }
}
- } //while
+ } // while
} catch (Exception e) {
throw new VizException("Error occured during paint", e);
}
-
+
if (calculationQueue.size() > 0) {
if (this.calculationJob == null) {
this.calculationJob = new CalculationJob();
@@ -429,8 +437,13 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
*/
protected abstract void disposeImages();
- protected abstract void paintImage(int x, int y, PaintProperties paintProps,
- double adjustedSize) throws VizException;
+ protected abstract void paintImage(int x, int y,
+ PaintProperties paintProps, double adjustedSize)
+ throws VizException;
+
+ protected abstract void paintGlobalImage(int x, int y,
+ PaintProperties paintProps, double adjustedSize)
+ throws VizException;
public void dispose() {
disposeImages();
@@ -451,7 +464,7 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
/**
* @param filter
- * the filter to set. Changed from density.
+ * the filter to set. Changed from density.
*/
public boolean setFilter(double filter) {
if (this.filter != filter) {
@@ -461,16 +474,15 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
return false;
}
-
public float getSize() {
- return size;
- }
+ return size;
+ }
- public void setSize(float size) {
- this.size = size;
- }
+ public void setSize(float size) {
+ this.size = size;
+ }
- /**
+ /**
* @param magnification
* the magnification to set
*/
@@ -482,38 +494,36 @@ public abstract class AbstractGriddedDisplay { //implements IRenderable
return false;
}
-
private boolean isGlobalModel() throws VizException {
-
- ReferencedCoordinate newrco0 = new ReferencedCoordinate(
- new Coordinate(0, 0),
- this.gridGeometryOfGrid, Type.GRID_CORNER);
- ReferencedCoordinate newrco1 = new ReferencedCoordinate(
- new Coordinate(gridDims[0] - 1, 0),
- this.gridGeometryOfGrid, Type.GRID_CORNER);
- ReferencedCoordinate newrco2 = new ReferencedCoordinate(
- new Coordinate(1, 0),
- this.gridGeometryOfGrid, Type.GRID_CORNER);
- try {
- Coordinate latLon0 = newrco0.asLatLon();
- Coordinate latLon1 = newrco1.asLatLon();
- Coordinate latLon2 = newrco2.asLatLon();
-
- double dx1 = latLon2.x - latLon0.x;
- double dx2 = (360 - latLon1.x) + latLon0.x;
-
- int dx = (int) Math.round(dx2/dx1);
- int dlat = (int) Math.round(latLon1.y - latLon0.y);
+ ReferencedCoordinate newrco0 = new ReferencedCoordinate(new Coordinate(
+ 0, 0), this.gridGeometryOfGrid, Type.GRID_CORNER);
+ ReferencedCoordinate newrco1 = new ReferencedCoordinate(new Coordinate(
+ gridDims[0] - 1, 0), this.gridGeometryOfGrid, Type.GRID_CORNER);
+ ReferencedCoordinate newrco2 = new ReferencedCoordinate(new Coordinate(
+ 1, 0), this.gridGeometryOfGrid, Type.GRID_CORNER);
- if (dx <= 2 && dlat == 0) return true;
-
- } catch (Exception e) {
- throw new VizException(e);
- }
-
- return false;
+ try {
+ Coordinate latLon0 = newrco0.asLatLon();
+ Coordinate latLon1 = newrco1.asLatLon();
+ Coordinate latLon2 = newrco2.asLatLon();
+
+ double dx1 = latLon2.x - latLon0.x;
+ double dx2 = (360 - latLon1.x) + latLon0.x;
+
+ int dx = (int) Math.round(dx2 / dx1);
+ int dlat = (int) Math.round(latLon1.y - latLon0.y);
+
+ if (dx <= 2 && dlat == 0)
+ return true;
+
+ } catch (Exception e) {
+ throw new VizException(e);
+ }
+
+ return false;
}
+
/**
* Off UI Thread job for calculating the wind images
*
diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/ContourSupport.java b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/ContourSupport.java
index af78e4507c..8abaa21614 100644
--- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/ContourSupport.java
+++ b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/ContourSupport.java
@@ -116,7 +116,7 @@ import com.vividsolutions.jts.linearref.LocationIndexedLine;
* May 23, 2012 X. Guo Loaded ncgrib logger
* Apr 26, 2013 B. Yin Fixed the world wrap problem for centeral line 0/180.
* Jun 06, 2013 B. Yin fixed the half-degree grid porblem.
- * Jul 19, 2013 B. Hebbard Merge in RTS change of Util-->ArraysUtil
+ * Jul 19, 2013 B. Hebbard Merge in RTS change of Util-->ArraysUtil
* Aug 19, 2013 #743 S. Gurung Added clrbar and corresponding getter/setter method (from Archana's branch) and
* fix for editing clrbar related attribute changess not being applied from right click legend.
* Aug 27, 2013 2262 bsteffen Convert to use new StrmPak.
@@ -127,58 +127,80 @@ import com.vividsolutions.jts.linearref.LocationIndexedLine;
*/
public class ContourSupport {
- private static NcepLogger logger = NcepLoggerManager.getNcepLogger(ContourSupport.class);
+ private static NcepLogger logger = NcepLoggerManager
+ .getNcepLogger(ContourSupport.class);
+
+ // provided values
+ private IDataRecord records;
+
+ private int level;
+
+ private IExtent extent;
+
+ private double currentDensity;
+
+ private IMapDescriptor descriptor;
+
+ private ContourAttributes attr;
+
+ private String cint;
+
+ private String fint;
+
+ private String type;
+
+ private String fline;
+
+ private String name;
+
+ private float zoom;
+
+ // calculated values
+ private ContourGroup contourGroup = null;
+
+ private MathTransform rastPosToWorldGrid = null;
- //provided values
- private IDataRecord records;
- private int level;
- private IExtent extent;
- private double currentDensity;
- private IMapDescriptor descriptor;
- private ContourAttributes attr;
- private String cint;
- private String fint;
- private String type;
- private String fline;
- private String name;
- private float zoom;
-
- //calculated values
- private ContourGroup contourGroup = null;
- private MathTransform rastPosToWorldGrid = null;
private MathTransform rastPosToLatLon = null;
+
private MathTransform rastPosLatLonToWorldGrid = null;
+
private int zoomLevelIndex;
+
private ContourGridData cntrData = null;
+
private List cvalues;
+
private List fvalues;
+
private Set svalues;
+
private boolean globalData = false;
-
- //world map with central meridian at 180 degree
+
+ // world map with central meridian at 180 degree
private boolean isWorld180;
-
- //return value from raytheon's worlWrapChecker
+
+ // return value from raytheon's worlWrapChecker
private boolean worldWrapChecker;
- //flag that indicates world wrap is needed
+ // flag that indicates world wrap is needed
private boolean worldWrap;
-
- //central meridian
+
+ // central meridian
private double centralMeridian = 0;
-
- //screen width of the map
+
+ // screen width of the map
private double mapScreenWidth;
-
- //screen x of the zero longitude
+
+ // screen x of the zero longitude
private double zeroLonOnScreen;
-
- //maximum number of grid along x direction
+
+ // maximum number of grid along x direction
private int maxGridX;
-
+
private boolean isCntrsCreated;
+
private static NcgribLogger ncgribLogger = NcgribLogger.getInstance();
-
+
/**
* Constructor
*
@@ -196,23 +218,18 @@ public class ContourSupport {
* @param zoom
* @param contourGp
* */
- public ContourSupport(IDataRecord records, int level,
- IExtent extent, double currentDensity,
- MathTransform worldGridToCRSTransform,
+ public ContourSupport(IDataRecord records, int level, IExtent extent,
+ double currentDensity, MathTransform worldGridToCRSTransform,
GeneralGridGeometry imageGridGeometry,
GeneralGridGeometry mapGridGeometry, IGraphicsTarget target,
- IMapDescriptor descriptor, ContourAttributes attr, String name, float zoom,
- ContourGroup contourGp) {
-
- initContourSupport ( records, level,
- extent, currentDensity,
- worldGridToCRSTransform,
- imageGridGeometry,
- mapGridGeometry, target,
- descriptor, attr, name, zoom,
- contourGp);
+ IMapDescriptor descriptor, ContourAttributes attr, String name,
+ float zoom, ContourGroup contourGp) {
+
+ initContourSupport(records, level, extent, currentDensity,
+ worldGridToCRSTransform, imageGridGeometry, mapGridGeometry,
+ target, descriptor, attr, name, zoom, contourGp);
}
-
+
/**
* Data structure for contouring
*/
@@ -222,7 +239,7 @@ public class ContourSupport {
public IWireframeShape posValueShape;
public IWireframeShape negValueShape;
-
+
public IShadedShape fillShapes;
public ContourGroup parent;
@@ -232,187 +249,202 @@ public class ContourSupport {
public double lastDensity;
public GridGeometry gridGeometry;
-
+
public List cvalues;
-
+
public List fvalues;
-
- public HashMap< String, Geometry> data;
-
+
+ public HashMap data;
+
public LinearRing grid;
public CLRBAR clrbar;
-
+
public ColorBar colorBarForGriddedFill;
-
+
}
public class ContourGridData {
- private float minValue;
- private float maxValue;
- private float[] data;
- private int szX;
- private int szY;
-
- public ContourGridData ( IDataRecord record ) {
- maxValue = Float.MIN_VALUE;
+ private float minValue;
+
+ private float maxValue;
+
+ private final float[] data;
+
+ private final int szX;
+
+ private final int szY;
+
+ public ContourGridData(IDataRecord record) {
+ maxValue = Float.MIN_VALUE;
minValue = Float.MAX_VALUE;
float[] data1D = null;
long[] sz = record.getSizes();
-
+
data1D = ((NcFloatDataRecord) record).getXdata();
-
- szX = (int)sz[0];
- szY = (int)sz[1];
- data = new float[szX*szY];
+
+ szX = (int) sz[0];
+ szY = (int) sz[1];
+ data = new float[szX * szY];
for (int j = 0; j < szY; j++) {
for (int i = 0; i < szX; i++) {
- data[szX * j + i] = data1D[(szX * j)+ i];
- if ( data[szX * j + i] != -999999.f ) {
- maxValue = Math.max( maxValue, data[szX * j + i]);
- minValue = Math.min( minValue, data[szX * j + i]);
- }
+ data[(szX * j) + i] = data1D[(szX * j) + i];
+ if (data[(szX * j) + i] != -999999.f) {
+ maxValue = Math.max(maxValue, data[(szX * j) + i]);
+ minValue = Math.min(minValue, data[(szX * j) + i]);
+ }
}
}
- }
-
- public float getMinValue () {
- return minValue;
- }
-
- public float getMaxValue () {
- return maxValue;
- }
-
- public float[] getData () {
- return data;
- }
- public int getX () {
- return szX;
- }
-
- public int getY () {
- return szY;
- }
+ }
+
+ public float getMinValue() {
+ return minValue;
+ }
+
+ public float getMaxValue() {
+ return maxValue;
+ }
+
+ public float[] getData() {
+ return data;
+ }
+
+ public int getX() {
+ return szX;
+ }
+
+ public int getY() {
+ return szY;
+ }
}
-
+
public void initContourSupport(IDataRecord records, int level,
IExtent extent, double currentDensity,
MathTransform worldGridToCRSTransform,
GeneralGridGeometry imageGridGeometry,
GeneralGridGeometry mapGridGeometry, IGraphicsTarget target,
- IMapDescriptor descriptor, ContourAttributes attr, String name, float zoom,
- ContourGroup contourGp) {
- isCntrsCreated = true;
- if ( records == null || attr == null ) {
- isCntrsCreated = false;
- return;
- }
- if ( ! initMathTransform (imageGridGeometry,mapGridGeometry) ) {
- isCntrsCreated = false;
- return;
- }
- this.records = records;
- this.level = level;
- this.extent = extent;
- this.currentDensity = currentDensity;
- this.descriptor = descriptor;
- this.attr = attr;
- this.cint = attr.getCint();
- this.type = attr.getType();
- this.fint = attr.getFint();
- this.fline = attr.getFline();
- this.name = name;
- this.zoom = zoom;
- this.cntrData = new ContourGridData(records);
- this.centralMeridian = getCentralMeridian(descriptor);
- if ( centralMeridian == -180 ) centralMeridian = 180;
- this.isWorld180 = (centralMeridian == 180.0);
- this.worldWrapChecker = new WorldWrapChecker(descriptor.getGridGeometry().getEnvelope()).needsChecking();
- this.worldWrap = needWrap(imageGridGeometry, rastPosToLatLon);
- mapScreenWidth = this.getMapWidth();
+ IMapDescriptor descriptor, ContourAttributes attr, String name,
+ float zoom, ContourGroup contourGp) {
+ isCntrsCreated = true;
+ if ((records == null) || (attr == null)) {
+ isCntrsCreated = false;
+ return;
+ }
+ if (!initMathTransform(imageGridGeometry, mapGridGeometry)) {
+ isCntrsCreated = false;
+ return;
+ }
+ this.records = records;
+ this.level = level;
+ this.extent = extent;
+ this.currentDensity = currentDensity;
+ this.descriptor = descriptor;
+ this.attr = attr;
+ this.cint = attr.getCint();
+ this.type = attr.getType();
+ this.fint = attr.getFint();
+ this.fline = attr.getFline();
+ this.name = name;
+ this.zoom = zoom;
+ this.cntrData = new ContourGridData(records);
+ this.centralMeridian = getCentralMeridian(descriptor);
+ if (centralMeridian == -180) {
+ centralMeridian = 180;
+ }
+ this.isWorld180 = (centralMeridian == 180.0);
+ this.worldWrapChecker = new WorldWrapChecker(descriptor
+ .getGridGeometry().getEnvelope()).needsChecking();
+ this.worldWrap = needWrap(imageGridGeometry, rastPosToLatLon);
+ mapScreenWidth = this.getMapWidth();
maxGridX = this.getMaxGridX(imageGridGeometry);
- initContourGroup ( target,contourGp );
+ initContourGroup(target, contourGp);
}
+
/**
* Create contours from provided parameters
*
*/
- public void createContours( ) {
-
- long t0 = System.currentTimeMillis();
-
+ public void createContours() {
+
+ long t0 = System.currentTimeMillis();
+
// Copy the pixel extent (deep copy required!)
// expand by 50% to cover the subgrid expansion
-/* PixelExtent workingExtent = (PixelExtent) extent.clone();
- workingExtent.getEnvelope().expandBy(workingExtent.getWidth() * .5,
- workingExtent.getHeight() * .5);*/
+ /*
+ * PixelExtent workingExtent = (PixelExtent) extent.clone();
+ * workingExtent.getEnvelope().expandBy(workingExtent.getWidth() * .5,
+ * workingExtent.getHeight() * .5);
+ */
/*
* Contours and/or color fills
*/
- if (records instanceof NcFloatDataRecord &&
- !((NcFloatDataRecord)records).isVector()) {
+ if ((records instanceof NcFloatDataRecord)
+ && !((NcFloatDataRecord) records).isVector()) {
long t1 = System.currentTimeMillis();
- logger.debug("Preparing " + name + " grid data took: " + (t1-t0));
-
+ logger.debug("Preparing " + name + " grid data took: " + (t1 - t0));
+
/*
- * ZoomLevel.
+ * ZoomLevel.
*/
- initZoomIndex ();
-
+ initZoomIndex();
+
long t1a = System.currentTimeMillis();
- logger.debug("new ContourGenerator took: " + (t1a-t1));
-
+ logger.debug("new ContourGenerator took: " + (t1a - t1));
+
/*
- * Get contour values from CINT
- */
- cvalues = calcCintValue ();
+ * Get contour values from CINT
+ */
+ cvalues = calcCintValue();
/*
- * Get color fill values from FINT and FLINE
- */
- fvalues = calcFintValue ();
+ * Get color fill values from FINT and FLINE
+ */
+ fvalues = calcFintValue();
/*
* Combine contour and fill values
*/
- combineCintAndFillValues ();
-
+ combineCintAndFillValues();
+
long t2 = System.currentTimeMillis();
- if ( svalues != null && svalues.size() > 0 ) {
- genContour ();
- if ( ! isCntrsCreated ) return;
- }
- else {
- logger.debug("Re-load contour line values took: " + (t2-t1));
+ if ((svalues != null) && (svalues.size() > 0)) {
+ genContour();
+ if (!isCntrsCreated) {
+ return;
+ }
+ } else {
+ logger.debug("Re-load contour line values took: " + (t2 - t1));
}
/*
* Create contour lines and labels wireframes
*/
- createContourLines ();
+ createContourLines();
/*
* Create color fills
*/
createColorFills();
-
+
long t10 = System.currentTimeMillis();
-// System.out.println("Contouring/Filling took: " + (t10-t0));
- logger.debug("===Total time for ("+name+") "+ " took: " + (t10-t0) + "\n");
-// logger.info("===Total time for "+ cf_string + " " + attr.getGdpfun().trim().toUpperCase()
-// + " took: " + (t10-t0) + "\n");
-
-// System.out.println("Total time for " + cf_string + " " + name + " took: " + (t10-t0) + "\n");
- /*
- * Streamlines
- */
+ // System.out.println("Contouring/Filling took: " + (t10-t0));
+ logger.debug("===Total time for (" + name + ") " + " took: "
+ + (t10 - t0) + "\n");
+ // logger.info("===Total time for "+ cf_string + " " +
+ // attr.getGdpfun().trim().toUpperCase()
+ // + " took: " + (t10-t0) + "\n");
+
+ // System.out.println("Total time for " + cf_string + " " + name +
+ // " took: " + (t10-t0) + "\n");
+ /*
+ * Streamlines
+ */
} else {
- createStreamLines();
+ createStreamLines();
}
}
public static GeneralEnvelope calculateSubGrid(IExtent workingExtent,
GeneralGridGeometry mapGridGeometry,
- GeneralGridGeometry imageGridGeometry) {
+ GeneralGridGeometry imageGridGeometry) {
GeneralEnvelope env = null;
try {
// transform screen extent to map crs
@@ -423,16 +455,18 @@ public class ContourSupport {
mapGridGeometry.getGridToCRS(PixelInCell.CELL_CORNER).transform(
screen, 0, map, 0, 2);
Envelope mapEnv = new Envelope(map[0], map[2], map[1], map[3]);
-
+
// transform map envelope to image crs
ReferencedEnvelope ref = new ReferencedEnvelope(mapEnv,
mapGridGeometry.getCoordinateReferenceSystem());
-
- Envelope imageEnv = ref.transform(imageGridGeometry
- .getCoordinateReferenceSystem(), true);
- if (imageEnv == null) return null;
-
+ Envelope imageEnv = ref.transform(
+ imageGridGeometry.getCoordinateReferenceSystem(), true);
+
+ if (imageEnv == null) {
+ return null;
+ }
+
// transform image envelope to image grid cells
double[] image = new double[] { imageEnv.getMinX(),
imageEnv.getMinY(), imageEnv.getMaxX(), imageEnv.getMaxY() };
@@ -441,460 +475,486 @@ public class ContourSupport {
.transform(image, 0, grid, 0, 2);
env = new GeneralEnvelope(2);
- env.setRange(0, Math.min(grid[0], grid[2]), Math.max(grid[0],
- grid[2]));
- env.setRange(1, Math.min(grid[1], grid[3]), Math.max(grid[1],
- grid[3]));
+ env.setRange(0, Math.min(grid[0], grid[2]),
+ Math.max(grid[0], grid[2]));
+ env.setRange(1, Math.min(grid[1], grid[3]),
+ Math.max(grid[1], grid[3]));
} catch (Exception e) {
-// throw new VizException("Error transforming extent", e);
+ // throw new VizException("Error transforming extent", e);
logger.error("Error transforming extent:" + e);
return null;
}
-// System.out.println("*** Subgrid: " + env);
+ // System.out.println("*** Subgrid: " + env);
return env;
}
- private static void createContourLabel(IExtent extent, ContourGroup contourGroup,
- float contourValue, double[][] valsArr) {
-
- double minx = extent.getMinX();
- double miny = extent.getMinY();
- double maxx = extent.getMaxX();
- double maxy = extent.getMaxY();
-
- double[][] visiblePts = new double[valsArr.length][valsArr[0].length];
- int actualLength = 0;
-
- for ( double[] dl : valsArr ) {
- if ( dl[0] > minx && dl[0] < maxx &&
- dl[1] > miny && dl[1] < maxy ) {
- visiblePts[actualLength][0] = dl[0];
- visiblePts[actualLength][1] = dl[1];
- actualLength++;
- }
- }
-
- DecimalFormat df = new DecimalFormat("0.#");
- double[] loc = {0.0, 0.0};
-
- if (actualLength > 0) {
- loc[ 0 ] = visiblePts[ actualLength/2 ][0];
- loc[ 1 ] = visiblePts[ actualLength/2 ][1];
-
- contourGroup.negValueShape.addLabel(df
- .format(contourValue), loc);
- }
-
- }
- private double[][] toScreen(Coordinate[] coords, MathTransform xform, int minX, int minY) {
-
- int size = coords.length;
-
- //remove points on longitude 360 degree. to avoid long cross lines
- if ( isWorld180 ) {
- for ( Coordinate pt : coords ){
- if ( pt.x == maxGridX) size--;
- }
- }
-
- double[][] out = new double[size][3];
- long nx = records.getSizes()[0] - 1;
-
- for ( int i=0, jj = 0; i< coords.length; i++, jj++ ) {
- if ( isWorld180 && coords[i].x == maxGridX ){ jj--; continue;}
-
- double[] tmp = new double[2];
- tmp[0]=coords[i].x + minX;
- tmp[1]=coords[i].y + minY;
-// if (tmp[0] > 180) tmp[0] -= 360;
-
- try {
- xform.transform(tmp, 0, out[jj], 0, 1);
- } catch (TransformException e) {
- // TODO Auto-generated catch block
- // e.printStackTrace();
- return null;
- }
-
- if ( worldWrapChecker ) {
- if ( tmp[0] > (nx-1) && out[jj][0] < 0){
- out[jj][0] = mapScreenWidth;
- }
- else if (tmp[0] < 1 && out[jj][0] > mapScreenWidth*0.9 ){
- out[jj][0] = 0;
- }
- }
+ private static void createContourLabel(IExtent extent,
+ ContourGroup contourGroup, float contourValue, double[][] valsArr) {
+ double minx = extent.getMinX();
+ double miny = extent.getMinY();
+ double maxx = extent.getMaxX();
+ double maxy = extent.getMaxY();
+
+ double[][] visiblePts = new double[valsArr.length][valsArr[0].length];
+ int actualLength = 0;
+
+ for (double[] dl : valsArr) {
+ if ((dl[0] > minx) && (dl[0] < maxx) && (dl[1] > miny)
+ && (dl[1] < maxy)) {
+ visiblePts[actualLength][0] = dl[0];
+ visiblePts[actualLength][1] = dl[1];
+ actualLength++;
+ }
}
-
- if ( out.length > 0 ) {
- return out;
- }
- else {
- return null;
+
+ DecimalFormat df = new DecimalFormat("0.#");
+ double[] loc = { 0.0, 0.0 };
+
+ if (actualLength > 0) {
+ loc[0] = visiblePts[actualLength / 2][0];
+ loc[1] = visiblePts[actualLength / 2][1];
+
+ contourGroup.negValueShape.addLabel(df.format(contourValue), loc);
}
+
}
- private double[][] toScreenRightOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
- // Coordinate[] out = new Coordinate[coords.length];
- double[][] out = new double[coords.length][3];
-
- for ( int i=0; i< coords.length; i++ ) {
- double[] tmp = new double[2];
- tmp[0]=coords[i].x + minX;
- tmp[1]=coords[i].y + minY;
-
- try {
- xform.transform(tmp, 0, out[i], 0, 1);
- } catch (TransformException e) {
- // e.printStackTrace();
- return null;
- }
-
- // System.out.println("WWWWWWW " + tmp[0]+" " + " " + out[i][0]);
-
- if ( out[i][0] < zeroLonOnScreen || (tmp[0] == maxGridX && out[i][0] == zeroLonOnScreen)){
- out[i][0] += mapScreenWidth;
- // System.out.println("Shift " + tmp[0]+" " + out[i][0]);
- }
- // else if ( delta < 0 && !(out[i][0] < middle ) && (delta < 0 || Math.abs(out[i][0]) < Math.abs(delta)) ){
-
- // System.out.println("SSSSSSSSSSSShift" + tmp[0]+" " + tmpout[0] + " " + out[i][0]);
- // out[i][0] += delta;
- // }
-
- }
-
- if ( out.length > 0 ) {
- return out;
- }
- else {
- return null;
- }
- }
-
- private LineString toScreenLSRightOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
- GeometryFactory gf = new GeometryFactory();
- Coordinate[] out = new Coordinate[coords.length];
- double[] tmpout = new double[3];
-
- for ( int i=0; i< coords.length; i++ ) {
- double[] tmp = new double[2];
- tmp[0]=coords[i].x + minX;
- tmp[1]=coords[i].y + minY;
-
- try {
- xform.transform(tmp, 0, tmpout, 0, 1);
- } catch (TransformException e) {
- // e.printStackTrace();
- return null;
- }
-
- if ( tmpout[0] < zeroLonOnScreen || (tmp[0] == maxGridX && tmpout[0] == zeroLonOnScreen)){
- tmpout[0] += mapScreenWidth;
- }
-
- out[i] = new Coordinate( tmpout[0], tmpout[1] );
-
- }
-
- if ( out.length >= 2 ) {
- return gf.createLineString(out);
- }
- else {
- return null;
- }
- }
-
- private double[][] toScreenLeftOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
- // Coordinate[] out = new Coordinate[coords.length];
- double[][] out = new double[coords.length][3];
-
- for ( int i=0; i< coords.length; i++ ) {
- double[] tmp = new double[2];
- tmp[0]=coords[i].x + minX;
- tmp[1]=coords[i].y + minY;
-
- try {
- xform.transform(tmp, 0, out[i], 0, 1);
- } catch (TransformException e) {
- // e.printStackTrace();
- return null;
- }
-
- // System.out.println("WWWWWWW " + tmp[0]+" " + tmpout[0] + " " + out[i][0]);
-
- if ( out[i][0] > zeroLonOnScreen || ( tmp[0] == 0 && out[i][0] == zeroLonOnScreen )){
- // System.out.println("Shift " + tmp[0]+" " + out[i][0]);
- out[i][0] -= mapScreenWidth;
- }
-
- }
-
- if ( out.length > 0 ) {
- return out;
- }
- else {
- return null;
- }
- }
-
-
- private LineString toScreenLSLeftOfZero(Coordinate[] coords, MathTransform xform, int minX, int minY) {
- GeometryFactory gf = new GeometryFactory();
- Coordinate[] out = new Coordinate[coords.length];
- double[] tmpout = new double[3];
-
- for ( int i=0; i< coords.length; i++ ) {
- double[] tmp = new double[2];
- tmp[0]=coords[i].x + minX;
- tmp[1]=coords[i].y + minY;
-
- try {
- xform.transform(tmp, 0, tmpout, 0, 1);
- } catch (TransformException e) {
- // e.printStackTrace();
- return null;
- }
-
- if ( tmpout[0] > zeroLonOnScreen || (tmp[0] == 0 && tmpout[0] == zeroLonOnScreen)){
- tmpout[0] -= mapScreenWidth;
- }
-
- out[i] = new Coordinate( tmpout[0], tmpout[1] );
-
- }
-
- if ( out.length >= 2 ) {
- return gf.createLineString(out);
- }
- else {
- return null;
- }
- }
- private LineString toScreenLS(Coordinate[] coords, MathTransform xform, int minX, int minY) {
-
- GeometryFactory gf = new GeometryFactory();
- long nx = records.getSizes()[0] - 1;
+ private double[][] toScreen(Coordinate[] coords, MathTransform xform,
+ int minX, int minY) {
int size = coords.length;
- //remove points on 360. to avoid long cross lines
- if ( isWorld180 ) {
- for ( Coordinate pt : coords ){
- if ( pt.x == maxGridX) size--;
- }
- }
-
+
+ // remove points on longitude 360 degree. to avoid long cross lines
+ if (isWorld180) {
+ for (Coordinate pt : coords) {
+ if (pt.x == maxGridX) {
+ size--;
+ }
+ }
+ }
+
+ double[][] out = new double[size][3];
+ long nx = records.getSizes()[0] - 1;
+
+ for (int i = 0, jj = 0; i < coords.length; i++, jj++) {
+ if (isWorld180 && (coords[i].x == maxGridX)) {
+ jj--;
+ continue;
+ }
+
+ double[] tmp = new double[2];
+ tmp[0] = coords[i].x + minX;
+ tmp[1] = coords[i].y + minY;
+ // if (tmp[0] > 180) tmp[0] -= 360;
+
+ try {
+ xform.transform(tmp, 0, out[jj], 0, 1);
+ } catch (TransformException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ return null;
+ }
+
+ if (worldWrap) {
+ if ((tmp[0] > (nx - 1)) && (out[jj][0] < 0)) {
+ out[jj][0] = mapScreenWidth;
+ } else if ((tmp[0] < 1)
+ && (out[jj][0] > (mapScreenWidth * 0.9))) {
+ out[jj][0] = 0;
+ }
+ }
+
+ }
+
+ if (out.length > 0) {
+ return out;
+ } else {
+ return null;
+ }
+ }
+
+ private double[][] toScreenRightOfZero(Coordinate[] coords,
+ MathTransform xform, int minX, int minY) {
+ // Coordinate[] out = new Coordinate[coords.length];
+ double[][] out = new double[coords.length][3];
+
+ for (int i = 0; i < coords.length; i++) {
+ double[] tmp = new double[2];
+ tmp[0] = coords[i].x + minX;
+ tmp[1] = coords[i].y + minY;
+
+ try {
+ xform.transform(tmp, 0, out[i], 0, 1);
+ } catch (TransformException e) {
+ // e.printStackTrace();
+ return null;
+ }
+
+ if ((out[i][0] < zeroLonOnScreen)
+ || ((tmp[0] == maxGridX) && (out[i][0] == zeroLonOnScreen))) {
+ out[i][0] += mapScreenWidth;
+
+ }
+ }
+
+ if (out.length > 0) {
+ return out;
+ } else {
+ return null;
+ }
+ }
+
+ private LineString toScreenLSRightOfZero(Coordinate[] coords,
+ MathTransform xform, int minX, int minY) {
+ GeometryFactory gf = new GeometryFactory();
+ Coordinate[] out = new Coordinate[coords.length];
+ double[] tmpout = new double[3];
+
+ for (int i = 0; i < coords.length; i++) {
+ double[] tmp = new double[2];
+ tmp[0] = coords[i].x + minX;
+ tmp[1] = coords[i].y + minY;
+
+ try {
+ xform.transform(tmp, 0, tmpout, 0, 1);
+ } catch (TransformException e) {
+ // e.printStackTrace();
+ return null;
+ }
+
+ if ((tmpout[0] < zeroLonOnScreen)
+ || ((tmp[0] == maxGridX) && (tmpout[0] == zeroLonOnScreen))) {
+ tmpout[0] += mapScreenWidth;
+ }
+
+ out[i] = new Coordinate(tmpout[0], tmpout[1]);
+
+ }
+
+ if (out.length >= 2) {
+ return gf.createLineString(out);
+ } else {
+ return null;
+ }
+ }
+
+ private double[][] toScreenLeftOfZero(Coordinate[] coords,
+ MathTransform xform, int minX, int minY) {
+ // Coordinate[] out = new Coordinate[coords.length];
+ double[][] out = new double[coords.length][3];
+
+ for (int i = 0; i < coords.length; i++) {
+ double[] tmp = new double[2];
+ tmp[0] = coords[i].x + minX;
+ tmp[1] = coords[i].y + minY;
+
+ try {
+ xform.transform(tmp, 0, out[i], 0, 1);
+ } catch (TransformException e) {
+ // e.printStackTrace();
+ return null;
+ }
+
+ // System.out.println("WWWWWWW " + tmp[0]+" " + tmpout[0] +
+ // " " + out[i][0]);
+
+ if ((out[i][0] > zeroLonOnScreen)
+ || ((tmp[0] == 0) && (out[i][0] == zeroLonOnScreen))) {
+ // System.out.println("Shift " + tmp[0]+" " + out[i][0]);
+ out[i][0] -= mapScreenWidth;
+ }
+
+ }
+
+ if (out.length > 0) {
+ return out;
+ } else {
+ return null;
+ }
+ }
+
+ private LineString toScreenLSLeftOfZero(Coordinate[] coords,
+ MathTransform xform, int minX, int minY) {
+ GeometryFactory gf = new GeometryFactory();
+ Coordinate[] out = new Coordinate[coords.length];
+ double[] tmpout = new double[3];
+
+ for (int i = 0; i < coords.length; i++) {
+ double[] tmp = new double[2];
+ tmp[0] = coords[i].x + minX;
+ tmp[1] = coords[i].y + minY;
+
+ try {
+ xform.transform(tmp, 0, tmpout, 0, 1);
+ } catch (TransformException e) {
+ // e.printStackTrace();
+ return null;
+ }
+
+ if ((tmpout[0] > zeroLonOnScreen)
+ || ((tmp[0] == 0) && (tmpout[0] == zeroLonOnScreen))) {
+ tmpout[0] -= mapScreenWidth;
+ }
+
+ out[i] = new Coordinate(tmpout[0], tmpout[1]);
+
+ }
+
+ if (out.length >= 2) {
+ return gf.createLineString(out);
+ } else {
+ return null;
+ }
+ }
+
+ private LineString toScreenLS(Coordinate[] coords, MathTransform xform,
+ int minX, int minY) {
+
+ GeometryFactory gf = new GeometryFactory();
+ long nx = records.getSizes()[0] - 1;
+
+ int size = coords.length;
+ // remove points on 360. to avoid long cross lines
+ if (isWorld180) {
+ for (Coordinate pt : coords) {
+ if (pt.x == maxGridX) {
+ size--;
+ }
+ }
+ }
+
Coordinate[] out = new Coordinate[size];
double[] tmpout = new double[3];
- for ( int i=0, jj = 0; i< coords.length; i++, jj++ ) {
- if ( isWorld180 && coords[i].x == maxGridX ){ jj--; continue;}
-
- double[] tmp = new double[2];
- tmp[0]=coords[i].x + minX;
- tmp[1]=coords[i].y + minY;
- // if (tmp[0] > 180) tmp[0] -= 360;
-
- try {
- xform.transform(tmp, 0, tmpout, 0, 1);
- } catch (TransformException e) {
- // TODO Auto-generated catch block
- // e.printStackTrace();
- return null;
- }
- if ( worldWrapChecker ) {
- if ( tmp[0] > (nx-1) && tmpout[0] < 0){
- tmpout[0] = extent.getMaxX();
- }
- else if (tmp[0] < 1 && tmpout[0] > extent.getMaxX()*0.9 ){
- tmpout[0] = 0;
- }
+ for (int i = 0, jj = 0; i < coords.length; i++, jj++) {
+ if (isWorld180 && (coords[i].x == maxGridX)) {
+ jj--;
+ continue;
}
-
- out[jj] = new Coordinate( tmpout[0], tmpout[1] );
+ double[] tmp = new double[2];
+ tmp[0] = coords[i].x + minX;
+ tmp[1] = coords[i].y + minY;
+ // if (tmp[0] > 180) tmp[0] -= 360;
+
+ try {
+ xform.transform(tmp, 0, tmpout, 0, 1);
+ } catch (TransformException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ return null;
+ }
+ if (worldWrap) {
+ if ((tmp[0] > (nx - 1)) && (tmpout[0] < 0)) {
+ tmpout[0] = extent.getMaxX();
+ } else if ((tmp[0] < 1)
+ && (tmpout[0] > (extent.getMaxX() * 0.9))) {
+ tmpout[0] = 0;
+ }
+ }
+
+ out[jj] = new Coordinate(tmpout[0], tmpout[1]);
}
- if ( out.length >= 2 ) {
- return gf.createLineString(out);
- }
- else {
- return null;
+ if (out.length >= 2) {
+ return gf.createLineString(out);
+ } else {
+ return null;
}
}
private static Geometry polyToLine(Polygon poly) {
- GeometryFactory gf = new GeometryFactory();
+ GeometryFactory gf = new GeometryFactory();
- if ( poly.getNumInteriorRing() == 0 ) return poly;
+ if (poly.getNumInteriorRing() == 0) {
+ return poly;
+ }
- poly.normalize();
- LineString outerPoly = poly.getExteriorRing();
+ poly.normalize();
+ LineString outerPoly = poly.getExteriorRing();
- /*
- * sort interior rings
- */
- TreeMap orderedHoles = new TreeMap();
- for ( int i=0; i < poly.getNumInteriorRing(); i++ ) {
- LineString hole = poly.getInteriorRingN(i);
- //if ( hole.getArea() == 8.0 ) System.out.println("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFound");
- Coordinate min = CoordinateArrays.minCoordinate( hole.getCoordinates() );
- orderedHoles.put( min, hole);
- }
+ /*
+ * sort interior rings
+ */
+ TreeMap orderedHoles = new TreeMap();
+ for (int i = 0; i < poly.getNumInteriorRing(); i++) {
+ LineString hole = poly.getInteriorRingN(i);
+ // if ( hole.getArea() == 8.0 )
+ // System.out.println("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFound");
+ Coordinate min = CoordinateArrays.minCoordinate(hole
+ .getCoordinates());
+ orderedHoles.put(min, hole);
+ }
- for ( Coordinate leftmost : orderedHoles.keySet() ) {
- CoordinateList clist = new CoordinateList();
- LineString hole = orderedHoles.get(leftmost);
- //Coordinate[] connector = DistanceOp.closestPoints( outerPoly, hole);
+ for (Coordinate leftmost : orderedHoles.keySet()) {
+ CoordinateList clist = new CoordinateList();
+ LineString hole = orderedHoles.get(leftmost);
+ // Coordinate[] connector = DistanceOp.closestPoints( outerPoly,
+ // hole);
- Coordinate testCoord = new Coordinate( 0, leftmost.y);
- // LineString testSegment = gf.createLineString( new Coordinate[] { leftmost, testCoord } );
- LineSegment testSegment = new LineSegment( leftmost, testCoord);
+ Coordinate testCoord = new Coordinate(0, leftmost.y);
+ // LineString testSegment = gf.createLineString( new Coordinate[] {
+ // leftmost, testCoord } );
+ LineSegment testSegment = new LineSegment(leftmost, testCoord);
- Coordinate max = findSegments(outerPoly, leftmost.y, testSegment);
- // System.out.println("MAX INTX = "+max);
- Coordinate[] connector = new Coordinate[] { max, leftmost };
+ Coordinate max = findSegments(outerPoly, leftmost.y, testSegment);
+ // System.out.println("MAX INTX = "+max);
+ Coordinate[] connector = new Coordinate[] { max, leftmost };
- LocationIndexedLine outerLil = new LocationIndexedLine(outerPoly);
- LinearLocation outerLoc= outerLil.indexOf( connector[0] );
- LocationIndexedLine innerLil = new LocationIndexedLine(hole);
- LinearLocation innerLoc= innerLil.indexOf( connector[1] );
+ LocationIndexedLine outerLil = new LocationIndexedLine(outerPoly);
+ LinearLocation outerLoc = outerLil.indexOf(connector[0]);
+ LocationIndexedLine innerLil = new LocationIndexedLine(hole);
+ LinearLocation innerLoc = innerLil.indexOf(connector[1]);
- clist.add( outerLil.extractLine( outerLil.getStartIndex(), outerLoc).getCoordinates(), true );
+ clist.add(outerLil.extractLine(outerLil.getStartIndex(), outerLoc)
+ .getCoordinates(), true);
- clist.add( innerLil.extractLine(innerLoc, innerLil.getEndIndex()).getCoordinates(), true);
- clist.add( innerLil.extractLine( innerLil.getStartIndex(), innerLoc).getCoordinates(), true);
+ clist.add(innerLil.extractLine(innerLoc, innerLil.getEndIndex())
+ .getCoordinates(), true);
+ clist.add(innerLil.extractLine(innerLil.getStartIndex(), innerLoc)
+ .getCoordinates(), true);
- clist.add( outerLil.extractLine( outerLoc, outerLil.getEndIndex() ).getCoordinates(), true );
+ clist.add(outerLil.extractLine(outerLoc, outerLil.getEndIndex())
+ .getCoordinates(), true);
- outerPoly = gf.createLineString(clist.toCoordinateArray());
+ outerPoly = gf.createLineString(clist.toCoordinateArray());
- }
+ }
- return outerPoly;
- //return ls.getSequencedLineStrings();
+ return outerPoly;
+ // return ls.getSequencedLineStrings();
}
- private static Coordinate findSegments(LineString outerPoly, double y, LineSegment seg) {
+ private static Coordinate findSegments(LineString outerPoly, double y,
+ LineSegment seg) {
- //GeometryFactory gf = new GeometryFactory();
- //List geoms = new ArrayList();
- Coordinate max = new Coordinate(0,0);
- //Geometry testGeom;
+ // GeometryFactory gf = new GeometryFactory();
+ // List geoms = new ArrayList();
+ Coordinate max = new Coordinate(0, 0);
+ // Geometry testGeom;
Coordinate[] coords = outerPoly.getCoordinates();
- for ( int i=0; i= coords[i+1].y)) || ((y >= coords[i].y) && (y <= coords[i+1].y)) ) {
- //Geometry temp = gf.createLineString(new Coordinate[] {coords[1], coords[i+1]} );
- LineSegment temp = new LineSegment( coords[i], coords[i+1]);
- intx = seg.intersection(temp);
- }
- //else if ( y == coords[i].y ) {
- // intx = coords[i];
- //}
+ for (int i = 0; i < (coords.length - 1); i++) {
+ Coordinate intx = null;
+ if (((y <= coords[i].y) && (y >= coords[i + 1].y))
+ || ((y >= coords[i].y) && (y <= coords[i + 1].y))) {
+ // Geometry temp = gf.createLineString(new Coordinate[]
+ // {coords[1], coords[i+1]} );
+ LineSegment temp = new LineSegment(coords[i], coords[i + 1]);
+ intx = seg.intersection(temp);
+ }
+ // else if ( y == coords[i].y ) {
+ // intx = coords[i];
+ // }
- if ( intx != null ) {
- if ( max.compareTo( intx ) == -1 ) max = intx;
+ if (intx != null) {
+ if (max.compareTo(intx) == -1) {
+ max = intx;
}
+ }
- // testGeom = seg.intersection(temp);
- // for ( int j=0; j < testGeom.getNumGeometries(); j++ ) {
- // Geometry g = testGeom.getGeometryN(j);
- // if ( max.compareTo( g.getCoordinate() ) == -1 ) max = g.getCoordinate();
- // }
- //}
+ // testGeom = seg.intersection(temp);
+ // for ( int j=0; j < testGeom.getNumGeometries(); j++ ) {
+ // Geometry g = testGeom.getGeometryN(j);
+ // if ( max.compareTo( g.getCoordinate() ) == -1 ) max =
+ // g.getCoordinate();
+ // }
+ // }
}
return max;
}
-
- public static double getCentralMeridian (IMapDescriptor descriptor) {
- MapProjection worldProjection = CRS.getMapProjection(descriptor
+
+ public static double getCentralMeridian(IMapDescriptor descriptor) {
+ MapProjection worldProjection = CRS.getMapProjection(descriptor
.getCRS());
if (worldProjection != null) {
ParameterValueGroup group = worldProjection.getParameterValues();
double centralMeridian = group.parameter(
AbstractProvider.CENTRAL_MERIDIAN.getName().getCode())
.doubleValue();
- if ( centralMeridian > 180 ) centralMeridian -= 360;
+ if (centralMeridian > 180) {
+ centralMeridian -= 360;
+ }
return centralMeridian;
- }
- return -999;
+ }
+ return -999;
}
-
- private static List contourReduce ( List contour1, List contour2){
- List tmp = new ArrayList();
- if ( contour2 != null ) {
- for ( Double d2 : contour2 ) {
- boolean found = false;
- for ( Double d1 : contour1 ) {
- if ( Double.compare(d1, d2) == 0 ) {
- found = true;
- break;
- }
- }
- if ( ! found ) {
- tmp.add(d2);
- }
- }
- }
- return tmp;
+
+ private static List contourReduce(List contour1,
+ List contour2) {
+ List tmp = new ArrayList();
+ if (contour2 != null) {
+ for (Double d2 : contour2) {
+ boolean found = false;
+ for (Double d1 : contour1) {
+ if (Double.compare(d1, d2) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ tmp.add(d2);
+ }
+ }
+ }
+ return tmp;
}
-
- private void initContourGroup (IGraphicsTarget target,
- ContourGroup contourGp) {
- contourGroup = new ContourGroup();
+
+ private void initContourGroup(IGraphicsTarget target, ContourGroup contourGp) {
+ contourGroup = new ContourGroup();
contourGroup.lastDensity = currentDensity;
contourGroup.posValueShape = target.createWireframeShape(false,
descriptor);
contourGroup.negValueShape = target.createWireframeShape(false,
descriptor);
- contourGroup.fillShapes = target.createShadedShape(false, descriptor, true);
+ contourGroup.fillShapes = target.createShadedShape(false, descriptor,
+ true);
contourGroup.zoomLevel = 1.0 / Math.pow(2.0, level);
-
+
contourGroup.cvalues = new ArrayList();
-
+
contourGroup.fvalues = new ArrayList();
-
- contourGroup.data = new HashMap< String, Geometry>();
-
+
+ contourGroup.data = new HashMap();
+
contourGroup.grid = null;
-
- if ( contourGp != null ) {
- if ( contourGp.cvalues != null && contourGp.cvalues.size() > 0 ) {
- contourGroup.cvalues.addAll(contourGp.cvalues);
- }
- if ( contourGp.fvalues != null && contourGp.fvalues.size() > 0 ) {
- contourGroup.fvalues.addAll(contourGp.fvalues);
- }
- if ( contourGp.data != null && contourGp.data.size() > 0 ) {
- contourGroup.data.putAll(contourGp.data);
- }
- if ( contourGp.grid != null )
- contourGroup.grid = contourGp.grid;
+
+ if (contourGp != null) {
+ if ((contourGp.cvalues != null) && (contourGp.cvalues.size() > 0)) {
+ contourGroup.cvalues.addAll(contourGp.cvalues);
+ }
+ if ((contourGp.fvalues != null) && (contourGp.fvalues.size() > 0)) {
+ contourGroup.fvalues.addAll(contourGp.fvalues);
+ }
+ if ((contourGp.data != null) && (contourGp.data.size() > 0)) {
+ contourGroup.data.putAll(contourGp.data);
+ }
+ if (contourGp.grid != null) {
+ contourGroup.grid = contourGp.grid;
+ }
}
-
+
contourGroup.lastUsedPixelExtent = (PixelExtent) extent.clone();
contourGroup.lastUsedPixelExtent.getEnvelope().expandBy(
contourGroup.lastUsedPixelExtent.getWidth() * .25,
contourGroup.lastUsedPixelExtent.getHeight() * .25);
}
-
- private boolean initMathTransform ( GeneralGridGeometry imageGridGeometry,
+
+ private boolean initMathTransform(GeneralGridGeometry imageGridGeometry,
GeneralGridGeometry mapGridGeometry) {
try {
- DefaultMathTransformFactory factory = new DefaultMathTransformFactory();
+ DefaultMathTransformFactory factory = new DefaultMathTransformFactory();
CoordinateReferenceSystem rastCrs = imageGridGeometry
.getCoordinateReferenceSystem();
CoordinateReferenceSystem mapCrs = mapGridGeometry
.getCoordinateReferenceSystem();
-
+
MathTransform rastGridToCrs = imageGridGeometry
.getGridToCRS(PixelInCell.CELL_CENTER);
MathTransform mapCrsToGrid = mapGridGeometry.getGridToCRS(
@@ -904,382 +964,445 @@ public class ContourSupport {
.getTransformToLatLon(rastCrs);
MathTransform rastCrsToWorldGrid = MapUtil
- .getTransformFromLatLon(mapCrs);
+ .getTransformFromLatLon(mapCrs);
MathTransform crs2crs = CRSCache.getInstance().findMathTransform(
rastCrs, mapCrs);
- rastPosToWorldGrid = factory
- .createConcatenatedTransform(
- factory.createConcatenatedTransform(rastGridToCrs,
- crs2crs), mapCrsToGrid);
-
+ rastPosToWorldGrid = factory
+ .createConcatenatedTransform(
+ factory.createConcatenatedTransform(rastGridToCrs,
+ crs2crs), mapCrsToGrid);
+
rastPosToLatLon = factory.createConcatenatedTransform(
rastGridToCrs, rastCrsToLatLon);
rastPosLatLonToWorldGrid = factory.createConcatenatedTransform(
- rastCrsToWorldGrid,mapCrsToGrid);
+ rastCrsToWorldGrid, mapCrsToGrid);
} catch (Exception e) {
-// throw new VizException("Error building Transforms", e);
+ // throw new VizException("Error building Transforms", e);
logger.error("Error building Transforms:" + e);
return false;
}
return true;
}
-
- private void initZoomIndex () {
- zoomLevelIndex = level+1;//(int)(zoom / 2) + 1; // To be adjusted
- if (zoomLevelIndex < 1) zoomLevelIndex = 1;
- int maxZoomLevel = 5;
- String cint = attr.getCint();
- if (cint != null) maxZoomLevel = cint.trim().split(">").length;
- if (zoomLevelIndex > maxZoomLevel ) zoomLevelIndex = maxZoomLevel;
- }
-
- private List calcCintValue () {
- List cvalues = null;
- if (type.trim().toUpperCase().contains("C")) {
- cvalues =CINT.parseCINT(cint, zoomLevelIndex, cntrData.getMinValue(), cntrData.getMaxValue());
- }
-// if ( cvalues != null ) {
-// System.out.println ("******after CINT.parseCINT("+cint+").cvalues:"+ cvalues.toString());
-// System.out.println ("******cgen.getMinValue():" + cgen.getMinValue() + " cgen.getMaxValue():"+cgen.getMaxValue());
-// }
- if ( contourGroup.cvalues.size() == 0 && cvalues != null ) {
- contourGroup.cvalues.addAll(cvalues);
- }
- else if (contourGroup.cvalues.size() > 0 ) {
- if ( cvalues != null ) {
- List tmp = new ArrayList(cvalues);
- cvalues = contourReduce (contourGroup.cvalues, cvalues);
- contourGroup.cvalues.clear();
- contourGroup.cvalues.addAll(tmp);
- }
- else {
- contourGroup.cvalues.clear();
- }
- }
- return cvalues;
- }
-
- private List calcFintValue () {
- List fvalues = null;
- if (type.trim().toUpperCase().contains("F")) {
- if ( !(fint.equalsIgnoreCase(cint)) ) {
- fvalues = FINT.parseFINT(fint, zoomLevelIndex, cntrData.minValue, cntrData.getMaxValue());
- }
- else if ( contourGroup.cvalues != null ){
- fvalues = contourGroup.cvalues;
- }
- }
- if ( contourGroup.fvalues.size() == 0 && fvalues != null){
- contourGroup.fvalues.addAll(fvalues);
- }
- else if ( contourGroup.fvalues.size() > 0 ) {
- if ( fvalues != null ){
- List tmp = new ArrayList(fvalues);
- fvalues = contourReduce (contourGroup.fvalues, fvalues);
- contourGroup.fvalues.clear();
- contourGroup.fvalues.addAll(tmp);
- }
- else {
- contourGroup.fvalues.clear();
- }
- }
- return fvalues;
- }
-
- private void combineCintAndFillValues () {
- if (cvalues != null && cvalues.size() > 0) svalues = new HashSet(cvalues);
- if (fvalues != null && fvalues.size() > 0) {
- if (svalues == null)
- svalues = new HashSet(fvalues);
- else
- svalues.addAll(fvalues);
- }
- }
-
- private void createContourLines () {
-
- long total_labeling_time = 0;
- long t2 = System.currentTimeMillis();
- if (type.trim().toUpperCase().contains("C") && contourGroup.cvalues.size() > 0) {
- int labelFreq = 1;
- String[] tempLineStrs = attr.getLine().split("/");
- List labelValues = null;
- if (tempLineStrs.length >= 4) {
- if (tempLineStrs[3].trim().contains(";")) {
- LineDataStringParser lineAttr = new LineDataStringParser(attr.getLine());
- labelValues = lineAttr.getInstanceOfLineBuilder().getLineLabelPresentList();
- }
- else {
- labelFreq = Math.abs(Integer.parseInt(tempLineStrs[3].trim()));
- }
- }
-
-
- int n = 0,minX=0,minY=0;
-
- double[][] screen = null;
- double[][] screenx = null;
-
- for ( Double cval : contourGroup.cvalues ) {
- float fval = (float) (cval * 1.0f);
- boolean toLabel = false;
-
- // Label frequency
- if (labelValues != null) {
- for(Integer value : labelValues) {
- if (value == Math.rint(fval)) {
- toLabel = true;
- break;
- }
- }
- }
- else {
- if (labelFreq == 0)
- toLabel = false;
- else
- toLabel = (n % labelFreq == 0) ? true : false;
- }
-
-
- Geometry g = contourGroup.data.get(cval.toString());
- if ( g == null ) continue;
-
- for ( int i=0; i < g.getNumGeometries(); i++ ) {
- Geometry gn = g.getGeometryN(i);
- if ( worldWrap ) {
- // screen = toScreenRightPart( gn.getCoordinates(), 0, rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY );
- // if ( screen != null ) contourGroup.negValueShape.addLineSegment(screen);
-
- screen = toScreenRightOfZero( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
- if ( screen != null ) contourGroup.negValueShape.addLineSegment(screen);
- screenx = toScreenLeftOfZero( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
- if ( screenx != null ) contourGroup.negValueShape.addLineSegment(screenx);
- }
- else {
- screen = toScreen( gn.getCoordinates(), rastPosToWorldGrid, minX, minY );
- if ( screen != null ) contourGroup.negValueShape.addLineSegment(screen);
- }
-
- /* if ( isWorld0 ) {
- screen1 = toScreenSubtract360( gn.getCoordinates(), rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY );
- if ( screen1 != null )
- contourGroup.negValueShape.addLineSegment(screen1);
- }
-
- */
- if (toLabel) {
- long tl0 = System.currentTimeMillis();
-// prepareLabel(contourGroup, zoom, fval,
-// labelPoints, screen);
- if ( screen != null )
- createContourLabel(extent, contourGroup, fval, screen);
- if ( screenx != null) {
- createContourLabel(extent, contourGroup, fval, screenx);
- }
- long tl1 = System.currentTimeMillis();
- total_labeling_time += (tl1-tl0);
- }
- }
-
- n++;
- }
- }
- long t3 = System.currentTimeMillis();
- logger.debug("===Creating label wireframes for ("+name+") took: " + total_labeling_time);
- if ( ncgribLogger.enableCntrLogs() )
- logger.info("===Creating contour line wireframes for ("+name+")took: " + (t3 - t2 ));
-// System.out.println("Creating contour line wireframes took: " + (t3 - t2 - total_labeling_time));
+ private void initZoomIndex() {
+ zoomLevelIndex = level + 1;// (int)(zoom / 2) + 1; // To be adjusted
+ if (zoomLevelIndex < 1) {
+ zoomLevelIndex = 1;
+ }
+ int maxZoomLevel = 5;
+ String cint = attr.getCint();
+ if (cint != null) {
+ maxZoomLevel = cint.trim().split(">").length;
+ }
+ if (zoomLevelIndex > maxZoomLevel) {
+ zoomLevelIndex = maxZoomLevel;
+ }
}
-
- private void createColorFills () {
-
- long t3 = System.currentTimeMillis();
-
- //Prepare the colorbar
- if (type.trim().toUpperCase().contains("F") && (attr.getClrbar() != null || !"0".equals(attr.getClrbar()))){
- ColorBar tempColorBar = generateColorBarInfo();
- if( tempColorBar != null ){
- contourGroup.colorBarForGriddedFill = new ColorBar(tempColorBar);
- }
- } else {
- contourGroup.colorBarForGriddedFill = null;
- }
-
- if (type.trim().toUpperCase().contains("F") && contourGroup.fvalues.size() > 0) {
-
- try {
-
- // Prepare colors for color fills
- List fillColorsIndex = new ArrayList();
- if (fline == null || fline.trim().length() < 1) {
- for(int i = 0; i < contourGroup.fvalues.size()+2; i++) {
- if (i <= 30)
- fillColorsIndex.add(i + 1);
- else
- fillColorsIndex.add(30);
- }
- } else {
- FLine flineInfo = new FLine(fline.trim());
- fillColorsIndex = flineInfo.getFillColorList();
-
- /*
- * Apply last color if not enough input color.
- */
- if (contourGroup.fvalues != null && fillColorsIndex.size() < (contourGroup.fvalues.size()+1)) {
- for (int i = fillColorsIndex.size(); i < contourGroup.fvalues.size()+2; i++) {
- fillColorsIndex.add(i);
- }
- }
- }
- int minX=0,minY=0;
- long t11 = System.currentTimeMillis();
- FillGenerator fgen = new FillGenerator(contourGroup.grid);
- long t12 = System.currentTimeMillis();
- logger.debug(" create FillGenerator took:" + (t12-t11));
- for ( Double cval : contourGroup.fvalues ) {
- float fval = (float) (cval * 1.0f);
- Geometry g = contourGroup.data.get(cval.toString());
- if ( g == null ) continue;
- fgen.addContours(fval, g);
- }
- t11 = System.currentTimeMillis();
- logger.debug(" add Contour took:" + (t11-t12));
- // Add color fill to contourGroup
- for (int n=0; n <= contourGroup.fvalues.size(); n++ ) {
- if (fillColorsIndex.get(n) <= 0 || fillColorsIndex.get(n) >= 32) continue;
-
- RGB color = GempakColor.convertToRGB(fillColorsIndex.get(n));
- Geometry fillPolys = null;
-
- int index = (n < contourGroup.fvalues.size()) ? n : (n-1);
- float fval = (float)(contourGroup.fvalues.get(index) * 1.0f);
-
- try {
- if (n == 0) {
- fillPolys = fgen.fillLessThan(fval);
- } else if (n == contourGroup.fvalues.size()) {
- fillPolys = fgen.fillGreaterThan(fval);
- } else {
- float fval1 = (float)(contourGroup.fvalues.get(n-1) * 1.0f);
- float fval2 = (float)(contourGroup.fvalues.get(n) * 1.0f);
- fillPolys = fgen.fillBetween( fval1, fval2 );
- }
- for (int j=0; j calcCintValue() {
+ List cvalues = null;
+ if (type.trim().toUpperCase().contains("C")) {
+ cvalues = CINT.parseCINT(cint, zoomLevelIndex,
+ cntrData.getMinValue(), cntrData.getMaxValue());
+ }
+ // if ( cvalues != null ) {
+ // System.out.println ("******after CINT.parseCINT("+cint+").cvalues:"+
+ // cvalues.toString());
+ // System.out.println ("******cgen.getMinValue():" + cgen.getMinValue()
+ // + " cgen.getMaxValue():"+cgen.getMaxValue());
+ // }
+ if ((contourGroup.cvalues.size() == 0) && (cvalues != null)) {
+ contourGroup.cvalues.addAll(cvalues);
+ } else if (contourGroup.cvalues.size() > 0) {
+ if (cvalues != null) {
+ List tmp = new ArrayList(cvalues);
+ cvalues = contourReduce(contourGroup.cvalues, cvalues);
+ contourGroup.cvalues.clear();
+ contourGroup.cvalues.addAll(tmp);
+ } else {
+ contourGroup.cvalues.clear();
+ }
+ }
+ return cvalues;
}
-
- private void createStreamLines () {
- // Step 1: Get the actual data
+
+ private List calcFintValue() {
+ List fvalues = null;
+ if (type.trim().toUpperCase().contains("F")) {
+ if (!(fint.equalsIgnoreCase(cint))) {
+ fvalues = FINT.parseFINT(fint, zoomLevelIndex,
+ cntrData.minValue, cntrData.getMaxValue());
+ } else if (contourGroup.cvalues != null) {
+ fvalues = contourGroup.cvalues;
+ }
+ }
+ if ((contourGroup.fvalues.size() == 0) && (fvalues != null)) {
+ contourGroup.fvalues.addAll(fvalues);
+ } else if (contourGroup.fvalues.size() > 0) {
+ if (fvalues != null) {
+ List tmp = new ArrayList(fvalues);
+ fvalues = contourReduce(contourGroup.fvalues, fvalues);
+ contourGroup.fvalues.clear();
+ contourGroup.fvalues.addAll(tmp);
+ } else {
+ contourGroup.fvalues.clear();
+ }
+ }
+ return fvalues;
+ }
+
+ private void combineCintAndFillValues() {
+ if ((cvalues != null) && (cvalues.size() > 0)) {
+ svalues = new HashSet(cvalues);
+ }
+ if ((fvalues != null) && (fvalues.size() > 0)) {
+ if (svalues == null) {
+ svalues = new HashSet(fvalues);
+ } else {
+ svalues.addAll(fvalues);
+ }
+ }
+ }
+
+ private void createContourLines() {
+
+ long total_labeling_time = 0;
+ long t2 = System.currentTimeMillis();
+ if (type.trim().toUpperCase().contains("C")
+ && (contourGroup.cvalues.size() > 0)) {
+ int labelFreq = 1;
+ String[] tempLineStrs = attr.getLine().split("/");
+ List labelValues = null;
+ if (tempLineStrs.length >= 4) {
+ if (tempLineStrs[3].trim().contains(";")) {
+ LineDataStringParser lineAttr = new LineDataStringParser(
+ attr.getLine());
+ labelValues = lineAttr.getInstanceOfLineBuilder()
+ .getLineLabelPresentList();
+ } else {
+ labelFreq = Math.abs(Integer.parseInt(tempLineStrs[3]
+ .trim()));
+ }
+ }
+
+ int n = 0, minX = 0, minY = 0;
+
+ double[][] screen = null;
+ double[][] screenx = null;
+
+ for (Double cval : contourGroup.cvalues) {
+ float fval = (float) (cval * 1.0f);
+ boolean toLabel = false;
+
+ // Label frequency
+ if (labelValues != null) {
+ for (Integer value : labelValues) {
+ if (value == Math.rint(fval)) {
+ toLabel = true;
+ break;
+ }
+ }
+ } else {
+ if (labelFreq == 0) {
+ toLabel = false;
+ } else {
+ toLabel = ((n % labelFreq) == 0) ? true : false;
+ }
+ }
+
+ Geometry g = contourGroup.data.get(cval.toString());
+ if (g == null) {
+ continue;
+ }
+
+ for (int i = 0; i < g.getNumGeometries(); i++) {
+ Geometry gn = g.getGeometryN(i);
+ if (worldWrap) {
+ // screen = toScreenRightPart( gn.getCoordinates(), 0,
+ // rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY
+ // );
+ // if ( screen != null )
+ // contourGroup.negValueShape.addLineSegment(screen);
+
+ screen = toScreenRightOfZero(gn.getCoordinates(),
+ rastPosToWorldGrid, minX, minY);
+ if (screen != null) {
+ contourGroup.negValueShape.addLineSegment(screen);
+ }
+
+ screenx = toScreenLeftOfZero(gn.getCoordinates(),
+ rastPosToWorldGrid, minX, minY);
+ if (screenx != null) {
+ contourGroup.negValueShape.addLineSegment(screenx);
+ }
+ } else {
+ screen = toScreen(gn.getCoordinates(),
+ rastPosToWorldGrid, minX, minY);
+ if (screen != null) {
+ contourGroup.negValueShape.addLineSegment(screen);
+ }
+ }
+
+ /*
+ * if ( isWorld0 ) { screen1 = toScreenSubtract360(
+ * gn.getCoordinates(),
+ * rastPosToLatLon,rastPosLatLonToWorldGrid, minX, minY );
+ * if ( screen1 != null )
+ * contourGroup.negValueShape.addLineSegment(screen1); }
+ */
+ if (toLabel) {
+ long tl0 = System.currentTimeMillis();
+ // prepareLabel(contourGroup, zoom, fval,
+ // labelPoints, screen);
+ if (screen != null) {
+ createContourLabel(extent, contourGroup, fval,
+ screen);
+ }
+ if (screenx != null) {
+ createContourLabel(extent, contourGroup, fval,
+ screenx);
+ }
+ long tl1 = System.currentTimeMillis();
+ total_labeling_time += (tl1 - tl0);
+ }
+ }
+
+ n++;
+ }
+ }
+ long t3 = System.currentTimeMillis();
+ logger.debug("===Creating label wireframes for (" + name + ") took: "
+ + total_labeling_time);
+ if (ncgribLogger.enableCntrLogs()) {
+ logger.info("===Creating contour line wireframes for (" + name
+ + ")took: " + (t3 - t2));
+ // System.out.println("Creating contour line wireframes took: " +
+ // (t3 -
+ // t2 - total_labeling_time));
+ }
+ }
+
+ private void createColorFills() {
+
+ long t3 = System.currentTimeMillis();
+
+ // Prepare the colorbar
+ if (type.trim().toUpperCase().contains("F")
+ && ((attr.getClrbar() != null) || !"0".equals(attr.getClrbar()))) {
+ ColorBar tempColorBar = generateColorBarInfo();
+ if (tempColorBar != null) {
+ contourGroup.colorBarForGriddedFill = new ColorBar(tempColorBar);
+ }
+ } else {
+ contourGroup.colorBarForGriddedFill = null;
+ }
+
+ if (type.trim().toUpperCase().contains("F")
+ && (contourGroup.fvalues.size() > 0)) {
+
+ try {
+
+ // Prepare colors for color fills
+ List fillColorsIndex = new ArrayList();
+ if ((fline == null) || (fline.trim().length() < 1)) {
+ for (int i = 0; i < (contourGroup.fvalues.size() + 2); i++) {
+ if (i <= 30) {
+ fillColorsIndex.add(i + 1);
+ } else {
+ fillColorsIndex.add(30);
+ }
+ }
+ } else {
+ FLine flineInfo = new FLine(fline.trim());
+ fillColorsIndex = flineInfo.getFillColorList();
+
+ /*
+ * Apply last color if not enough input color.
+ */
+ if ((contourGroup.fvalues != null)
+ && (fillColorsIndex.size() < (contourGroup.fvalues
+ .size() + 1))) {
+ for (int i = fillColorsIndex.size(); i < (contourGroup.fvalues
+ .size() + 2); i++) {
+ fillColorsIndex.add(i);
+ }
+ }
+ }
+
+ int minX = 0, minY = 0;
+ long t11 = System.currentTimeMillis();
+ FillGenerator fgen = new FillGenerator(contourGroup.grid);
+ long t12 = System.currentTimeMillis();
+ logger.debug(" create FillGenerator took:" + (t12 - t11));
+ for (Double cval : contourGroup.fvalues) {
+ float fval = (float) (cval * 1.0f);
+ Geometry g = contourGroup.data.get(cval.toString());
+ if (g == null) {
+ continue;
+ }
+ fgen.addContours(fval, g);
+ }
+ t11 = System.currentTimeMillis();
+ logger.debug(" add Contour took:" + (t11 - t12));
+ // Add color fill to contourGroup
+ for (int n = 0; n <= contourGroup.fvalues.size(); n++) {
+ if ((fillColorsIndex.get(n) <= 0)
+ || (fillColorsIndex.get(n) >= 32)) {
+ continue;
+ }
+
+ RGB color = GempakColor
+ .convertToRGB(fillColorsIndex.get(n));
+ Geometry fillPolys = null;
+
+ int index = (n < contourGroup.fvalues.size()) ? n : (n - 1);
+ float fval = (float) (contourGroup.fvalues.get(index) * 1.0f);
+
+ try {
+ if (n == 0) {
+ fillPolys = fgen.fillLessThan(fval);
+ } else if (n == contourGroup.fvalues.size()) {
+ fillPolys = fgen.fillGreaterThan(fval);
+ } else {
+ float fval1 = (float) (contourGroup.fvalues
+ .get(n - 1) * 1.0f);
+ float fval2 = (float) (contourGroup.fvalues.get(n) * 1.0f);
+ fillPolys = fgen.fillBetween(fval1, fval2);
+ }
+ for (int j = 0; j < fillPolys.getNumGeometries(); j++) {
+ Geometry g = fillPolys.getGeometryN(j);
+ if (g instanceof Polygon) {
+ g = polyToLine((Polygon) g);
+ }
+
+ if (worldWrap) {
+ LineString ls = toScreenLSRightOfZero(
+ g.getCoordinates(), rastPosToWorldGrid,
+ minX, minY);
+ if (ls != null) {
+ contourGroup.fillShapes
+ .addPolygonPixelSpace(
+ new LineString[] { ls },
+ color);
+ }
+ ls = toScreenLSLeftOfZero(g.getCoordinates(),
+ rastPosToWorldGrid, minX, minY);
+ if (ls != null) {
+ contourGroup.fillShapes
+ .addPolygonPixelSpace(
+ new LineString[] { ls },
+ color);
+ }
+ } else {
+ LineString ls = toScreenLS(g.getCoordinates(),
+ rastPosToWorldGrid, minX, minY);
+ if (ls != null) {
+ contourGroup.fillShapes
+ .addPolygonPixelSpace(
+ new LineString[] { ls },
+ color);
+ }
+ }
+
+ // if ( isWorld0 ) {
+ // ls = toScreenLSSubtract360( g.getCoordinates(),
+ // rastPosToLatLon,rastPosLatLonToWorldGrid, minX,
+ // minY);
+ // if ( ls != null )
+ // contourGroup.fillShapes.addPolygonPixelSpace(new
+ // LineString[]{ls}, color);
+ // }
+ }
+ } catch (FillException e) {
+ // e.printStackTrace();
+ }
+ }
+ t12 = System.currentTimeMillis();
+ logger.debug(" loop fvalues took:" + (t12 - t11));
+ // System.out.println("Creating color fills took : " + (t4-t3));
+
+ } catch (Exception e) {
+ logger.debug("Could not create FILL Polygons.");
+ // e.printStackTrace();
+ return;
+ }
+ }
+ long t4 = System.currentTimeMillis();
+ if (ncgribLogger.enableCntrLogs()) {
+ logger.info("===Creating color fills for (" + name + ") took : "
+ + (t4 - t3));
+ }
+ }
+
+ private void createStreamLines() {
+ // Step 1: Get the actual data
float[] uW = null;
float[] vW = null;
long[] sz = records.getSizes();
-
-// Step 2: Determine the subgrid, if any
- int minX=0,minY=0;
- int maxX = (int)sz[0] - 1;
- int maxY = (int)sz[1] - 1;
+
+ // Step 2: Determine the subgrid, if any
+ int minX = 0, minY = 0;
+ int maxX = (int) sz[0] - 1;
+ int maxY = (int) sz[1] - 1;
int szX = (maxX - minX) + 1;
int szY = (maxY - minY) + 1;
int x = (int) sz[0];
-
+
uW = ((NcFloatDataRecord) records).getXdata();
vW = ((NcFloatDataRecord) records).getYdata();
-
- if ( globalData ){ // remove column 360
- x--;
- szX--;
- maxX--;
+
+ if (globalData) { // remove column 360
+ x--;
+ szX--;
+ maxX--;
}
-
+
int totalSz = szX * szY;
if (totalSz <= 0) {
- isCntrsCreated = false;
- return ;
+ isCntrsCreated = false;
+ return;
}
-
+
float[][] adjustedUw = new float[szX][szY];
float[][] adjustedVw = new float[szX][szY];
- if ( globalData ){
- for (int j = 0; j < szY; j++) {
- for (int i = 0; i < szX+1; i++) {
- if (( i+minX )== 360 ) {
- continue;
- }
+ if (globalData) {
+ for (int j = 0; j < szY; j++) {
+ for (int i = 0; i < (szX + 1); i++) {
+ if ((i + minX) == 360) {
+ continue;
+ }
adjustedUw[szX - i - 1][j] = uW[((x + 1) * (j + minY))
+ (i + minX)];
adjustedVw[szX - i - 1][j] = vW[((x + 1) * (j + minY))
+ (i + minX)];
- }
- }
- }
- else {
- for (int j = 0; j < szY; j++) {
- for (int i = 0; i < szX; i++) {
+ }
+ }
+ } else {
+ for (int j = 0; j < szY; j++) {
+ for (int i = 0; i < szX; i++) {
adjustedUw[szX - i - 1][j] = uW[(x * (j + minY))
+ (i + minX)];
adjustedVw[szX - i - 1][j] = vW[(x * (j + minY))
+ (i + minX)];
- }
- }
+ }
+ }
}
- // for ( int kk = 0; kk < 365; kk++ ){
- // System.out.println( kk + " " + adjustedUw[kk]+ " " + uW[kk]);
- // }
-
+ // for ( int kk = 0; kk < 365; kk++ ){
+ // System.out.println( kk + " " + adjustedUw[kk]+ " " + uW[kk]);
+ // }
+
uW = null;
vW = null;
// Use ported legacy code to determine contour interval
-// contourGroup.lastDensity = currentDensity;
-
- double spadiv = 1 * contourGroup.lastDensity * 500 / 25;
-
+ // contourGroup.lastDensity = currentDensity;
+
+ double spadiv = (1 * contourGroup.lastDensity * 500) / 25;
+
double minSpacing = 1.0 / spadiv;
double maxSpacing = 3.0 / spadiv;
@@ -1298,24 +1421,26 @@ public class ContourSupport {
if (maxspc < 0.25) {
maxspc = 0.25f;
}
-
+
/*
* Fix arrow size by M. Li
*/
float arrowSize = (float) (0.4f / Math.sqrt(zoom));
- if (arrowSize > 0.4) arrowSize = 0.4f;
-
+ if (arrowSize > 0.4) {
+ arrowSize = 0.4f;
+ }
+
StrmPakConfig config = new StrmPakConfig(arrowSize, minspc, maxspc,
-1000000f, -999998f);
StreamLineContainer streamLines = StrmPak.strmpak(adjustedUw,
adjustedVw, szX, szX, szY, config);
-
-// long t1 = System.currentTimeMillis();
-// System.out.println("Streamline Contouring took: " + (t1 - t0));
+
+ // long t1 = System.currentTimeMillis();
+ // System.out.println("Streamline Contouring took: " + (t1 - t0));
List vals = new ArrayList();
List pts = new ArrayList();
- double[][] screen, screenx;;
+ double[][] screen, screenx;
long tAccum = 0;
try {
@@ -1324,32 +1449,34 @@ public class ContourSupport {
double[] out = new double[2];
try {
long tZ0 = System.currentTimeMillis();
-
+
float f;
-
+
if (point.getX() >= 360) {
f = 0;
}
-
+
else {
- f = maxX + 1 - point.getX();
+ f = (maxX + 1) - point.getX();
}
-
- if (f > 180) f = f - 360;
-
+
+ if (f > 180) {
+ f = f - 360;
+ }
+
rastPosToWorldGrid.transform(
new double[] { f, point.getY() + minY }, 0,
out, 0, 1);
-
+
pts.add(new Coordinate(f, point.getY() + minY));
-
+
long tZ1 = System.currentTimeMillis();
tAccum += (tZ1 - tZ0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
vals.add(out);
}
if (pts.size() > 0) {
@@ -1358,14 +1485,16 @@ public class ContourSupport {
screen = toScreenRightOfZero(
pts.toArray(new Coordinate[pts.size()]),
rastPosToWorldGrid, minX, minY);
- if (screen != null)
+ if (screen != null) {
contourGroup.posValueShape.addLineSegment(screen);
+ }
screenx = toScreenLeftOfZero(
pts.toArray(new Coordinate[pts.size()]),
rastPosToWorldGrid, minX, minY);
- if (screenx != null)
+ if (screenx != null) {
contourGroup.posValueShape.addLineSegment(screenx);
+ }
} else {
double[][] valsArr = vals.toArray(new double[vals
.size()][2]);
@@ -1379,219 +1508,260 @@ public class ContourSupport {
}
-// System.out.println("streamline transformation time: " + tAccum);
+ // System.out.println("streamline transformation time: " + tAccum);
if (vals.size() > 0) {
- double[][] valsArr = vals
- .toArray(new double[vals.size()][2]);
+ double[][] valsArr = vals.toArray(new double[vals.size()][2]);
contourGroup.posValueShape.addLineSegment(valsArr);
-
- if ( worldWrap ) {
- screen = toScreenRightOfZero( pts.toArray(new Coordinate[pts.size()]), rastPosToWorldGrid, minX, minY );
- if ( screen != null ) contourGroup.posValueShape.addLineSegment(screen);
- screenx = toScreenLeftOfZero( pts.toArray(new Coordinate[pts.size()]),rastPosToWorldGrid, minX, minY );
- if ( screenx != null ) contourGroup.posValueShape.addLineSegment(screenx);
- }
+ if (worldWrap) {
+ screen = toScreenRightOfZero(
+ pts.toArray(new Coordinate[pts.size()]),
+ rastPosToWorldGrid, minX, minY);
+ if (screen != null) {
+ contourGroup.posValueShape.addLineSegment(screen);
+ }
+
+ screenx = toScreenLeftOfZero(
+ pts.toArray(new Coordinate[pts.size()]),
+ rastPosToWorldGrid, minX, minY);
+ if (screenx != null) {
+ contourGroup.posValueShape.addLineSegment(screenx);
+ }
+ }
vals.clear();
}
} catch (Throwable e) {
-// throw new VizException("Error postprocessing contours", e);
+ // throw new VizException("Error postprocessing contours", e);
logger.error("Error postprocessing contours:" + e);
isCntrsCreated = false;
return;
- }
+ }
}
-
-
- private ColorBar generateColorBarInfo(){
-
- if( attr.getClrbar() != null && !attr.getClrbar().isEmpty()){
- contourGroup.clrbar = new CLRBAR(attr.getClrbar());
- ColorBarAttributesBuilder cBarAttrBuilder = contourGroup.clrbar.getcBarAttributesBuilder();
- ColorBar colorBar = new ColorBar();
- if ( cBarAttrBuilder.isDrawColorBar() ){
- colorBar.setAttributesFromColorBarAttributesBuilder(cBarAttrBuilder);
- colorBar.setAttributesFromColorBarAttributesBuilder(cBarAttrBuilder);
- colorBar.setColorDevice( NcDisplayMngr.getActiveNatlCntrsEditor().getActiveDisplayPane().getDisplay() );
- FINT theFillIntervals = new FINT(fint.trim());
- FLine fillColorString = new FLine(fline.trim());
- if( !theFillIntervals.isFINTStringParsed() || !fillColorString.isFLineStringParsed() )
- return null;
- List fillIntvls = theFillIntervals.getUniqueSortedFillValuesFromAllZoomLevels();
- List fillColors = fillColorString.getFillColorList();
-
- fillIntvls.add(0, Double.NEGATIVE_INFINITY);
- int numFillIntervals = fillIntvls.size();
- fillIntvls.add(numFillIntervals, Double.POSITIVE_INFINITY);
- int numDecimals = 0;
- for (int index = 0 ; index <= numFillIntervals -1 ; index++){
- colorBar.addColorBarInterval(fillIntvls.get(index).floatValue(), fillIntvls.get(index + 1).floatValue(), GempakColor.convertToRGB(fillColors.get(index)));
- String tmp[] = fillIntvls.get(index).toString().split("\\.");
- if (tmp.length > 1 && tmp[1].length() > numDecimals && !"0".equals(tmp[1])) {
- numDecimals = tmp[1].length();
- }
- }
- colorBar.setNumDecimals(numDecimals);
- return colorBar;
- }
- }
- return null;
- }
-
- public void genContour () {
-
- ContourCalculationReentrantLock.getReentrantLock();
-// synchronized (ContourSupport.class) {
- List allvalues = new ArrayList(svalues);
- Collections.sort(allvalues);
- long t1a = System.currentTimeMillis();
- ContourGenerator cgen = new ContourGenerator( cntrData.getData(), cntrData.getX(), cntrData.getY());
- long t1b = System.currentTimeMillis();
- logger.debug("Creating contour values took: " + (t1b-t1a));
- cgen.setContourValues( allvalues );
+ private ColorBar generateColorBarInfo() {
- long t1c = System.currentTimeMillis();
- logger.debug("ContourGenerator.setContourValues(allvalues) took: " + (t1c-t1b));
-// System.out.println("ContourGenerator init took:" + (t1c-t0));
-
- try {
- cgen.generateContours();
- } catch (ContourException e1) {
- // TODO Auto-generated catch block
-// e1.printStackTrace();
- cgen.dispose();
- isCntrsCreated = false;
- ContourCalculationReentrantLock.releaseReentrantLock();
- return;
- }
-
-
-
- long t2 = System.currentTimeMillis();
- if ( ncgribLogger.enableCntrLogs() )
- logger.info("===ContourGenerator.generateContours() for ("+name+") took: " + (t2-t1a));
-
-// System.out.println("Contour Computation took: " + (t2-t1c));
-
- logger.debug("Total generating contour line values took: " + (t2-t1a));
- if ( cvalues != null ) {
- for ( Double cval : cvalues ) {
- float fval = (float) (cval * 1.0f);
- contourGroup.data.put(cval.toString(), cgen.getContours(fval));
- }
- }
- if ( fvalues != null ) {
- for ( Double cval : fvalues ) {
- float fval = (float) (cval * 1.0f);
- contourGroup.data.put(cval.toString(), cgen.getContours(fval));
- }
- }
-
- if ( contourGroup.grid == null ) {
- contourGroup.grid = cgen.getEdges();
- }
- cgen.dispose();
- ContourCalculationReentrantLock.releaseReentrantLock();
-// }
+ if ((attr.getClrbar() != null) && !attr.getClrbar().isEmpty()) {
+ contourGroup.clrbar = new CLRBAR(attr.getClrbar());
+ ColorBarAttributesBuilder cBarAttrBuilder = contourGroup.clrbar
+ .getcBarAttributesBuilder();
+ ColorBar colorBar = new ColorBar();
+ if (cBarAttrBuilder.isDrawColorBar()) {
+ colorBar.setAttributesFromColorBarAttributesBuilder(cBarAttrBuilder);
+ colorBar.setAttributesFromColorBarAttributesBuilder(cBarAttrBuilder);
+ colorBar.setColorDevice(NcDisplayMngr
+ .getActiveNatlCntrsEditor().getActiveDisplayPane()
+ .getDisplay());
+ FINT theFillIntervals = new FINT(fint.trim());
+ FLine fillColorString = new FLine(fline.trim());
+ if (!theFillIntervals.isFINTStringParsed()
+ || !fillColorString.isFLineStringParsed()) {
+ return null;
+ }
+ List fillIntvls = theFillIntervals
+ .getUniqueSortedFillValuesFromAllZoomLevels();
+ List fillColors = fillColorString.getFillColorList();
+
+ fillIntvls.add(0, Double.NEGATIVE_INFINITY);
+ int numFillIntervals = fillIntvls.size();
+ fillIntvls.add(numFillIntervals, Double.POSITIVE_INFINITY);
+ int numDecimals = 0;
+ for (int index = 0; index <= (numFillIntervals - 1); index++) {
+ colorBar.addColorBarInterval(fillIntvls.get(index)
+ .floatValue(), fillIntvls.get(index + 1)
+ .floatValue(), GempakColor.convertToRGB(fillColors
+ .get(index)));
+ String tmp[] = fillIntvls.get(index).toString()
+ .split("\\.");
+ if ((tmp.length > 1) && (tmp[1].length() > numDecimals)
+ && !"0".equals(tmp[1])) {
+ numDecimals = tmp[1].length();
+ }
+ }
+ colorBar.setNumDecimals(numDecimals);
+ return colorBar;
+ }
+ }
+ return null;
}
-
+
+ public void genContour() {
+
+ ContourCalculationReentrantLock.getReentrantLock();
+ // synchronized (ContourSupport.class) {
+ List allvalues = new ArrayList(svalues);
+ Collections.sort(allvalues);
+
+ long t1a = System.currentTimeMillis();
+ ContourGenerator cgen = new ContourGenerator(cntrData.getData(),
+ cntrData.getX(), cntrData.getY());
+ long t1b = System.currentTimeMillis();
+ logger.debug("Creating contour values took: " + (t1b - t1a));
+ cgen.setContourValues(allvalues);
+
+ long t1c = System.currentTimeMillis();
+ logger.debug("ContourGenerator.setContourValues(allvalues) took: "
+ + (t1c - t1b));
+ // System.out.println("ContourGenerator init took:" + (t1c-t0));
+
+ try {
+ cgen.generateContours();
+ } catch (ContourException e1) {
+ // TODO Auto-generated catch block
+ // e1.printStackTrace();
+ cgen.dispose();
+ isCntrsCreated = false;
+ ContourCalculationReentrantLock.releaseReentrantLock();
+ return;
+ }
+
+ long t2 = System.currentTimeMillis();
+ if (ncgribLogger.enableCntrLogs()) {
+ logger.info("===ContourGenerator.generateContours() for (" + name
+ + ") took: " + (t2 - t1a));
+ }
+
+ // System.out.println("Contour Computation took: " + (t2-t1c));
+
+ logger.debug("Total generating contour line values took: " + (t2 - t1a));
+ if (cvalues != null) {
+ for (Double cval : cvalues) {
+ float fval = (float) (cval * 1.0f);
+ contourGroup.data.put(cval.toString(), cgen.getContours(fval));
+ }
+ }
+ if (fvalues != null) {
+ for (Double cval : fvalues) {
+ float fval = (float) (cval * 1.0f);
+ contourGroup.data.put(cval.toString(), cgen.getContours(fval));
+ }
+ }
+
+ if (contourGroup.grid == null) {
+ contourGroup.grid = cgen.getEdges();
+ }
+ cgen.dispose();
+ ContourCalculationReentrantLock.releaseReentrantLock();
+ // }
+ }
+
public ContourGroup getContours() {
- if ( ! isCntrsCreated ) return null;
- return contourGroup;
+ if (!isCntrsCreated) {
+ return null;
+ }
+ return contourGroup;
}
-
+
/**
- * If the worldWrapChecker is true and the gird is split by the map border.
+ * If the worldWrapChecker is true and the grid is split by the map border.
+ *
* @param imageGridGeometry
* @param rastPosToLatLon
* @return
*/
- private boolean needWrap(GeneralGridGeometry imageGridGeometry, MathTransform rastPosToLatLon){
- boolean ret = worldWrapChecker;
-
- if ( ret ){
- //minimum, maximum X grid
- int minx = imageGridGeometry.getGridRange().getLow(0);
- int maxx = imageGridGeometry.getGridRange().getHigh(0);
+ private boolean needWrap(GeneralGridGeometry imageGridGeometry,
+ MathTransform rastPosToLatLon) {
+ boolean ret = worldWrapChecker;
- double [] out0 = new double[3];
- double [] out1 = new double[3];
+ if (ret) {
+ // minimum, maximum X grid
+ int minx = imageGridGeometry.getGridRange().getLow(0);
+ int maxx = imageGridGeometry.getGridRange().getHigh(0);
- //minimum, maximum longitudes
- try {
- rastPosToLatLon.transform( new double[]{minx, 0}, 0, out0, 0, 1 );
- rastPosToLatLon.transform( new double[]{maxx, 0}, 0, out1, 0, 1 );
- } catch (TransformException e) {
- // TODO Auto-generated catch block
- //printStackTrace();
- ret = false;
- }
-
-
- double minLon = ( out0[0] >= 0 ) ? out0[0] : out0[0] +360;
- double maxLon = ( out1[0] >= 0 ) ? out1[0] : out1[0] +360;
-
- if ( minLon == 0 && maxLon == 360 ) globalData = true;
-
- if ( maxLon >= 360 ) maxLon = 359;
+ double[] out0 = new double[3];
+ double[] out1 = new double[3];
- double right = centralMeridian + 180;
+ // minimum, maximum longitudes
+ try {
+ rastPosToLatLon.transform(new double[] { minx, 0 }, 0, out0, 0,
+ 1);
+ rastPosToLatLon.transform(new double[] { maxx, 0 }, 0, out1, 0,
+ 1);
+ } catch (TransformException e) {
+ // TODO Auto-generated catch block
+ // printStackTrace();
+ ret = false;
+ }
- if ( maxLon > minLon ){
- ret = (right > minLon) && (right < maxLon );
- }
- else {
- ret = !(right > minLon) && (right < maxLon );
- }
- }
-
- return ret;
+ double minLon = (out0[0] >= 0) ? out0[0] : out0[0] + 360;
+ double maxLon = (out1[0] >= 0) ? out1[0] : out1[0] + 360;
+
+ if ((minLon == 0) && (maxLon == 360)) {
+ globalData = true;
+ }
+
+ if (maxLon >= 360) {
+ maxLon = 359;
+ }
+ double right = centralMeridian + 180;
+
+ if (maxLon > minLon) {
+ ret = (right > minLon) && (right < maxLon);
+
+ } else {
+ ret = !(right > minLon) && (right < maxLon);
+
+ }
+
+ }
+ // ret = false;
+
+ MapProjection worldProjection = CRS.getMapProjection(descriptor
+ .getCRS());
+ try {
+ if (worldProjection.getClass().getCanonicalName()
+ .contains("Lambert")) {
+ ret = false;
+ }
+ } catch (Exception e) {
+ System.out.println(" Can't get projection");
+ }
+ return ret;
}
-
+
/**
* Gets the maximum grid number in x direction
+ *
* @param imageGridGeometry
* @return int - maximum grid number in x direction
*/
- private int getMaxGridX(GeneralGridGeometry imageGridGeometry){
+ private int getMaxGridX(GeneralGridGeometry imageGridGeometry) {
return imageGridGeometry.getGridRange().getHigh(0);
}
-
+
/**
* Gets the map width in screen coordinate.
+ *
* @return
*/
private double getMapWidth() {
- if ( worldWrapChecker ){
- // double right[] = new double[]{centralMeridian + 180, 0};
- // double left[] = new double[]{centralMeridian - 180, 0};
- double right[] = new double[]{-180, 0};
- double left[] = new double[]{0, 0};
-
- double screenLeft[] = new double[2];
- double screenRight[] = new double[2];
+ if (worldWrapChecker) {
+ // double right[] = new double[]{centralMeridian + 180, 0};
+ // double left[] = new double[]{centralMeridian - 180, 0};
+ double right[] = new double[] { -180, 0 };
+ double left[] = new double[] { 0, 0 };
- try {
- double center[] = new double[]{0, 0};
- double out[] = new double[2];
- rastPosLatLonToWorldGrid.transform(center, 0, out, 0, 1);
- zeroLonOnScreen = out[0];
-
- rastPosLatLonToWorldGrid.transform(left, 0, screenLeft, 0, 1);
- rastPosLatLonToWorldGrid.transform(right, 0, screenRight, 0, 1);
-
- return Math.abs(screenRight[0] - screenLeft[0])*2;
- } catch (TransformException e) {
- // TODO Auto-generated catch block
- return 0;
- }
-
- }
- else {
- return 0;
- }
+ double screenLeft[] = new double[2];
+ double screenRight[] = new double[2];
+
+ try {
+ double center[] = new double[] { 0, 0 };
+ double out[] = new double[2];
+ rastPosLatLonToWorldGrid.transform(center, 0, out, 0, 1);
+ zeroLonOnScreen = out[0];
+
+ rastPosLatLonToWorldGrid.transform(left, 0, screenLeft, 0, 1);
+ rastPosLatLonToWorldGrid.transform(right, 0, screenRight, 0, 1);
+
+ return Math.abs(screenRight[0] - screenLeft[0]) * 2;
+ } catch (TransformException e) {
+ // TODO Auto-generated catch block
+ return 0;
+ }
+
+ } else {
+ return 0;
+ }
}
-}
+}
diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/GriddedVectorDisplay.java b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/GriddedVectorDisplay.java
index fb059e86c5..c6f6f772a4 100644
--- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/GriddedVectorDisplay.java
+++ b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/contours/GriddedVectorDisplay.java
@@ -212,7 +212,8 @@ public class GriddedVectorDisplay extends AbstractGriddedDisplay {
int idx = x + y * this.gridDims[0];
// System.out.println("paintImage idx==="+idx+" x=="+ijcoord.x+" y====="+ijcoord.y);
-
+ // System.out.println("INDEX " + idx + " : " + x + "," + y + " : "
+ // + gridDims[0] + "," + gridDims[1]);
if (idx < 0 || idx >= (gridDims[0] * gridDims[1])) {
return;
}
@@ -623,4 +624,93 @@ public class GriddedVectorDisplay extends AbstractGriddedDisplay {
}
return match;
}
+
+ @Override
+ /*
+ * HACK hack hack ... this version of paintImage is being used for global
+ * grids. I don't think the grid <-> latlon transforms are working, so the
+ * index calculation has been modified. This is not a good solution, but was
+ * implemented due to time crunch for 13.5.2
+ */
+ protected void paintGlobalImage(int x, int y, PaintProperties paintProps,
+ double adjSize) throws VizException {
+ int adjx = x - 1;
+ // if (x > 0)
+ // adjx = 180 + x;
+ int adjy = y + 1;
+ if (x > 0) {
+ adjx++;
+ adjy = y;
+ }
+ int idx = adjx + adjy * this.gridDims[0];
+
+ // System.out.println("paintImage idx==="+idx+" x=="+ijcoord.x+" y====="+ijcoord.y);
+ // System.out.println("INDEX " + idx + " : " + x + "," + y + " : " +
+ // adjx
+ // + "," + adjy + " : " + gridDims[0] + "," + gridDims[1]);
+ if (idx < 0 || idx >= (gridDims[0] * gridDims[1])) {
+ return;
+ }
+ float spd = this.magnitude.get(idx);
+ float dir = this.direction.get(idx);
+
+ if (Float.isNaN(spd) || Float.isNaN(dir)) {
+ return;
+ }
+
+ if (this.isPlotted[idx]) {
+ return;
+ }
+
+ ReferencedCoordinate newrco = new ReferencedCoordinate(new Coordinate(
+ x, y), this.gridGeometryOfGrid, Type.GRID_CENTER);
+ Coordinate plotLoc = null;
+
+ try {
+ plotLoc = newrco.asPixel(this.descriptor.getGridGeometry());
+ latLon = newrco.asLatLon();
+ // System.out.println("plotloc = " + latLon);
+
+ if (latLon.x > 180 || latLon.x < -180 || latLon.y < -90
+ || latLon.y > 90) {
+ return;
+ }
+
+ double[] stationLocation = { latLon.x, latLon.y };
+ double[] stationPixelLocation = this.descriptor
+ .worldToPixel(stationLocation);
+
+ if (stationPixelLocation != null) {
+ stationPixelLocation[1]--;
+ double[] newWorldLocation = this.descriptor
+ .pixelToWorld(stationPixelLocation);
+ this.gc.setStartingGeographicPoint(stationLocation[0],
+ stationLocation[1]);
+ this.gc.setDestinationGeographicPoint(newWorldLocation[0],
+ newWorldLocation[1]);
+ }
+
+ dir = dir + (float) MapUtil.rotation(latLon, gridLocation);
+ dir -= this.gc.getAzimuth();
+ } catch (Exception e) {
+ throw new VizException(e);
+ }
+
+ dir = (float) Math.toRadians(dir);
+ switch (displayType) {
+ case ARROW:
+ paintArrow(plotLoc, adjSize, spd, dir);
+ break;
+ case BARB:
+ paintBarb(plotLoc, adjSize, spd, dir);
+ break;
+ case DUALARROW:
+ paintDualArrow(plotLoc, adjSize, spd, dir);
+ break;
+ default:
+ throw new VizException("Unsupported disply type: " + displayType);
+ }
+
+ this.isPlotted[idx] = true;
+ }
}
diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/EnsembleSelectComposite.java b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/EnsembleSelectComposite.java
index a446d01690..c7097f3682 100644
--- a/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/EnsembleSelectComposite.java
+++ b/ncep/gov.noaa.nws.ncep.viz.rsc.ncgrid/src/gov/noaa/nws/ncep/viz/rsc/ncgrid/rsc/EnsembleSelectComposite.java
@@ -114,7 +114,7 @@ public class EnsembleSelectComposite extends Composite {
Button isPrimaryButton;
Text[] weightText = new Text[MaxNumOfEnsembleCycles];
- Button[] cycleButtons = new Button[MaxNumOfEnsembleCycles];
+ Button[] cycleButtons = new Button[MaxNumOfEnsembleCycles];
}
public EnsembleSelectComposite( Composite parent ) {
@@ -294,7 +294,7 @@ public class EnsembleSelectComposite extends Composite {
// Use the NcGridInventory with constraints on the model/ensembleId
@SuppressWarnings("null")
public Date[] getAvailCycleTimes( Date seldCycleTime, String modelName, String pertNum ) {
-
+
HashMap reqConstraints =
new HashMap();
reqConstraints.put( "pluginName", new RequestConstraint( GridDBConstants.GRID_TBL_NAME ) );
@@ -312,20 +312,20 @@ public class EnsembleSelectComposite extends Composite {
reqMsg.setReqConstraintsMap(
(HashMap)reqConstraints );
reqMsg.setUniqueValues( true );
-
+
Object rslts;
- try {
+ try {
rslts = ThriftClient.sendRequest( reqMsg );
} catch (VizException e) {
System.out.println("Error querying inventory "+inventoryName+" for ensemble "+
" component cycle times:"+e.getMessage() );
return new Date[0];
- }
+ }
if( !(rslts instanceof String[]) ) {
out.println("Inventory Request Failed: "+rslts.toString() );
return new Date[0];
- }
+ }
String[] rsltsList = (String[]) rslts;
DataTime[] dataTimeArr = new DataTime[ rsltsList.length ];
@@ -333,7 +333,7 @@ public class EnsembleSelectComposite extends Composite {
for( int i=0 ; i refTimes = new ArrayList();
@@ -347,14 +347,14 @@ public class EnsembleSelectComposite extends Composite {
if( !refTimes.contains( refTime ) &&
refTime.getTime() <= seldCycleTime.getTime() ) {
refTimes.add( refTime );
- }
+ }
}
-
+
Date[] sortedRefTimesArr = refTimes.toArray( new Date[0] );
Arrays.sort( sortedRefTimesArr );
Date[] availCycleTimesArray =
- Arrays.copyOf( sortedRefTimesArr, MaxNumOfEnsembleCycles );
+ Arrays.copyOf( sortedRefTimesArr, sortedRefTimesArr.length );
return availCycleTimesArray;
}
diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java b/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java
index 4b7d504e49..3992874700 100644
--- a/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java
+++ b/ncep/gov.noaa.nws.ncep.viz.rsc.plotdata/src/gov/noaa/nws/ncep/viz/rsc/plotdata/rsc/NcPlotResource2.java
@@ -125,6 +125,8 @@ import static java.lang.System.out;
* 10/18/2012 896 sgurung Refactored PlotResource2 to use new generator class: NcPlotDataThreadPool. Added FrameLoaderJob to populate all frames.
* Added code to plot stations within 25% of the area outside of the current display area.
* 05/20/2013 988 Archana.S Refactored this class for performance improvement
+ * 10/24/2013 sgurung Added fix for "no data for every other frame" issue
+ *
*
*
* @author brockwoo
@@ -1470,7 +1472,6 @@ public class NcPlotResource2 extends AbstractNatlCntrsResource= 0 ; --index){
frameLoaderTask = new FrameLoaderTask( listOfFrameTimes.get( index ) );
frameRetrievalPool.schedule( frameLoaderTask );
- --index;
}
}
else{
diff --git a/rpms/awips2.core/Installer.httpd-pypies/SOURCES/httpd-pypies.logrotate b/rpms/awips2.core/Installer.httpd-pypies/SOURCES/httpd-pypies.logrotate
deleted file mode 100644
index ab3f28b269..0000000000
--- a/rpms/awips2.core/Installer.httpd-pypies/SOURCES/httpd-pypies.logrotate
+++ /dev/null
@@ -1,8 +0,0 @@
-/awips2/httpd_pypies/var/log/httpd/*log {
- missingok
- notifempty
- sharedscripts
- postrotate
- /sbin/service httpd-pypies reload > /dev/null 2>/dev/null || true
- endscript
-}
diff --git a/rpms/awips2.core/Installer.httpd-pypies/component.spec b/rpms/awips2.core/Installer.httpd-pypies/component.spec
index 5f646e979f..4ea8e60b22 100644
--- a/rpms/awips2.core/Installer.httpd-pypies/component.spec
+++ b/rpms/awips2.core/Installer.httpd-pypies/component.spec
@@ -8,12 +8,11 @@ Summary: Pypies Apache HTTP Server
Name: awips2-httpd-pypies
Version: 2.2.3
# This Is Officially Release: 22%{?dist}
-Release: 30%{?dist}
+Release: 31%{?dist}
URL: http://httpd.apache.org/
Prefix: /awips2/httpd_pypies
Source0: http://www.apache.org/dist/httpd/httpd-%{version}.tar.gz
Source1: centos_index.html
-Source3: httpd-pypies.logrotate
Source4: httpd-pypies.init
Source5: httpd.sysconf
Source8: centos_powered_by_rh.png
@@ -362,11 +361,11 @@ ln -s ../..%{_libdir}/httpd/modules $RPM_BUILD_ROOT/awips2/httpd_pypies/etc/http
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
install -m755 %{_baseline_workspace}/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies \
${RPM_BUILD_ROOT}/etc/init.d
-
-# install log rotation stuff
-mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
-install -m644 $RPM_SOURCE_DIR/httpd-pypies.logrotate \
- $RPM_BUILD_ROOT/etc/logrotate.d/httpd-pypies
+
+# install cron job
+mkdir -p ${RPM_BUILD_ROOT}/etc/cron.daily
+install -m755 %{_baseline_workspace}/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/cron.daily/pypiesLogCleanup.sh \
+ ${RPM_BUILD_ROOT}/etc/cron.daily
# fix man page paths
sed -e "s|/usr/local/apache2/conf/httpd.conf|/etc/httpd/conf/httpd.conf|" \
@@ -571,7 +570,7 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace) /awips2/httpd_pypies%{_sysconfdir}/httpd/conf.d/proxy_ajp.conf
%config(noreplace) /awips2/httpd_pypies%{_sysconfdir}/httpd/conf/magic
-%config(noreplace) %{_sysconfdir}/logrotate.d/httpd-pypies
+%{_sysconfdir}/cron.daily/pypiesLogCleanup.sh
%config(noreplace) %{_sysconfdir}/init.d/httpd-pypies
%dir /awips2/httpd_pypies%{_sysconfdir}/httpd/conf.d
diff --git a/rpms/awips2.core/Installer.httpd-pypies/configuration/conf/httpd.conf b/rpms/awips2.core/Installer.httpd-pypies/configuration/conf/httpd.conf
index c1d1363356..10b8710ddd 100644
--- a/rpms/awips2.core/Installer.httpd-pypies/configuration/conf/httpd.conf
+++ b/rpms/awips2.core/Installer.httpd-pypies/configuration/conf/httpd.conf
@@ -469,7 +469,7 @@ HostnameLookups Off
# logged here. If you *do* define an error logfile for a
# container, that host's errors will be logged there and not here.
#
-ErrorLog logs/error_log
+ErrorLog "|/awips2/httpd_pypies/usr/sbin/rotatelogs /awips2/httpd_pypies/var/log/httpd/error_log.%Y.%m.%d 86400"
#
# LogLevel: Control the number of messages logged to the error_log.
@@ -511,7 +511,7 @@ LogFormat "%{User-agent}i" agent
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
-CustomLog logs/access_log combined
+CustomLog "|/awips2/httpd_pypies/usr/sbin/rotatelogs /awips2/httpd_pypies/var/log/httpd/access_log.%Y.%m.%d 86400" combined
#
# Optionally add a line containing the server version and virtual host
diff --git a/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/cron.daily/pypiesLogCleanup.sh b/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/cron.daily/pypiesLogCleanup.sh
new file mode 100644
index 0000000000..4008cb8d85
--- /dev/null
+++ b/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/cron.daily/pypiesLogCleanup.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# Remove any logs from a week ago, if they exist.
+
+_PYPIES_LOG_DIRECTORY="/awips2/httpd_pypies/var/log/httpd"
+
+_LOG_NAME_PREFIXES=( 'access_log' 'error_log' )
+_COUNT_DAYS=( 7 8 9 10 11 12 13 14 )
+
+for day in ${_COUNT_DAYS[*]}; do
+ _log_date=`date -d "-${day} day" +%Y.%m.%d`
+
+ for logPrefix in ${_LOG_NAME_PREFIXES[*]}; do
+ _log_file="${logPrefix}.${_log_date}"
+
+ echo "${_PYPIES_LOG_DIRECTORY}/${_log_file}"
+ rm -f ${_PYPIES_LOG_DIRECTORY}/${_log_file}
+ done
+done
diff --git a/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies b/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies
index cdbe6c81ce..24a54b3fce 100644
--- a/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies
+++ b/rpms/awips2.core/Installer.httpd-pypies/configuration/etc/init.d/httpd-pypies
@@ -98,10 +98,30 @@ start() {
return $RETVAL
}
+stop() {
+ echo -n $"Stopping $prog: "
+ /awips2/httpd_pypies/usr/sbin/apachectl -k graceful-stop
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
+ echo -n $"Stopping logging service:"
+ # Stop the logging process
+ for pid in `ps aux | grep [l]ogProcess.py | awk '{print $2}'`;
+ do
+ kill -9 ${pid}
+ RC=$?
+ if [ ${RC} -ne 0 ]; then
+ failure
+ return
+ fi
+ done
+ success
+ echo
+}
# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
-stop() {
+forcestop() {
echo -n $"Stopping $prog: "
killproc -d 10 $httpd
RETVAL=$?
@@ -128,7 +148,7 @@ reload() {
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
- killproc $httpd -HUP
+ /awips2/httpd_pypies/usr/sbin/apachectl -k graceful
RETVAL=$?
fi
echo
@@ -142,6 +162,9 @@ case "$1" in
stop)
stop
;;
+ forcestop)
+ forcestop
+ ;;
status)
status $httpd
RETVAL=$?
@@ -164,7 +187,7 @@ case "$1" in
RETVAL=$?
;;
*)
- echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
+ echo $"Usage: $prog {start|stop|forcestop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
diff --git a/rpms/build/i386/build.sh b/rpms/build/i386/build.sh
index c06f7c3002..878964bba4 100644
--- a/rpms/build/i386/build.sh
+++ b/rpms/build/i386/build.sh
@@ -85,7 +85,6 @@ if [ "${2}" = "-nobinlightning" ]; then
fi
if [ "${1}" = "-python-qpid" ]; then
- buildRPM "awips2"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
@@ -116,15 +115,6 @@ if [ "${1}" = "-python-qpid" ]; then
exit 1
fi
- #buildRPM "awips2-ant"
- #unpackHttpdPypies
- if [ $? -ne 0 ]; then
- exit 1
- fi
- #buildRPM "awips2-httpd-pypies"
- #buildRPM "awips2-java"
- #buildRPM "awips2-ldm"
- #buildRPM "awips2-tools"
buildRPM "awips2-python-shapely"
exit 0
@@ -164,7 +154,6 @@ if [ "${1}" = "-delta" ]; then
exit 1
fi
- buildRPM "awips2"
buildRPM "awips2-ncep-database"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
@@ -180,7 +169,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-data.hdf5-gfe.climo"
- buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-maps-database"
buildRPM "awips2-notification"
@@ -188,7 +176,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildRPM "awips2-rcm"
- buildRPM "awips2-edex-environment"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
@@ -198,6 +185,7 @@ if [ "${1}" = "-delta" ]; then
fi
if [ "${1}" = "-full" ]; then
+ buildRPM "awips2"
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
@@ -229,8 +217,8 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
+ buildRPM "awips2-python-shapely"
- buildRPM "awips2"
buildRPM "awips2-adapt-native"
buildRPM "awips2-aviation-shared"
buildRPM "awips2-cli"
@@ -267,14 +255,11 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-httpd-pypies"
buildJava
buildRPM "awips2-groovy"
- #buildRPM "awips2-ldm"
buildRPM "awips2-postgres"
buildRPM "awips2-pgadmin3"
buildRPM "awips2-tools"
- buildRPM "awips2-edex-environment"
buildRPM "awips2-openfire"
buildRPM "awips2-httpd-collaboration"
- buildRPM "awips2-python-shapely"
exit 0
fi
@@ -360,9 +345,6 @@ if [ "${1}" = "-ade" ]; then
fi
if [ "${1}" = "-viz" ]; then
- buildRPM "awips2-common-base"
- buildRPM "awips2-rcm"
- buildRPM "awips2-hydroapps-shared"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
@@ -373,13 +355,9 @@ if [ "${1}" = "-viz" ]; then
fi
if [ "${1}" = "-edex" ]; then
- buildRPM "awips2-common-base"
- buildRPM "awips2-adapt-native"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-edex-environment"
- # buildRPM "awips2-ncep-database"
- # buildRPM "awips2-python-dynamicserialize"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@@ -421,7 +399,19 @@ fi
# Use the custom flag for selecting specific rpms to build
if [ "${1}" = "-custom" ]; then
- #buildRPM "awips2-ldm"
+ #unpackHttpdPypies
+ #if [ $? -ne 0 ]; then
+ # exit 1
+ #fi
+ #buildRPM "awips2-httpd-pypies"
+ #buildRPM "awips2-ant"
+ buildRPM "awips2-adapt-native"
+ #buildRPM "awips2-common-base"
+ buildRPM "awips2-hydroapps-shared"
+ #buildRPM "awips2-java"
+ #buildRPM "awips2-python-dynamicserialize"
+ #buildRPM "awips2-rcm"
+ #buildRPM "awips2-tools"
exit 0
fi
diff --git a/rpms/build/i386/build.sh-keep-10032013 b/rpms/build/i386/build.sh-keep-10212013
similarity index 96%
rename from rpms/build/i386/build.sh-keep-10032013
rename to rpms/build/i386/build.sh-keep-10212013
index 31dd6470c1..9ee32c3e1c 100644
--- a/rpms/build/i386/build.sh-keep-10032013
+++ b/rpms/build/i386/build.sh-keep-10212013
@@ -85,7 +85,6 @@ if [ "${2}" = "-nobinlightning" ]; then
fi
if [ "${1}" = "-python-qpid" ]; then
- buildRPM "awips2"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
@@ -116,15 +115,6 @@ if [ "${1}" = "-python-qpid" ]; then
exit 1
fi
- #buildRPM "awips2-ant"
- #unpackHttpdPypies
- if [ $? -ne 0 ]; then
- exit 1
- fi
- #buildRPM "awips2-httpd-pypies"
- #buildRPM "awips2-java"
- #buildRPM "awips2-ldm"
- #buildRPM "awips2-tools"
buildRPM "awips2-python-shapely"
exit 0
@@ -157,7 +147,6 @@ if [ "${1}" = "-delta" ]; then
exit 1
fi
- buildRPM "awips2"
buildRPM "awips2-ncep-database"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
@@ -173,7 +162,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-data.hdf5-gfe.climo"
- buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-maps-database"
buildRPM "awips2-notification"
@@ -181,7 +169,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildRPM "awips2-rcm"
- buildRPM "awips2-edex-environment"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
@@ -222,8 +209,8 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
+ buildRPM "awips2-python-shapely"
- buildRPM "awips2"
buildRPM "awips2-adapt-native"
buildRPM "awips2-aviation-shared"
buildRPM "awips2-cli"
@@ -260,14 +247,11 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-httpd-pypies"
buildJava
buildRPM "awips2-groovy"
- #buildRPM "awips2-ldm"
buildRPM "awips2-postgres"
buildRPM "awips2-pgadmin3"
buildRPM "awips2-tools"
- buildRPM "awips2-edex-environment"
buildRPM "awips2-openfire"
buildRPM "awips2-httpd-collaboration"
- buildRPM "awips2-python-shapely"
exit 0
fi
@@ -347,9 +331,6 @@ if [ "${1}" = "-ade" ]; then
fi
if [ "${1}" = "-viz" ]; then
- buildRPM "awips2-common-base"
- buildRPM "awips2-rcm"
- buildRPM "awips2-hydroapps-shared"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
@@ -360,13 +341,9 @@ if [ "${1}" = "-viz" ]; then
fi
if [ "${1}" = "-edex" ]; then
- buildRPM "awips2-common-base"
- buildRPM "awips2-adapt-native"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-edex-environment"
- # buildRPM "awips2-ncep-database"
- # buildRPM "awips2-python-dynamicserialize"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@@ -408,7 +385,18 @@ fi
# Use the custom flag for selecting specific rpms to build
if [ "${1}" = "-custom" ]; then
- #buildRPM "awips2-ldm"
+ unpackHttpdPypies
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-httpd-pypies"
+ buildRPM "awips2-adapt-native"
+ buildRPM "awips2-hydroapps-shared"
+ buildRPM "awips2-common-base"
+ buildRPM "awips2-rcm"
+ #buildRPM "awips2-ant"
+ #buildRPM "awips2-java"
+ #buildRPM "awips2-tools"
exit 0
fi
diff --git a/rpms/build/i386/build.sh_old b/rpms/build/i386/build.sh-keep-10312013
similarity index 92%
rename from rpms/build/i386/build.sh_old
rename to rpms/build/i386/build.sh-keep-10312013
index 37dbb8eaa6..061f2699f7 100644
--- a/rpms/build/i386/build.sh_old
+++ b/rpms/build/i386/build.sh-keep-10312013
@@ -85,7 +85,6 @@ if [ "${2}" = "-nobinlightning" ]; then
fi
if [ "${1}" = "-python-qpid" ]; then
- buildRPM "awips2"
buildRPM "awips2-python-qpid"
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
@@ -116,15 +115,6 @@ if [ "${1}" = "-python-qpid" ]; then
exit 1
fi
- #buildRPM "awips2-ant"
- #unpackHttpdPypies
- if [ $? -ne 0 ]; then
- exit 1
- fi
- #buildRPM "awips2-httpd-pypies"
- #buildRPM "awips2-java"
- #buildRPM "awips2-ldm"
- #buildRPM "awips2-tools"
buildRPM "awips2-python-shapely"
exit 0
@@ -137,11 +127,16 @@ if [ "${1}" = "-postgres" ]; then
buildRPM "awips2-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-pgadmin3"
+ buildRPM "awips2-data.hdf5-gfe.climo"
+ buildRPM "awips2-data.hdf5-topo"
+ buildRPM "awips2-notification"
+ buildRPM "awips2-tools"
exit 0
fi
if [ "${1}" = "-delta" ]; then
+ buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
@@ -152,8 +147,7 @@ if [ "${1}" = "-delta" ]; then
exit 1
fi
- buildRPM "awips2"
- buildRPM "Installer.ncep-database"
+ buildRPM "awips2-ncep-database"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-python"
@@ -168,7 +162,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-database-server-configuration"
buildRPM "awips2-database-standalone-configuration"
buildRPM "awips2-data.hdf5-gfe.climo"
- buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-localapps-environment"
buildRPM "awips2-maps-database"
buildRPM "awips2-notification"
@@ -176,7 +169,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
buildRPM "awips2-rcm"
- buildRPM "awips2-edex-environment"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
@@ -186,11 +178,11 @@ if [ "${1}" = "-delta" ]; then
fi
if [ "${1}" = "-full" ]; then
+ buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
fi
- buildRPM "Installer.ncep-database"
buildRPM "awips2-alertviz"
buildEDEX
if [ $? -ne 0 ]; then
@@ -217,8 +209,8 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-python-werkzeug"
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
+ buildRPM "awips2-python-shapely"
- buildRPM "awips2"
buildRPM "awips2-adapt-native"
buildRPM "awips2-aviation-shared"
buildRPM "awips2-cli"
@@ -231,6 +223,7 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-gfesuite-server"
buildRPM "awips2-hydroapps-shared"
buildRPM "awips2-localapps-environment"
+ buildRPM "awips2-ncep-database"
buildRPM "awips2-maps-database"
buildRPM "awips2-notification"
buildRPM "awips2-pypies"
@@ -252,22 +245,20 @@ if [ "${1}" = "-full" ]; then
exit 1
fi
buildRPM "awips2-httpd-pypies"
- buildRPM "awips2-java"
- #buildRPM "awips2-ldm"
+ buildJava
+ buildRPM "awips2-groovy"
buildRPM "awips2-postgres"
buildRPM "awips2-pgadmin3"
buildRPM "awips2-tools"
- buildRPM "awips2-edex-environment"
buildRPM "awips2-openfire"
buildRPM "awips2-httpd-collaboration"
- buildRPM "awips2-python-shapely"
exit 0
fi
if [ "${1}" = "-ade" ]; then
buildRPM "awips2-eclipse"
- buildRPM "awips2-java"
+ buildJava
buildRPM "awips2-ant"
buildRPM "awips2-python"
buildRPM "awips2-python-cherrypy"
@@ -340,8 +331,6 @@ if [ "${1}" = "-ade" ]; then
fi
if [ "${1}" = "-viz" ]; then
- buildRPM "awips2"
- buildRPM "awips2-rcm"
buildCAVE
if [ $? -ne 0 ]; then
exit 1
@@ -352,11 +341,9 @@ if [ "${1}" = "-viz" ]; then
fi
if [ "${1}" = "-edex" ]; then
- buildRPM "awips2"
- buildRPM "awips2-cli"
buildRPM "awips2-gfesuite-client"
buildRPM "awips2-gfesuite-server"
- buildRPM "Installer.ncep-database"
+ buildRPM "awips2-edex-environment"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@@ -365,6 +352,16 @@ if [ "${1}" = "-edex" ]; then
exit 0
fi
+if [ "${1}" = "-localization" ]; then
+ buildLocalizationRPMs
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+
if [ "${1}" = "-qpid" ]; then
buildQPID
if [ $? -ne 0 ]; then
@@ -380,6 +377,31 @@ if [ "${1}" = "-ldm" ]; then
exit 0
fi
+if [ "${1}" = "-awips2" ]; then
+ buildRPM "awips2"
+
+ exit 0
+fi
+
+# Use the custom flag for selecting specific rpms to build
+if [ "${1}" = "-custom" ]; then
+ #unpackHttpdPypies
+ #if [ $? -ne 0 ]; then
+ # exit 1
+ #fi
+ #buildRPM "awips2-httpd-pypies"
+ #buildRPM "awips2-ant"
+ #buildRPM "awips2-adapt-native"
+ #buildRPM "awips2-common-base"
+ #buildRPM "awips2-hydroapps-shared"
+ #buildRPM "awips2-java"
+ buildRPM "awips2-python-dynamicserialize"
+ #buildRPM "awips2-rcm"
+ #buildRPM "awips2-tools"
+
+ exit 0
+fi
+
if [ "${1}" = "-package" ]; then
repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
if [ -d ${WORKSPACE}/${repository_directory} ]; then
diff --git a/rpms/build/x86_64/build.sh b/rpms/build/x86_64/build.sh
index eb3cddb126..b61205f522 100644
--- a/rpms/build/x86_64/build.sh
+++ b/rpms/build/x86_64/build.sh
@@ -116,7 +116,6 @@ if [ "${1}" = "-64bit" ]; then
buildRPM "awips2-python-pygtk"
buildRPM "awips2-python-pycairo"
buildJava
- buildRPM "awips2"
buildRPM "awips2-python-shapely"
buildRPM "awips2-notification"
@@ -155,7 +154,6 @@ if [ "${1}" = "-delta" ]; then
buildRPM "awips2-localapps-environment"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
- buildRPM "awips2"
buildLocalizationRPMs
if [ $? -ne 0 ]; then
exit 1
@@ -167,6 +165,7 @@ if [ "${1}" = "-delta" ]; then
fi
if [ "${1}" = "-full" ]; then
+ buildRPM "awips2"
buildRPM "awips2-common-base"
buildCAVE
if [ $? -ne 0 ]; then
@@ -205,7 +204,6 @@ if [ "${1}" = "-full" ]; then
buildRPM "awips2-localapps-environment"
buildRPM "awips2-data.hdf5-topo"
buildRPM "awips2-data.gfe"
- buildRPM "awips2"
unpackHttpdPypies
if [ $? -ne 0 ]; then
exit 1
@@ -250,6 +248,7 @@ fi
if [ "${1}" = "-edex" ]; then
buildRPM "awips2-common-base"
+ buildRPM "awips2-edex-environment"
buildEDEX
if [ $? -ne 0 ]; then
exit 1
@@ -273,6 +272,31 @@ if [ "${1}" = "-ldm" ]; then
exit 0
fi
+
+if [ "${1}" = "-awips2" ]; then
+ buildRPM "awips2"
+
+ exit 0
+fi
+
+# Use the custom flag for selecting specific rpms to build
+if [ "${1}" = "-custom" ]; then
+ #unpackHttpdPypies
+ #if [ $? -ne 0 ]; then
+ # exit 1
+ #fi
+ #buildRPM "awips2-httpd-pypies"
+ buildRPM "awips2-adapt-native"
+ #buildRPM "awips2-ant"
+ buildRPM "awips2-hydroapps-shared"
+ #buildRPM "awips2-java"
+ #buildRPM "awips2-python-dynamicserialize"
+ #buildRPM "awips2-tools"
+
+ exit 0
+fi
+
+
if [ "${1}" = "-package" ]; then
repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
if [ -d ${WORKSPACE}/${repository_directory} ]; then
diff --git a/rpms/build/x86_64/build.sh-10172013 b/rpms/build/x86_64/build.sh-10172013
new file mode 100644
index 0000000000..c1ac1b921a
--- /dev/null
+++ b/rpms/build/x86_64/build.sh-10172013
@@ -0,0 +1,333 @@
+#!/bin/bash
+
+function buildRPM()
+{
+ # Arguments:
+ # ${1} == the name of the rpm.
+ lookupRPM "${1}"
+ if [ $? -ne 0 ]; then
+ echo "ERROR: '${1}' is not a recognized AWIPS II RPM."
+ exit 1
+ fi
+
+ /usr/bin/rpmbuild -ba \
+ --define '_topdir %(echo ${AWIPSII_TOP_DIR})' \
+ --define '_baseline_workspace %(echo ${WORKSPACE})' \
+ --define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \
+ --define '_awipscm_share %(echo ${AWIPSCM_SHARE})' \
+ --define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \
+ --define '_component_version %(echo ${AWIPSII_VERSION})' \
+ --define '_component_release %(echo ${AWIPSII_RELEASE})' \
+ --define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \
+ --define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \
+ --define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \
+ --buildroot ${AWIPSII_BUILD_ROOT} \
+ ${RPM_SPECIFICATION}/component.spec
+ if [ $? -ne 0 ]; then
+ echo "ERROR: Failed to build RPM ${1}."
+ exit 1
+ fi
+
+ return 0
+}
+
+# This script will build all of the 64-bit rpms.
+# Ensure that we are on a machine with the correct architecture.
+
+architecture=`uname -i`
+if [ ! "${architecture}" = "x86_64" ]; then
+ echo "ERROR: This build can only be performed on a 64-bit Operating System."
+ exit 1
+fi
+
+# Determine which directory we are running from.
+path_to_script=`readlink -f $0`
+dir=$(dirname $path_to_script)
+
+common_dir=`cd ${dir}/../common; pwd;`
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to find the common functions directory."
+ exit 1
+fi
+# source the common functions.
+source ${common_dir}/lookupRPM.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to source the common functions."
+ exit 1
+fi
+source ${common_dir}/usage.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to source the common functions."
+ exit 1
+fi
+source ${common_dir}/rpms.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to source the common functions."
+ exit 1
+fi
+source ${common_dir}/systemInfo.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to retrieve the system information."
+ exit 1
+fi
+
+# prepare the build environment.
+source ${dir}/buildEnvironment.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to prepare the build environment."
+ exit 1
+fi
+
+export LIGHTNING=true
+# Determine if the optional '-nobinlightning' argument has been specified.
+if [ "${2}" = "-nobinlightning" ]; then
+ LIGHTNING=false
+fi
+
+if [ "${1}" = "-64bit" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-python"
+ buildRPM "awips2-python-cherrypy"
+ buildRPM "awips2-python-dynamicserialize"
+ buildRPM "awips2-python-h5py"
+ buildRPM "awips2-python-jimporter"
+ buildRPM "awips2-python-matplotlib"
+ buildRPM "awips2-python-nose"
+ buildRPM "awips2-python-numpy"
+ buildRPM "awips2-python-pil"
+ buildRPM "awips2-python-pmw"
+ buildRPM "awips2-python-pupynere"
+ buildRPM "awips2-python-qpid"
+ buildRPM "awips2-python-scientific"
+ buildRPM "awips2-python-scipy"
+ buildRPM "awips2-python-tables"
+ buildRPM "awips2-python-thrift"
+ buildRPM "awips2-python-tpg"
+ buildRPM "awips2-python-ufpy"
+ buildRPM "awips2-python-werkzeug"
+ buildRPM "awips2-python-pygtk"
+ buildRPM "awips2-python-pycairo"
+ buildJava
+ buildRPM "awips2-python-shapely"
+ buildRPM "awips2-notification"
+
+ exit 0
+fi
+
+if [ "${1}" = "-postgres" ]; then
+ buildRPM "awips2-postgres"
+ buildRPM "awips2-database-server-configuration"
+ buildRPM "awips2-database-standalone-configuration"
+ buildRPM "awips2-database"
+ buildRPM "awips2-maps-database"
+ buildRPM "awips2-ncep-database"
+ buildRPM "awips2-pgadmin3"
+
+ exit 0
+fi
+
+if [ "${1}" = "-delta" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+ buildEDEX
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-python-dynamicserialize"
+ buildRPM "awips2-python-ufpy"
+ buildRPM "awips2-cli"
+ buildRPM "awips2-data.hdf5-gfe.climo"
+ buildRPM "awips2-gfesuite-client"
+ buildRPM "awips2-gfesuite-server"
+ buildRPM "awips2-localapps-environment"
+ buildRPM "awips2-data.hdf5-topo"
+ buildRPM "awips2-data.gfe"
+ buildLocalizationRPMs
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-edex-environment"
+ buildRPM "awips2-notification"
+
+ exit 0
+fi
+
+if [ "${1}" = "-full" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+ buildEDEX
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-python"
+ buildRPM "awips2-python-cherrypy"
+ buildRPM "awips2-python-dynamicserialize"
+ buildRPM "awips2-python-h5py"
+ buildRPM "awips2-python-jimporter"
+ buildRPM "awips2-python-matplotlib"
+ buildRPM "awips2-python-nose"
+ buildRPM "awips2-python-numpy"
+ buildRPM "awips2-python-pil"
+ buildRPM "awips2-python-pmw"
+ buildRPM "awips2-python-pupynere"
+ buildRPM "awips2-python-qpid"
+ buildRPM "awips2-python-scientific"
+ buildRPM "awips2-python-scipy"
+ buildRPM "awips2-python-tables"
+ buildRPM "awips2-python-thrift"
+ buildRPM "awips2-python-tpg"
+ buildRPM "awips2-python-ufpy"
+ buildRPM "awips2-python-werkzeug"
+ buildRPM "awips2-python-pygtk"
+ buildRPM "awips2-python-pycairo"
+ buildRPM "awips2-cli"
+ buildRPM "awips2-data.hdf5-gfe.climo"
+ buildRPM "awips2-gfesuite-client"
+ buildRPM "awips2-gfesuite-server"
+ buildRPM "awips2-localapps-environment"
+ buildRPM "awips2-data.hdf5-topo"
+ buildRPM "awips2-data.gfe"
+ unpackHttpdPypies
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-httpd-pypies"
+ buildJava
+ buildRPM "awips2-groovy"
+ buildLocalizationRPMs
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-edex-environment"
+ buildRPM "awips2-notification"
+ buildRPM "awips2-python-shapely"
+ buildRPM "awips2-postgres"
+ buildRPM "awips2-database"
+ buildRPM "awips2-maps-database"
+ buildRPM "awips2-ncep-database"
+ buildRPM "awips2-pgadmin3"
+ buildRPM "awips2-ldm"
+ exit 0
+fi
+
+if [ "${1}" = "-ade" ]; then
+ echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE."
+ exit 0
+ buildRPM "awips2-eclipse"
+
+ exit 0
+fi
+
+if [ "${1}" = "-viz" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+
+ exit 0
+fi
+
+if [ "${1}" = "-edex" ]; then
+ buildRPM "awips2-common-base"
+ buildEDEX
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+if [ "${1}" = "-qpid" ]; then
+ buildQPID
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+if [ "${1}" = "-ldm" ]; then
+ buildRPM "awips2-ldm"
+
+ exit 0
+fi
+
+
+if [ "${1}" = "-awips2" ]; then
+ buildRPM "awips2"
+
+ exit 0
+fi
+
+# Use the custom flag for selecting specific rpms to build
+if [ "${1}" = "-custom" ]; then
+ unpackHttpdPypies
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-httpd-pypies"
+ buildRPM "awips2-adapt-native"
+ buildRPM "awips2-hydroapps-shared"
+
+ exit 0
+fi
+
+
+if [ "${1}" = "-package" ]; then
+ repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
+ if [ -d ${WORKSPACE}/${repository_directory} ]; then
+ rm -rf ${WORKSPACE}/${repository_directory}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ fi
+ mkdir -p ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ cp -r ${AWIPSII_TOP_DIR}/RPMS/* \
+ ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ rpms_directory="${WORKSPACE}/rpms"
+ comps_xml="${rpms_directory}/common/yum/arch.x86_64/comps.xml"
+ cp -v ${comps_xml} ${WORKSPACE}/${repository_directory}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ pushd . > /dev/null
+ cd ${WORKSPACE}
+ tar -cvf ${repository_directory}.tar ${repository_directory}
+ RC=$?
+ popd > /dev/null
+ if [ ${RC} -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+usage
+exit 0
diff --git a/rpms/build/x86_64/build.sh-10312013 b/rpms/build/x86_64/build.sh-10312013
new file mode 100644
index 0000000000..fcd9f21030
--- /dev/null
+++ b/rpms/build/x86_64/build.sh-10312013
@@ -0,0 +1,338 @@
+#!/bin/bash
+
+function buildRPM()
+{
+ # Arguments:
+ # ${1} == the name of the rpm.
+ lookupRPM "${1}"
+ if [ $? -ne 0 ]; then
+ echo "ERROR: '${1}' is not a recognized AWIPS II RPM."
+ exit 1
+ fi
+
+ /usr/bin/rpmbuild -ba \
+ --define '_topdir %(echo ${AWIPSII_TOP_DIR})' \
+ --define '_baseline_workspace %(echo ${WORKSPACE})' \
+ --define '_uframe_eclipse %(echo ${UFRAME_ECLIPSE})' \
+ --define '_awipscm_share %(echo ${AWIPSCM_SHARE})' \
+ --define '_build_root %(echo ${AWIPSII_BUILD_ROOT})' \
+ --define '_component_version %(echo ${AWIPSII_VERSION})' \
+ --define '_component_release %(echo ${AWIPSII_RELEASE})' \
+ --define '_component_build_date %(echo ${COMPONENT_BUILD_DATE})' \
+ --define '_component_build_time %(echo ${COMPONENT_BUILD_TIME})' \
+ --define '_component_build_system %(echo ${COMPONENT_BUILD_SYSTEM})' \
+ --buildroot ${AWIPSII_BUILD_ROOT} \
+ ${RPM_SPECIFICATION}/component.spec
+ if [ $? -ne 0 ]; then
+ echo "ERROR: Failed to build RPM ${1}."
+ exit 1
+ fi
+
+ return 0
+}
+
+# This script will build all of the 64-bit rpms.
+# Ensure that we are on a machine with the correct architecture.
+
+architecture=`uname -i`
+if [ ! "${architecture}" = "x86_64" ]; then
+ echo "ERROR: This build can only be performed on a 64-bit Operating System."
+ exit 1
+fi
+
+# Determine which directory we are running from.
+path_to_script=`readlink -f $0`
+dir=$(dirname $path_to_script)
+
+common_dir=`cd ${dir}/../common; pwd;`
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to find the common functions directory."
+ exit 1
+fi
+# source the common functions.
+source ${common_dir}/lookupRPM.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to source the common functions."
+ exit 1
+fi
+source ${common_dir}/usage.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to source the common functions."
+ exit 1
+fi
+source ${common_dir}/rpms.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to source the common functions."
+ exit 1
+fi
+source ${common_dir}/systemInfo.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to retrieve the system information."
+ exit 1
+fi
+
+# prepare the build environment.
+source ${dir}/buildEnvironment.sh
+if [ $? -ne 0 ]; then
+ echo "ERROR: Unable to prepare the build environment."
+ exit 1
+fi
+
+export LIGHTNING=true
+# Determine if the optional '-nobinlightning' argument has been specified.
+if [ "${2}" = "-nobinlightning" ]; then
+ LIGHTNING=false
+fi
+
+if [ "${1}" = "-64bit" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-python"
+ buildRPM "awips2-python-cherrypy"
+ buildRPM "awips2-python-dynamicserialize"
+ buildRPM "awips2-python-h5py"
+ buildRPM "awips2-python-jimporter"
+ buildRPM "awips2-python-matplotlib"
+ buildRPM "awips2-python-nose"
+ buildRPM "awips2-python-numpy"
+ buildRPM "awips2-python-pil"
+ buildRPM "awips2-python-pmw"
+ buildRPM "awips2-python-pupynere"
+ buildRPM "awips2-python-qpid"
+ buildRPM "awips2-python-scientific"
+ buildRPM "awips2-python-scipy"
+ buildRPM "awips2-python-tables"
+ buildRPM "awips2-python-thrift"
+ buildRPM "awips2-python-tpg"
+ buildRPM "awips2-python-ufpy"
+ buildRPM "awips2-python-werkzeug"
+ buildRPM "awips2-python-pygtk"
+ buildRPM "awips2-python-pycairo"
+ buildJava
+ buildRPM "awips2-python-shapely"
+ buildRPM "awips2-notification"
+
+ exit 0
+fi
+
+if [ "${1}" = "-postgres" ]; then
+ buildRPM "awips2-postgres"
+ buildRPM "awips2-database-server-configuration"
+ buildRPM "awips2-database-standalone-configuration"
+ buildRPM "awips2-database"
+ buildRPM "awips2-maps-database"
+ buildRPM "awips2-ncep-database"
+ buildRPM "awips2-pgadmin3"
+
+ exit 0
+fi
+
+if [ "${1}" = "-delta" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+ buildEDEX
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-python-dynamicserialize"
+ buildRPM "awips2-python-ufpy"
+ buildRPM "awips2-cli"
+ buildRPM "awips2-data.hdf5-gfe.climo"
+ buildRPM "awips2-gfesuite-client"
+ buildRPM "awips2-gfesuite-server"
+ buildRPM "awips2-localapps-environment"
+ buildRPM "awips2-data.hdf5-topo"
+ buildRPM "awips2-data.gfe"
+ buildLocalizationRPMs
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-edex-environment"
+ buildRPM "awips2-notification"
+
+ exit 0
+fi
+
+if [ "${1}" = "-full" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+ buildEDEX
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-python"
+ buildRPM "awips2-python-cherrypy"
+ buildRPM "awips2-python-dynamicserialize"
+ buildRPM "awips2-python-h5py"
+ buildRPM "awips2-python-jimporter"
+ buildRPM "awips2-python-matplotlib"
+ buildRPM "awips2-python-nose"
+ buildRPM "awips2-python-numpy"
+ buildRPM "awips2-python-pil"
+ buildRPM "awips2-python-pmw"
+ buildRPM "awips2-python-pupynere"
+ buildRPM "awips2-python-qpid"
+ buildRPM "awips2-python-scientific"
+ buildRPM "awips2-python-scipy"
+ buildRPM "awips2-python-tables"
+ buildRPM "awips2-python-thrift"
+ buildRPM "awips2-python-tpg"
+ buildRPM "awips2-python-ufpy"
+ buildRPM "awips2-python-werkzeug"
+ buildRPM "awips2-python-pygtk"
+ buildRPM "awips2-python-pycairo"
+ buildRPM "awips2-cli"
+ buildRPM "awips2-data.hdf5-gfe.climo"
+ buildRPM "awips2-gfesuite-client"
+ buildRPM "awips2-gfesuite-server"
+ buildRPM "awips2-localapps-environment"
+ buildRPM "awips2-data.hdf5-topo"
+ buildRPM "awips2-data.gfe"
+ unpackHttpdPypies
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-httpd-pypies"
+ buildJava
+ buildRPM "awips2-groovy"
+ buildLocalizationRPMs
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-edex-environment"
+ buildRPM "awips2-notification"
+ buildRPM "awips2-python-shapely"
+ buildRPM "awips2-postgres"
+ buildRPM "awips2-database"
+ buildRPM "awips2-maps-database"
+ buildRPM "awips2-ncep-database"
+ buildRPM "awips2-pgadmin3"
+ buildRPM "awips2-ldm"
+ exit 0
+fi
+
+if [ "${1}" = "-ade" ]; then
+ echo "INFO: AWIPS II currently does not support a 64-bit version of the ADE."
+ exit 0
+ buildRPM "awips2-eclipse"
+
+ exit 0
+fi
+
+if [ "${1}" = "-viz" ]; then
+ buildRPM "awips2-common-base"
+ buildCAVE
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ buildRPM "awips2-alertviz"
+
+ exit 0
+fi
+
+if [ "${1}" = "-edex" ]; then
+ buildRPM "awips2-common-base"
+ buildRPM "awips2-edex-environment"
+ buildEDEX
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+if [ "${1}" = "-qpid" ]; then
+ buildQPID
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+if [ "${1}" = "-ldm" ]; then
+ buildRPM "awips2-ldm"
+
+ exit 0
+fi
+
+
+if [ "${1}" = "-awips2" ]; then
+ buildRPM "awips2"
+
+ exit 0
+fi
+
+# Use the custom flag for selecting specific rpms to build
+if [ "${1}" = "-custom" ]; then
+ #unpackHttpdPypies
+ #if [ $? -ne 0 ]; then
+ # exit 1
+ #fi
+ #buildRPM "awips2-httpd-pypies"
+ #buildRPM "awips2-adapt-native"
+ #buildRPM "awips2-hydroapps-shared"
+ #buildRPM "awips2-ant"
+ buildRPM "awips2-python-dynamicserialize"
+ #buildRPM "awips2-java"
+ #buildRPM "awips2-tools"
+
+ exit 0
+fi
+
+
+if [ "${1}" = "-package" ]; then
+ repository_directory="awips2-repository-${AWIPSII_VERSION}-${AWIPSII_RELEASE}"
+ if [ -d ${WORKSPACE}/${repository_directory} ]; then
+ rm -rf ${WORKSPACE}/${repository_directory}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+ fi
+ mkdir -p ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ cp -r ${AWIPSII_TOP_DIR}/RPMS/* \
+ ${WORKSPACE}/${repository_directory}/${AWIPSII_VERSION}-${AWIPSII_RELEASE}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ rpms_directory="${WORKSPACE}/rpms"
+ comps_xml="${rpms_directory}/common/yum/arch.x86_64/comps.xml"
+ cp -v ${comps_xml} ${WORKSPACE}/${repository_directory}
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+
+ pushd . > /dev/null
+ cd ${WORKSPACE}
+ tar -cvf ${repository_directory}.tar ${repository_directory}
+ RC=$?
+ popd > /dev/null
+ if [ ${RC} -ne 0 ]; then
+ exit 1
+ fi
+
+ exit 0
+fi
+
+usage
+exit 0