diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.classpath b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.project b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.project new file mode 100644 index 0000000000..6cd9b28af7 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.edex.plugin.bufrobs + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..c537b63063 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..1867e585df --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Bufrobs +Bundle-SymbolicName: com.raytheon.uf.edex.plugin.bufrobs +Bundle-Version: 1.14.0 +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.raytheon.uf.common.nc.bufr, + com.raytheon.uf.common.nc4, + ucar.nc2, + ucar.nc2.bufrsplitter, + com.raytheon.uf.common.status, + org.geotools diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/build.properties b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/util/BaseTranslationTableGenerator.java b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/util/BaseTranslationTableGenerator.java new file mode 100644 index 0000000000..c45785da28 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/src/com/raytheon/uf/edex/plugin/bufrobs/util/BaseTranslationTableGenerator.java @@ -0,0 +1,180 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.edex.plugin.bufrobs.util; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.InvalidParameterException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.JAXBException; +import javax.xml.stream.XMLStreamException; + +import com.raytheon.uf.common.nc.bufr.util.TranslationTableGenerator; + +/** + * Command line utility to generate obs translation table base files. The + * resulting files will be edited to add mapping values to synoptic tables. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 24, 2014 2906       bclement     Initial creation
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ +public class BaseTranslationTableGenerator { + + public static final String PREFIX_OPT = "-p"; + + public static final String TABLES_OPT = "-t"; + + public static final String DEST_DIR_OPT = "-d"; + + public static final Set OPTIONS = new HashSet( + Arrays.asList(PREFIX_OPT, TABLES_OPT, DEST_DIR_OPT)); + + public static final String DEFAULT_DEST_DIR = "utility/edex_static/base/bufrobs/tables"; + + public static final String ARGDESC = "Arguments: -p [optional file prefix]" + + " -d [optional destination directory]" + + " -t [optional comma separated list of table names in 'F XX YYY' format]" + + " [WMO BUFR Code Table XML file]"; + + /** + * Example arguments: + * + *
+     * -p synoptic_land -d utility/edex_static/base/bufrobs/tables -t "0 10 063,0 20 011,0 20 012,0 20 003" BUFRCREX_21_0_0_CodeFlag_en.xml
+     * 
+ * + * @param args + * @throws XMLStreamException + * @throws JAXBException + * @throws IOException + */ + public static void main(String[] args) throws XMLStreamException, + JAXBException, IOException { + OptArgs optArgs = processArgs(args, OPTIONS); + if (optArgs.args.size() != 1) { + System.out.println(ARGDESC); + System.exit(1); + } + String bufrFile = optArgs.args.get(0); + String dest = optArgs.opts.get(DEST_DIR_OPT); + if (dest == null) { + dest = DEFAULT_DEST_DIR; + } + Set includedTables; + String tablesStr = optArgs.opts.get(TABLES_OPT); + if (tablesStr == null || tablesStr.trim().isEmpty()) { + includedTables = Collections.emptySet(); + } else { + includedTables = parseTables(tablesStr); + } + String prefix = optArgs.opts.get(PREFIX_OPT); + if (prefix == null) { + prefix = ""; + } + InputStream bufrTables = new FileInputStream(bufrFile); + try { + TranslationTableGenerator.generate(prefix, new File( + dest), includedTables, true, bufrTables); + } finally { + bufrTables.close(); + } + } + + /** + * Split string by comma and place in set + * + * @param tablesStr + * @return + */ + private static Set parseTables(String tablesStr) { + Set rval = new HashSet(); + for (String part : tablesStr.split(",")) { + part = part.trim(); + if (!part.isEmpty()) { + rval.add(part); + } + } + return rval; + } + + /* + * return value container for options map and list of arguments + */ + private static class OptArgs { + final Map opts; + + final List args; + + public OptArgs(Map opts, List args) { + this.opts = opts; + this.args = args; + } + } + + /** + * Process list of command line arguments that have option flags with values + * followed by a possible list of additional arguments + * + * @param args + * command line arguments + * @param options + * option flags + * @return + */ + public static OptArgs processArgs(String[] args, Set options) { + Map opts = new HashMap(); + List leftOver = new ArrayList(); + for (int i = 0; i < args.length; ++i) { + if (options.contains(args[i])) { + if (i + 1 > args.length || options.contains(args[i + 1])) { + throw new InvalidParameterException("Invalid option: '" + + args[i] + + "'. All options must be followed by value"); + } + opts.put(args[i], args[i + 1]); + i += 1; + } else { + leftOver.add(args[i]); + } + } + return new OptArgs(opts, leftOver); + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_10_063.xml b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_10_063.xml new file mode 100644 index 0000000000..667f594489 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_10_063.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_003.xml b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_003.xml new file mode 100644 index 0000000000..981c0d9848 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_003.xml @@ -0,0 +1,1108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_011.xml b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_011.xml new file mode 100644 index 0000000000..30a48c8516 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_011.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_012.xml b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_012.xml new file mode 100644 index 0000000000..ea255fec30 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.plugin.bufrobs/utility/edex_static/base/bufrobs/tables/synoptic_land-0_20_012.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file