Omaha #4911 - Fix updating common_obs_spatial

Change-Id: I4bece475ecf7e63a4ecaf3579c7885a4d776d585

Former-commit-id: b2206e973e66c537a95c9502049fc70a39a29629
This commit is contained in:
Richard Peter 2015-10-12 13:07:54 -05:00
parent b1032150f1
commit f510e43795
29 changed files with 2716 additions and 4067 deletions

View file

@ -0,0 +1,13 @@
#! /bin/bash
# DR #4911 - This script drops unused columns from the common_obs_spatial table
PSQL="/awips2/psql/bin/psql"
columns=( "aerodromeflag" "rbsnindicator" "pressurelevel" )
echo "INFO: Updating common_obs_spatial"
for column in ${columns[@]} ; do
${PSQL} -U awips -d metadata -c "ALTER TABLE IF EXISTS common_obs_spatial DROP COLUMN IF EXISTS ${column} ;"
done

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Loctables Plug-in
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.loctables
Bundle-Version: 1.14.0.qualifier
Bundle-Version: 1.15.1.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: com.raytheon.edex.common,
@ -10,10 +10,9 @@ Require-Bundle: com.raytheon.edex.common,
com.raytheon.uf.common.localization,
javax.measure,
org.geotools,
org.slf4j,
javax.persistence,
com.raytheon.uf.edex.decodertools;bundle-version="1.0.0",
com.raytheon.uf.common.site;bundle-version="1.12.1174",
com.raytheon.uf.edex.site;bundle-version="1.0.0",
com.raytheon.uf.common.monitor;bundle-version="1.12.1174",
com.raytheon.uf.edex.ndm;bundle-version="1.0.0"
Import-Package: org.apache.commons.logging

View file

@ -2,49 +2,50 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="loctablesPluginName" class="java.lang.String" depends-on="ndmProc">
<constructor-arg type="java.lang.String" value="loctables" />
</bean>
<bean id="loctablesProperties" class="com.raytheon.uf.common.dataplugin.PluginProperties">
<property name="pluginName" ref="loctablesPluginName" />
</bean>
<bean factory-bean="pluginRegistry" factory-method="register">
<constructor-arg value="loctables"/>
<constructor-arg ref="loctablesProperties"/>
</bean>
<bean id="loctablesIngest" class="com.raytheon.uf.edex.plugin.loctables.ingest.LocationTablesIngest">
<constructor-arg ref="loctablesPluginName" />
<constructor-arg ref="ndmProc" />
</bean>
<bean id="loctablesDistRegistry" factory-bean="distributionSrv"
factory-method="register">
<constructor-arg ref="loctablesPluginName" />
<constructor-arg value="jms-durable:queue:Ingest.loctables" />
<bean id="raobTableHandler" class="com.raytheon.uf.edex.plugin.loctables.util.handlers.RAOBTableHandler"/>
<bean id="maritimeTableHandler" class="com.raytheon.uf.edex.plugin.loctables.util.handlers.MaritimeTableHandler"/>
<bean id="metarTableHandler" class="com.raytheon.uf.edex.plugin.loctables.util.handlers.MetarTableHandler"/>
<bean id="pirepTableHandler" class="com.raytheon.uf.edex.plugin.loctables.util.handlers.PirepTableHandler"/>
<bean id="synopticTableHandler" class="com.raytheon.uf.edex.plugin.loctables.util.handlers.SynopticLandTableHandler"/>
<bean id="mesonetTableHandler" class="com.raytheon.uf.edex.plugin.loctables.util.handlers.MesonetTableHandler"/>
<!-- Order is specific -->
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="raobStationInfo.txt" />
<constructor-arg ref="raobTableHandler" />
</bean>
<camelContext id="loctables-camel"
xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="CMANStationInfo.txt" />
<constructor-arg ref="maritimeTableHandler" />
</bean>
<!-- Begin loctables routes -->
<route id="loctablesIngestRoute">
<from uri="jms-durable:queue:Ingest.loctables"/>
<setHeader headerName="pluginName">
<constant>loctables</constant>
</setHeader>
<doTry>
<bean ref="loctablesIngest" method="processFile" />
<doCatch>
<exception>java.lang.Throwable</exception>
<to uri="log:loctables?level=ERROR"/>
</doCatch>
</doTry>
</route>
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="maritimeStationInfo.txt" />
<constructor-arg ref="maritimeTableHandler" />
</bean>
</camelContext>
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="metarStationInfo.txt" />
<constructor-arg ref="metarTableHandler" />
</bean>
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="pirepsTable.txt" />
<constructor-arg ref="pirepTableHandler" />
</bean>
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="synopticStationTable.txt" />
<constructor-arg ref="synopticTableHandler" />
</bean>
<bean factory-bean="loctablesIngest" factory-method="registerHandler">
<constructor-arg value="mesonetStationInfo.txt" />
<constructor-arg ref="mesonetTableHandler" />
</bean>
</beans>

View file

@ -20,28 +20,34 @@
package com.raytheon.uf.edex.plugin.loctables.ingest;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
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.localization.SaveableOutputStream;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.edex.database.query.DatabaseQuery;
import com.raytheon.uf.edex.ndm.ingest.IDataSetIngester;
import com.raytheon.uf.edex.ndm.ingest.INationalDatasetSubscriber;
import com.raytheon.uf.edex.plugin.loctables.util.CommonObsSpatialBuilder;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.DefaultHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.MaritimeTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.MesonetTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.MetarTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.PirepTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.RAOBTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.SynopticLandTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
/**
* Location Tables NDM subscriber
@ -57,7 +63,7 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationStoreStrategy;
* Apr 28, 2014 3086 skorolev Updated setupLocalFiles method
* Sep 04, 2014 3220 skorolev Removed parameter currentSite from FSSObs configuration managers.
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObs monitors.
*
* Oct 12, 2015 4911 rjpeter Updated to reload all location data and diff table as a whole.
* </pre>
*
* @author jkorman
@ -66,17 +72,13 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationStoreStrategy;
public class LocationTablesIngest implements INationalDatasetSubscriber {
private static final TableHandler DEFAULT_HANDLER = new DefaultHandler();
private static final String NDM_LOC_DIR = "spatialTables" + File.separator;
private HashMap<String, TableHandler> handlers = null;
private final Logger logger = LoggerFactory.getLogger(getClass());
private IDataSetIngester ingester = null;
private final Map<String, TableHandler> handlers;
private final Log logger = LogFactory.getLog(getClass());
@SuppressWarnings("unused")
private LocationTablesIngest() {
}
private final IDataSetIngester ndmIngester;
/**
* Location Tables Ingest.
@ -84,55 +86,17 @@ public class LocationTablesIngest implements INationalDatasetSubscriber {
* @param pluginName
* @param ingester
*/
public LocationTablesIngest(String pluginName, IDataSetIngester ingester) {
this.ingester = ingester;
public LocationTablesIngest(IDataSetIngester ingester) {
ndmIngester = ingester;
setupHandlers();
setupLocalFiles();
// always want to process in same order
handlers = new LinkedHashMap<String, TableHandler>();
}
/**
* Setup Handlers.
*/
private void setupHandlers() {
logger.info("Creating handlers");
handlers = new HashMap<String, TableHandler>();
handlers.put("pirepsTable.txt", new PirepTableHandler(
new ObStationStoreStrategy()));
handlers.put("maritimeStationInfo.txt", new MaritimeTableHandler(
new ObStationStoreStrategy()));
handlers.put("metarStationInfo.txt", new MetarTableHandler(
new ObStationStoreStrategy()));
handlers.put("synopticStationTable.txt", new SynopticLandTableHandler(
new ObStationStoreStrategy()));
handlers.put("raobStationInfo.txt", new RAOBTableHandler(
new ObStationStoreStrategy()));
handlers.put("mesonetStationInfo.txt", new MesonetTableHandler(
new ObStationStoreStrategy()));
handlers.put("CMANStationInfo.txt", new MaritimeTableHandler(
new ObStationStoreStrategy()));
handlers.put("common_obs_spatial.txt",
new CommonObsSpatialBuilder(this));
for (String fileName : handlers.keySet()) {
ingester.registerListener(fileName, this);
}
}
/**
* Setup local FSSObs managers.
*/
private void setupLocalFiles() {
List<FSSObsMonitorConfigurationManager> monitors = new ArrayList<FSSObsMonitorConfigurationManager>();
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.fog));
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.ss));
monitors.add(FSSObsMonitorConfigurationManager
.getInstance(MonName.snow));
public INationalDatasetSubscriber registerHandler(String fileName,
TableHandler handler) {
handlers.put(fileName, handler);
return ndmIngester.registerListener(fileName, this);
}
/**
@ -140,47 +104,175 @@ public class LocationTablesIngest implements INationalDatasetSubscriber {
*/
@Override
public void notify(String fileName, File file) {
processFile(file);
}
/**
*
* @param file
* @return
*/
public void processFile(File file) {
getHandler(file).processFile(file);
}
/**
* Gets Handler.
*
* @param file
* @return
*/
private TableHandler getHandler(File file) {
TableHandler handler = null;
if (file != null) {
if (handlers != null) {
handler = handlers.get(file.getName());
if (handler == null) {
handler = DEFAULT_HANDLER;
}
} else {
handler = DEFAULT_HANDLER;
}
if (handlers.containsKey(fileName)) {
processFile(file);
} else {
handler = DEFAULT_HANDLER;
logger.warn("No handler exists for file [" + fileName + "]");
}
return handler;
}
/**
* Gets Handlers.
*
* @return handlers
* @param file
* @return
*/
public Map<String, TableHandler> getHandlers() {
return handlers;
public synchronized void processFile(File file) {
try {
storeNdmFile(file);
} catch (Exception e) {
logger.error(
"Update of common_obs_spatial cancelled. Failed to store "
+ file.getPath() + " to localization", e);
return;
}
try {
Map<String, ObStationRow> gidMap = new HashMap<String, ObStationRow>();
for (Map.Entry<String, TableHandler> entry : handlers.entrySet()) {
LocalizationFile locFile = getSpatialFile(entry.getKey());
List<ObStationRow> stations = entry.getValue().process(locFile);
if (stations != null) {
addStations(gidMap, stations);
}
}
checkICAOs(gidMap);
// persist the gidMap
ObStationDao dao = new ObStationDao();
LocationTablesProcessor proc = new LocationTablesProcessor(dao,
gidMap);
DatabaseQuery query = new DatabaseQuery(ObStation.class);
dao.processByCriteria(query, proc);
logger.info(String
.format("Processing of file [%s] Complete. Stations Added/Updated/Deleted: [%d/%d/%d]",
file.getName(), proc.getStationsAdded(),
proc.getStationsUpdated(),
proc.getStationsDeleted()));
} catch (Exception e) {
logger.error("Error occurred processing file: " + file.getName(), e);
}
}
protected void addStations(Map<String, ObStationRow> gidMap,
List<ObStationRow> stations) {
for (ObStationRow station : stations) {
if (station != null) {
String key = station.getGid();
if (!gidMap.containsKey(key)) {
gidMap.put(key, station);
}
if (ObStation.CAT_TYPE_SFC_RAOB
.equals(station.getCatalogType())) {
// check for fixed land for this raob
key = ObStation.createGID(ObStation.CAT_TYPE_SFC_FXD,
station.getStationId());
if (gidMap.containsKey(key)) {
ObStationRow aggregate = gidMap.get(key);
aggregate.setUpperAirElevation(station
.getUpperAirElevation());
aggregate.setUpperAirGeometry(station
.getUpperAirGeometry());
if (aggregate.getIcao() == null) {
aggregate.setIcao(station.getIcao());
}
}
} else if (ObStation.CAT_TYPE_SFC_FXD.equals(station
.getCatalogType())) {
// check for raob for this fixed land
key = ObStation.createGID(ObStation.CAT_TYPE_SFC_RAOB,
station.getStationId());
if (gidMap.containsKey(key)) {
ObStationRow aggregate = gidMap.get(key);
station.setUpperAirElevation(aggregate
.getUpperAirElevation());
station.setUpperAirGeometry(aggregate
.getUpperAirGeometry());
if (station.getIcao() == null) {
station.setIcao(aggregate.getIcao());
}
}
}
}
}
}
/**
* Post process all fixed station types and add an associated ICAO entry if
* it doesn't exist.
*/
private void checkICAOs(Map<String, ObStationRow> gidMap) {
List<ObStationRow> newStations = new ArrayList<>();
for (ObStationRow row : gidMap.values()) {
if (ObStation.CAT_TYPE_SFC_FXD.equals(row.getCatalogType())) {
// This synoptic has an associated ICAO, check to see if it is
// in the ICAOs
String icao = row.getIcao();
if (icao != null) {
String key = ObStation.createGID(ObStation.CAT_TYPE_ICAO,
icao);
if (!gidMap.containsKey(key)) {
ObStationRow icaoRow = new ObStationRow(
ObStation.CAT_TYPE_ICAO);
icaoRow.setIcao(icao);
icaoRow.setStationId(icao);
icaoRow.setWmoIndex(row.getWmoIndex());
icaoRow.setWmoRegion(row.getWmoRegion());
icaoRow.setCountry(row.getCountry());
icaoRow.setState(row.getState());
icaoRow.setElevation(row.getElevation());
icaoRow.setLocation(row.getLocation());
newStations.add(icaoRow);
}
}
}
}
for (ObStationRow newStation : newStations) {
gidMap.put(newStation.getGid(), newStation);
}
}
/**
* Store the given ndm file in the localization directory.
*
* @param file
* @throws IOException
* @throws LocalizationException
*/
protected void storeNdmFile(File file) throws IOException,
LocalizationException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = PathManagerFactory.getPathManager()
.getContext(LocalizationType.EDEX_STATIC,
LocalizationLevel.CONFIGURED);
LocalizationFile locFile = pm.getLocalizationFile(context, NDM_LOC_DIR
+ file.getName());
try (SaveableOutputStream out = locFile.openOutputStream();
InputStream in = new FileInputStream(file)) {
FileUtil.copy(in, out);
out.save();
}
}
/**
* Get a list of the lines of the given file.
*
* @param fileName
* @return a list of the lines of the file
*/
protected LocalizationFile getSpatialFile(String fileName) {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationFile file = pm.getStaticLocalizationFile(
LocalizationType.EDEX_STATIC, NDM_LOC_DIR + fileName);
return file;
}
}

View file

@ -0,0 +1,145 @@
/**
* 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.loctables.ingest;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.database.processor.IDatabaseProcessor;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
/**
* Processor for ObStation and ObStationRow differencing. Takes what the
* common_obs_spatial table should be and applies all adds/updates/deletes to
* match the expected view.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 6, 2015 4911 rjpeter Initial creation
* </pre>
*
* @author rjpeter
* @version 1.0
*/
public class LocationTablesProcessor implements IDatabaseProcessor<ObStation> {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ObStationDao dao;
private final Map<String, ObStationRow> gidMap;
private final Set<ObStation> stationsToUpdate = new HashSet<>();
private final Set<ObStation> stationsToDelete = new HashSet<>();
private int batchSize = 100;
private int stationsAdded = 0;
private int stationsUpdated = 0;
private int stationsDeleted = 0;
public LocationTablesProcessor(ObStationDao dao,
Map<String, ObStationRow> gidMap) {
this.dao = dao;
this.gidMap = gidMap;
}
@Override
public boolean process(ObStation currentStation) throws Exception {
// remove the entry from gidMap so that it won't be further processed
ObStationRow updatedStation = gidMap.remove(currentStation.getGid());
if (updatedStation == null) {
stationsToDelete.add(currentStation);
} else if (updatedStation.requiresUpdate(currentStation)) {
stationsToUpdate.add(currentStation);
}
return true;
}
@SuppressWarnings("unchecked")
@Override
public void finish() throws Exception {
/*
* persist changes, can't be done during process due to clearing of
* hibernate session
*/
for (ObStationRow station : gidMap.values()) {
logger.info("Adding station: " + station.getGid());
dao.create(station.toObStation());
stationsAdded++;
}
for (ObStation station : stationsToUpdate) {
logger.info("Updating station: " + station.getGid());
dao.update(station);
stationsUpdated++;
}
for (ObStation station : stationsToDelete) {
logger.info("Removing station: " + station.getGid());
dao.delete(station);
stationsDeleted++;
}
}
@Override
public int getBatchSize() {
return batchSize;
}
@Override
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
/**
* @return the stationsAdded
*/
public int getStationsAdded() {
return stationsAdded;
}
/**
* @return the stationsUpdated
*/
public int getStationsUpdated() {
return stationsUpdated;
}
/**
* @return the stationsDeleted
*/
public int getStationsDeleted() {
return stationsDeleted;
}
}

View file

@ -1,240 +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.plugin.loctables.util;
import static com.raytheon.uf.common.localization.LocalizationContext.LocalizationType.EDEX_STATIC;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.edex.plugin.loctables.ingest.LocationTablesIngest;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.AbstractTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 19, 2010 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class CommonObsSpatialBuilder implements TableHandler {
private Log logger = LogFactory.getLog(getClass());
private static final String TABLES_DIR = "spatialTables";
private static final String COS_DIRECTIVE = "COMMON_OBS_SPATIAL";
private static final String COMMON_OBS_SPATIAL = AbstractTableHandler.DIRECTIVE + COS_DIRECTIVE;
private static final Pattern P_DIRECTIVE = Pattern.compile("^" + COMMON_OBS_SPATIAL + "$");
private static final String [] COMMON_TABLES = {
"maritimeStationInfo.txt",
"metarStationInfo.txt", "pirepsTable.txt",
"synopticStationInfo.txt", "raobStationInfo.txt",
"mesonetStationInfo.txt"
};
private LocationTablesIngest ingest = null;
public CommonObsSpatialBuilder(LocationTablesIngest ingestor) {
ingest = ingestor;
}
/**
*
*/
@Override
public String findDirective(String data) {
String directive = null;
Matcher m = P_DIRECTIVE.matcher(data);
if(m.matches()) {
directive = COS_DIRECTIVE;
}
return directive;
}
/**
*
*/
@Override
public void handleDirective(String directive) {
if(COS_DIRECTIVE.equals(directive)) {
processCommonObsSpatial();
}
}
/**
*
*/
@Override
public void processFile(File file) {
logger.info("Creating new CommonObsSpatial files");
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String line = null;
while((line = reader.readLine()) != null) {
handleDirective(findDirective(line));
}
} catch(IOException ioe) {
logger.error("Error processing data", ioe);
} finally {
if(reader != null) {
try {
reader.close();
} catch(IOException ioe) {
logger.error("Error closing file",ioe);
}
}
}
}
/**
* No implementation in the class.
*/
@Override
public ObStationRow parseLine(String data) {
return null;
}
/**
* No implementation in the class.
*/
@Override
public boolean processObStationRow(ObStationRow row) {
return false;
}
@Override
public void setStatus(Integer status) {
}
@Override
public void setErrorPos(Integer pos) {
}
@Override
public void setStatusMsg(String errMsg) {
}
private void processCommonObsSpatial() {
try {
File fileDir = null;
IPathManager manager = PathManagerFactory.getPathManager();
if (manager != null) {
LocalizationContext context = manager.getContext(EDEX_STATIC,
LocalizationLevel.BASE);
if (context != null) {
fileDir = manager.getFile(context, TABLES_DIR);
if (fileDir.exists()) {
for(String table : COMMON_TABLES) {
processTable(fileDir,table);
}
} else {
logger.error("");
}
} else {
logger.error(String.format(" "));
}
} else {
// Could not create PathManager
}
} catch (Exception e) {
logger.error(" ", e);
}
}
private void processTable(File fileDir, String table) {
BufferedReader reader = null;
TableHandler tblStrategy = ingest.getHandlers().get(table);
if (tblStrategy != null) {
try {
File file = new File(fileDir, table);
if (file.exists()) {
reader = new BufferedReader(new FileReader(file));
String line = null;
while ((line = reader.readLine()) != null) {
ObStationRow row = tblStrategy.parseLine(line);
if(row != null) {
System.out.println(row.toSQLInsertString());
}
}
} else {
logger.error("File " + table + " not processed");
}
} catch (Exception e) {
logger.error("Error processing file " + table, e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ioe) {
logger.error(" ", ioe);
}
}
}
} else {
logger.error("No table handler strategy for " + table + " was found");
}
}
public static final void main(String [] args) {
String data = COMMON_OBS_SPATIAL;
Matcher m = P_DIRECTIVE.matcher(data);
if(m.matches()) {
System.out.println("Found directive");
}
}
}

View file

@ -19,78 +19,39 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util;
import java.io.File;
import java.io.IOException;
import java.util.List;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
/**
* TODO Add Description
* Interface for parsing a station file.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 8, 2010 jkorman Initial creation
*
* Apr 8, 2010 jkorman Initial creation
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
*
* @author jkorman
* @version 1.0
* @version 1.0
*/
public interface TableHandler {
/**
* Process a LocalizationFile for all ObStationRow entries.
*
* @param file
*/
void processFile(File file);
/**
*
* @param data
* @param locFile
* @return
* @throws IOException
* @throws LocalizationException
*/
ObStationRow parseLine(String data);
/**
*
* @param row
* @return
*/
boolean processObStationRow(ObStationRow row);
/**
*
* @param data
* @return
*/
String findDirective(String data);
/**
*
* @param data
* @return
*/
void handleDirective(String data);
/**
* Set a status to this handler.
* @param status Current status.
*/
void setStatus(Integer status);
/**
* Set the position of the last error encountered.
* @param pos Position of the last error.
*/
void setErrorPos(Integer pos);
/**
* Set a status message for this handler.
* @param errorMsg The status message to be displayed.
*/
void setStatusMsg(String statusMsg);
List<ObStationRow> process(LocalizationFile locFile) throws IOException,
LocalizationException;
}

View file

@ -20,25 +20,29 @@
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Calendar;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
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.localization.exception.LocalizationException;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Handles parsing of station files. Specific implementation override parseLine
* to handle transformation.
*
* <pre>
*
@ -48,7 +52,7 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
* ------------ ---------- ----------- --------------------------
* Apr 16, 2010 jkorman Initial creation
* Sep 18, 2014 #3627 mapeters Updated deprecated {@link TimeTools} usage.
*
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
* @author jkorman
@ -58,232 +62,127 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
public abstract class AbstractTableHandler implements TableHandler {
public static final int STA_NORMAL = 0;
public static final int ERR_RES_DISPOSED = -100;
public static final String DIRECTIVE_STATUS_DIR = "#!!STATUS_DIR=";
private static Pattern LATLON = Pattern.compile("(\\d{1,3})(( +\\d{2})( +\\d{2})?)?([NESW])");
private static Pattern LATLON = Pattern
.compile("(\\d{1,3})(( +\\d{2})( +\\d{2})?)?([NESW])");
public static final String COMMENT = "#";
public static final String DIRECTIVE = "#!!";
Log logger = LogFactory.getLog(getClass());
private int status = STA_NORMAL;
private int errorPos = -1;
private String statusMessage = null;
private RowStoreStrategy storeStrategy;
protected static final LocalizationContext LOC_CONTEXT = PathManagerFactory
.getPathManager().getContext(LocalizationType.EDEX_STATIC,
LocalizationLevel.CONFIGURED);
protected Logger logger = LoggerFactory.getLogger(getClass());
private PrintStream statusFile = null;
private File processFile = null;
final String handlerName;
/**
*
* @param name
* @param storeStrategy
*/
AbstractTableHandler (String name, RowStoreStrategy storeStrategy) {
AbstractTableHandler(String name) {
handlerName = name;
this.storeStrategy = storeStrategy;
if(storeStrategy != null) {
storeStrategy.setParent(this);
}
}
/**
* Parse a line of data and return an ObStationRow.
*
* @param file
*/
@Override
public void processFile(File file) {
if(file != null) {
logger.info(handlerName + "Handler [" + file.getName() + "]");
BufferedReader reader = null;
try {
processFile = file;
reader = new BufferedReader(new FileReader(file));
String line = null;
while((line = reader.readLine()) != null) {
clearStatus();
try {
// If a directive was found a null reference is returned.
if(findDirective(line) != null) {
ObStationRow row = parseLine(line);
if(!processObStationRow(row)) {
String msg = null;
if(statusMessage != null) {
if(errorPos >= 0) {
msg = statusMessage + " at position " + errorPos;
} else {
msg = statusMessage;
}
} else {
msg = "Error processing [" + line + "]";
}
writeStatus(msg);
} else {
if(statusMessage != null) {
writeStatus(statusMessage);
}
}
}
} catch(Exception e) {
writeStatus("Error processing [" + line + "]", e);
}
}
} catch(IOException ioe) {
logger.error("Error processing " + handlerName + " data", ioe);
} finally {
if(reader != null) {
try {
reader.close();
} catch(IOException ioe) {
logger.error("Error closing " + handlerName + " file",ioe);
}
}
if(statusFile != null) {
statusFile.close();
if(statusFile.checkError()) {
logger.error("Error closing status file");
}
}
}
} else {
logger.error("Cannot process null file reference.");
}
}
/**
* Determine if the specified data is either a directive or comment
* line. Directive data is passed to a specified directive strategy.
* Directive and Comment lines are set to null and returned.
* @param data A potential directive or comment line.
* @return The original data if not a directive or comment, null otherwise.
*/
public String findDirective(String data) {
if(data != null) {
if(data.startsWith(DIRECTIVE)) {
handleDirective(data);
data = null;
} else if(data.startsWith(COMMENT)) {
data = null;
} else if(data.length() == 0) {
data = null;
}
}
return data;
}
/**
* Handle any directives
* @param data A line of data containing a directive.
*/
@Override
public void handleDirective(String data) {
if(data != null) {
if(data.startsWith(DIRECTIVE_STATUS_DIR)) {
String fs = data.substring(DIRECTIVE_STATUS_DIR.length()).trim();
Calendar c = TimeUtil.newGmtCalendar();
fs = String.format("%s.%2$tY%<te%<td%<tH%<tM%<tS.jnl", fs, c);
try {
statusFile = new PrintStream(fs);
} catch(IOException ioe) {
logger.error("Could not create statusFile " + fs);
statusFile = null;
}
}
}
}
/**
*
* @param row
* @param data
* @return
*/
public boolean processObStationRow(ObStationRow row) {
boolean success = false;
if(storeStrategy != null) {
success = storeStrategy.store(row);
abstract protected ObStationRow parseLine(String data);
@Override
public List<ObStationRow> process(LocalizationFile locFile)
throws IOException, LocalizationException {
if (locFile == null) {
logger.error("Cannot process null file reference.");
return null;
}
return success;
List<ObStationRow> rval = new ArrayList<>(5000);
logger.info(handlerName + "Handler [" + locFile + "]");
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
locFile.openInputStream()))) {
String line = null;
while ((line = reader.readLine()) != null) {
if (checkLine(line)) {
ObStationRow row = parseLine(line);
if (row != null) {
rval.add(row);
}
}
}
}
return rval;
}
/**
* Set a status to this handler.
* @param status Current status.
* Determine if the specified data is a valid line. Skips empty and
* commented lines.
*
* @param data
* A line from file
* @return True if line should be parsed, false otherwise.
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* Set the position of the last error encountered.
* @param pos Position of the last error.
*/
public void setErrorPos(Integer pos) {
errorPos = pos;
public boolean checkLine(String data) {
boolean rval = true;
if ((data == null) || data.trim().startsWith(COMMENT)
|| (data.trim().isEmpty())) {
rval = false;
}
return rval;
}
/**
* Set the error message for the last error encountered.
* @param errorMsg The error message to be displayed.
*/
public void setStatusMsg(String statusMsg) {
statusMessage = statusMsg;
}
/**
* Convert a latitude or longitude value in degrees, minutes, seconds (EWNS)
* to a double value.
*
* @param value
* @return
*/
public final Double cvtLatLon(String value) {
Double latlon = null;
if(value != null) {
if (value != null) {
Matcher m = LATLON.matcher(value);
if(m.find()) {
if (m.find()) {
double lalo = -9999;
String s = m.group(1);
lalo = Double.parseDouble(s);
s = m.group(3);
if(s != null) {
double mm = Double.parseDouble(s);
lalo += (mm / 60);
s = m.group(4);
if(s != null) {
mm = Double.parseDouble(s);
lalo += (mm / 3600);
}
}
s = m.group(5);
if("N".equals(s)) {
latlon = lalo;
} else if("E".equals(s)) {
latlon = lalo;
} else if("S".equals(s)) {
latlon = lalo * -1;
} else if("W".equals(s)) {
latlon = lalo * -1;
}
s = m.group(3);
if (s != null) {
double mm = Double.parseDouble(s);
lalo += (mm / 60);
s = m.group(4);
if (s != null) {
mm = Double.parseDouble(s);
lalo += (mm / 3600);
}
}
s = m.group(5);
if ("N".equals(s)) {
latlon = lalo;
} else if ("E".equals(s)) {
latlon = lalo;
} else if ("S".equals(s)) {
latlon = lalo * -1;
} else if ("W".equals(s)) {
latlon = lalo * -1;
}
}
}
return latlon;
}
/**
*
* @param value
@ -293,7 +192,7 @@ public abstract class AbstractTableHandler implements TableHandler {
Integer retValue = null;
try {
retValue = new Integer(value);
} catch(NumberFormatException nfe) {
} catch (NumberFormatException nfe) {
// Nothing - return null
}
return retValue;
@ -307,7 +206,7 @@ public abstract class AbstractTableHandler implements TableHandler {
*/
public static final Integer getInt(String value, Integer defaultValue) {
Integer retValue = getInt(value);
if(retValue == null) {
if (retValue == null) {
retValue = defaultValue;
}
return retValue;
@ -322,12 +221,12 @@ public abstract class AbstractTableHandler implements TableHandler {
Double retValue = null;
try {
retValue = new Double(value);
} catch(NumberFormatException nfe) {
} catch (NumberFormatException nfe) {
// Nothing - return null
}
return retValue;
}
/**
*
* @param value
@ -335,51 +234,9 @@ public abstract class AbstractTableHandler implements TableHandler {
*/
public static final Double getDouble(String value, Double defaultValue) {
Double retValue = getDouble(value);
if(retValue == null) {
if (retValue == null) {
retValue = defaultValue;
}
return retValue;
}
/**
* Write a status message to the status file only if the status file
* has been opened.
* @param message A status message to write.
*/
private void writeStatus(String message) {
if(status < STA_NORMAL) {
logger.error(message);
} else {
logger.info(message);
}
if(statusFile != null) {
statusFile.println(message);
}
}
/**
* Write a status message to the status file only if the status file
* has been opened.
* @param message A status message to write.
*/
private void writeStatus(String message, Throwable t) {
if(status < STA_NORMAL) {
logger.error(message, t);
} else {
logger.info(message, t);
}
if(statusFile != null) {
statusFile.println(message + " " + t);
}
}
/**
* Reset the status to normal.
*/
public void clearStatus() {
status = STA_NORMAL;
statusMessage = null;
errorPos = -1;
}
}

View file

@ -1,69 +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.plugin.loctables.util.handlers;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 8, 2010 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class DefaultHandler extends AbstractTableHandler {
protected Log logger = LogFactory.getLog(getClass());
public DefaultHandler() {
super("DefaultHandler", null);
}
@Override
public void processFile(File file) {
logger.info("No handler exists for file [" + file.getName() + "]");
}
/**
*
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
return null;
}
}

View file

@ -19,29 +19,21 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Parses station data from maritime and CMAN station files.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 8, 2010 jkorman Initial creation
*
* Apr 8, 2010 jkorman Initial creation
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
* @author jkorman
@ -49,68 +41,67 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
*/
public class MaritimeTableHandler extends AbstractTableHandler {
private final Pattern NUMERIC = Pattern.compile("\\d{5}");
private Log logger = LogFactory.getLog(getClass());
private Pattern NUMERIC = Pattern.compile("\\d{5}");
/**
*
*/
public MaritimeTableHandler(RowStoreStrategy storeStrategy) {
super("MaritimeTable", storeStrategy);
public MaritimeTableHandler() {
super("MaritimeTable");
}
/**
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
// 11111111112222222222333333333344444444445555555555666666666677777777778888888888
// 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
// 0000000000|41001| 34.679| -72.637| 0|6N13 /D E HATTERAS |US|BOY
// 0000000000|41002| 32.281| -75.202| 0|6N35 /D S HATTERAS |US|BOY
/**
* <pre>
* 11111111112222222222333333333344444444445555555555666666666677777777778888888888
* 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
* 0000000000|41001| 34.679| -72.637| 0|6N13 /D E HATTERAS |US|BOY
* 0000000000|41002| 32.281| -75.202| 0|6N35 /D S HATTERAS |US|BOY
* </pre>
*/
ObStationRow row = null;
if((data != null)&&(data.length() > 79)) {
String s = data.substring(11,16).trim();
if ((data != null) && (data.length() > 79)) {
String s = data.substring(11, 16).trim();
String t = data.substring(80).trim();
if((s.length() > 0)&&(t.length() > 0)) {
if("BOY".equals(t)) {
if ((s.length() > 0) && (t.length() > 0)) {
if ("BOY".equals(t)) {
row = new ObStationRow(ObStation.CAT_TYPE_BUOY_FXD);
if(NUMERIC.matcher(s).matches()) {
if (NUMERIC.matcher(s).matches()) {
row.setWmoIndex(new Integer(s));
}
} else if("CMAN".equals(t)) {
} else if ("CMAN".equals(t)) {
row = new ObStationRow(ObStation.CAT_TYPE_CMAN);
}
row.setStationId(s);
if(row != null) {
s = data.substring(17,24).trim();
if (row != null) {
s = data.substring(17, 24).trim();
double lat = Double.parseDouble(s);
s = data.substring(25,33).trim();
s = data.substring(25, 33).trim();
double lon = Double.parseDouble(s);
row.setLocation(ObStationRow.getPoint(lat, lon));
s = data.substring(34,39).trim();
if("-0".equals(s)) {
s = data.substring(34, 39).trim();
if ("-0".equals(s)) {
// Unknown station height. we'll deal with this later.
} else {
if(s.length() > 0) {
Integer elev = new Integer(s);
row.setElevation(elev);
}
} else if (!s.isEmpty()) {
Integer elev = new Integer(s);
row.setElevation(elev);
}
s = data.substring(40,76).trim();
if(s.length() > 0) {
s = data.substring(40, 76).trim();
if (!s.isEmpty()) {
row.setName(s);
}
s = data.substring(77,79).trim();
if(s.length() > 0) {
s = data.substring(77, 79).trim();
if (!s.isEmpty()) {
row.setCountry(s);
}
}
@ -118,31 +109,4 @@ public class MaritimeTableHandler extends AbstractTableHandler {
}
return row;
}
public static final void main(String [] args) {
File file = new File("./utility/edex_static/base/spatialTables/CMANStationInfo.txt");
File fout = new File("./utility/edex_static/base/spatialTables");
RowStoreStrategy out = null;
try {
out = new PrintStreamStoreStrategy(fout,"common_obs_spatial","sql",4000);
TableHandler handler = new MaritimeTableHandler(out);
handler.processFile(file);
} catch(Exception e) {
} finally {
if(out != null) {
try {
out.close();
} catch(IOException ioe) {
}
}
}
}
}

View file

@ -19,39 +19,27 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.File;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Parses station data from the mesonet station file.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 24, 2011 skorolev Initial creation
*
* Aug 24, 2011 skorolev Initial creation
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
*
* @author skorolev
* @version 1.0
* @version 1.0
*/
public class MesonetTableHandler extends AbstractTableHandler {
private Log logger = LogFactory.getLog(getClass());
private static final String DELIMITER = "\\|";
@ -59,25 +47,22 @@ public class MesonetTableHandler extends AbstractTableHandler {
* @param name
* @param storeStrategy
*/
public MesonetTableHandler(RowStoreStrategy storeStrategy) {
super("MesonetTable", storeStrategy);
public MesonetTableHandler() {
super("MesonetTable");
}
/* (non-Javadoc)
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
// 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
// AALND|AALND|Austin Academy For Excellen Garland, TX| 107.620|
// 33.5108| -94.5753|CST6CDT |||1|||TX|
/**
* <pre>
* AALND|AALND|Austin Academy For Excellen Garland, TX| 107.620| 33.5108| -94.5753|CST6CDT |||1|||TX
* </pre>
*/
ObStationRow row = null;
if (data != null) {
// System.out.println(data);
row = new ObStationRow(ObStation.CAT_TYPE_MESONET);
String[] s = data.split(DELIMITER);
row.setStationId(s[1]);
// row.setIcao(icao);
double lat = Double.parseDouble(s[4].trim());
double lon = Double.parseDouble(s[5].trim());
@ -87,42 +72,7 @@ public class MesonetTableHandler extends AbstractTableHandler {
row.setName(s[2].trim());
row.setState(s[12]);
row.setCountry("US");
// row.setWmoIndex(wmoIndex);
// row.setWmoRegion(wmoRegion);
}
}
return row;
}
/**
* @param args
*/
public static void main(String[] args) {
File file = new File(
"./utility/edex_static/base/spatialTables/mesonetStationInfo.txt");
File fout = new File("./utility/edex_static/base/spatialTables");
RowStoreStrategy out = null;
try {
out = new PrintStreamStoreStrategy(fout, "common_obs_spatial",
"sql", 4000);
TableHandler handler = new MesonetTableHandler(out);
handler.processFile(file);
} catch (Exception e) {
} finally {
if (out != null) {
try {
out.close();
} catch (IOException ioe) {
}
}
}
}
}

View file

@ -19,98 +19,88 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.File;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Parses station data from the metar station file.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 20, 2010 jkorman Initial creation
*
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
*
* @author jkorman
* @version 1.0
* @version 1.0
*/
public class MetarTableHandler extends AbstractTableHandler {
private Log logger = LogFactory.getLog(getClass());
/**
*
*/
public MetarTableHandler(RowStoreStrategy storeStrategy) {
super("MetarTable", storeStrategy);
public MetarTableHandler() {
super("MetarTable");
}
/**
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
// 11111111112222222222333333333344444444445555555555666666666677777777778888888888
// 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
// 0000000000| 5GN | 61.82 |-147.56 | 900|TAHNETA PASS, AK |US|MTR
// 0000070279| 5HN | 60.23 |-146.65 | 56|CAPE HINCHINBROOK, AK |US|MTR
/**
* <pre>
* 0000000000| 5GN | 61.82 |-147.56 | 900|TAHNETA PASS, AK |US|MTR
* 0000070279| 5HN | 60.23 |-146.65 | 56|CAPE HINCHINBROOK, AK |US|MTR
* </pre>
*/
ObStationRow row = null;
if(data != null) {
String [] parts = data.split("\\|");
if(parts.length == 8) {
String s = parts[1].trim();
if(s.length() > 0) {
if (data != null) {
String[] parts = data.split("\\|");
if (parts.length == 8) {
String s = parts[1].trim();
if (!s.isEmpty()) {
row = new ObStationRow(ObStation.CAT_TYPE_ICAO);
row.setStationId(s);
row.setIcao(s);
StringBuilder sb = new StringBuilder(parts[0]);
for(int i = 0;i < sb.length();i++) {
if(sb.charAt(i) == '0') {
for (int i = 0; i < sb.length(); i++) {
if (sb.charAt(i) == '0') {
sb.setCharAt(i, ' ');
} else {
break;
}
}
s = sb.toString().trim();
if(s.length() > 0) {
if (!s.isEmpty()) {
Integer wmo = getInt(s, -1);
if(wmo >= 0) {
if (wmo >= 0) {
row.setWmoIndex(wmo);
}
}
Double lat = getDouble(parts[2].trim(), null);
Double lon = getDouble(parts[3].trim(), null);
if(lat != null && lon != null) {
if ((lat != null) && (lon != null)) {
row.setLocation(ObStationRow.getPoint(lat, lon));
s = parts[4].trim();
if(s.length() > 0) {
if (!s.isEmpty()) {
Integer elev = new Integer(s);
row.setElevation(elev);
}
s = parts[5].trim();
if(s.length() > 0) {
if (!s.isEmpty()) {
row.setName(s);
}
s = parts[6].trim();
if(s.length() > 0) {
if (!s.isEmpty()) {
row.setCountry(s);
}
} else {
@ -121,63 +111,4 @@ public class MetarTableHandler extends AbstractTableHandler {
}
return row;
}
public static final void main(String [] args) {
// File file = new File("./utility/edex_static/base/spatialTables/metarStationInfo.txt");
// File fout = new File("./utility/edex_static/base/spatialTables");
//
//
// RowStoreStrategy out = null;
// try {
// out = new PrintStreamStoreStrategy(fout,"common_obs_spatial","sql",4000);
//
// TableHandler handler = new MetarTableHandler(out);
//
// handler.processFile(file);
//
// } catch(Exception e) {
//
// } finally {
// if(out != null) {
// try {
// out.close();
// } catch(IOException ioe) {
//
// }
// }
// }
RowStoreStrategy out = null;
try {
out = new PrintStreamStoreStrategy(System.out);
TableHandler handler = new MetarTableHandler(out);
ObStationRow row = handler.parseLine("000070279| 5HN | 60.23 |-146.65 | 56|CAPE HINCHINBROOK, AK |US|MTR");
System.out.println(row);
} catch(Exception e) {
} finally {
if(out != null) {
try {
out.close();
} catch(IOException ioe) {
}
}
}
String [] parts = "000070279| 5HN | 60.23 |-146.65 | 56|CAPE HINCHINBROOK, AK |US|MTR".split("\\|");
for(String s : parts) {
System.out.println(s);
}
}
}

View file

@ -19,45 +19,34 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Parses station data from the pirep station file.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 8, 2010 jkorman Initial creation
*
* Apr 8, 2010 jkorman Initial creation
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
*
* @author jkorman
* @version 1.0
* @version 1.0
*/
public class PirepTableHandler extends AbstractTableHandler {
private Log logger = LogFactory.getLog(getClass());
/**
*
*/
public PirepTableHandler(RowStoreStrategy storeStrategy) {
super("PirepTable", storeStrategy);
public PirepTableHandler() {
super("PirepTable");
}
/**
*
* @param data
@ -65,51 +54,45 @@ public class PirepTableHandler extends AbstractTableHandler {
*/
@Override
public ObStationRow parseLine(String data) {
// 1111111111222222222233333333334444444444555555555566666666667777777777
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789
// AAO 0 WICHITA KS US 3775 -9722 0 0
/**
* <pre>
* 1111111111222222222233333333334444444444555555555566666666667777777777
* 01234567890123456789012345678901234567890123456789012345678901234567890123456789
* AAO 0 WICHITA KS US 3775 -9722 0 0
* </pre>
*/
ObStationRow row = null;
if((data != null)&&(data.length() > 67)) {
String s = data.substring(0,9).trim();
if(s.length() > 0) {
if ((data != null) && (data.length() > 67)) {
String s = data.substring(0, 9).trim();
if (!s.isEmpty()) {
row = new ObStationRow(ObStation.CAT_TYPE_ACFT_PIREP);
row.setStationId(s);
s = data.substring(16,48).trim();
if(s.length() > 0) {
s = data.substring(16, 48).trim();
if (!s.isEmpty()) {
row.setName(s);
}
s = data.substring(49,51).trim();
if(s.length() > 0) {
s = data.substring(49, 51).trim();
if (!s.isEmpty()) {
row.setState(s);
}
s = data.substring(52,54).trim();
if(s.length() > 0) {
s = data.substring(52, 54).trim();
if (!s.isEmpty()) {
row.setCountry(s);
}
s = data.substring(55,60).trim();
s = data.substring(55, 60).trim();
double lat = Double.parseDouble(s) / 100;
s = data.substring(60,67).trim();
s = data.substring(60, 67).trim();
double lon = Double.parseDouble(s) / 100;
row.setLocation(ObStationRow.getPoint(lat, lon));
}
}
return row;
}
public static final void main(String [] args) {
TableHandler handler = new PirepTableHandler(new PrintStreamStoreStrategy(System.out));
File file = new File("./utility/edex_static/base/spatialTables/pirepsTable.txt");
handler.processFile(file);
}
}

View file

@ -19,69 +19,62 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Parses station data from the raob station file.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 21, 2010 jkorman Initial creation
*
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
*
* @author jkorman
* @version 1.0
* @version 1.0
*/
public class RAOBTableHandler extends AbstractTableHandler {
public class RAOBTableHandler extends AbstractTableHandler {
private static final String SEP = "|";
private Log logger = LogFactory.getLog(getClass());
/**
*
*/
public RAOBTableHandler(RowStoreStrategy storeStrategy) {
super("RAOBTable", storeStrategy);
public RAOBTableHandler() {
super("RAOBTable");
}
/**
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
// 0000004202|BGTL | 76.53333| -68.75000| 77|THULE AB, GREENLAND|GL|RAOB
// 0000008594|GVAC | 16.73300| -22.95000| 55|SAL, CAPE VERDE|CV|RAOB
/**
* <pre>
* 0000004202|BGTL | 76.53333| -68.75000| 77|THULE AB, GREENLAND|GL|RAOB
* 0000008594|GVAC | 16.73300| -22.95000| 55|SAL, CAPE VERDE|CV|RAOB
* </pre>
*/
ObStationRow row = null;
if(data != null) {
List<String> tokens = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(data,SEP,true);
if (data != null) {
List<String> tokens = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(data, SEP, true);
String lastToken = null;
while(st.hasMoreTokens()) {
while (st.hasMoreTokens()) {
String token = st.nextToken();
if(SEP.equals(token)) {
if(SEP.equals(lastToken)) {
if (SEP.equals(token)) {
if (SEP.equals(lastToken)) {
tokens.add("");
}
} else {
@ -89,17 +82,17 @@ public class RAOBTableHandler extends AbstractTableHandler {
}
lastToken = token;
}
if(tokens.size() == 8) {
if (tokens.size() >= 7) {
Integer wmo = new Integer(tokens.get(0));
if(wmo != null) {
if (wmo != null) {
row = new ObStationRow(ObStation.CAT_TYPE_SFC_RAOB);
row.setWmoIndex(wmo);
row.setStationId(String.format("%05d",wmo));
row.setStationId(String.format("%05d", wmo));
row.setIcao(tokens.get(1));
row.setUpperAirElevation(new Integer(tokens.get(4)));
Double lat = new Double(tokens.get(2));
Double lon = new Double(tokens.get(3));
if((lat != null)&&(lon != null)) {
if ((lat != null) && (lon != null)) {
row.setUpperAirGeometry(ObStationRow.getPoint(lat, lon));
row.setName(tokens.get(5));
row.setCountry(tokens.get(6));
@ -108,37 +101,10 @@ public class RAOBTableHandler extends AbstractTableHandler {
}
}
} else {
System.out.println(tokens);
logger.error("Skipping line [" + data
+ "], not enough tokens to parse");
}
}
return row;
}
public static final void main(String [] args) {
File file = new File("./utility/edex_static/base/spatialTables/raobStationInfo.txt");
File fout = new File("./utility/edex_static/base/spatialTables");
RowStoreStrategy out = null;
try {
out = new PrintStreamStoreStrategy(fout,"common_obs_spatial","sql",4000);
TableHandler handler = new RAOBTableHandler(out);
handler.processFile(file);
} catch(Exception e) {
} finally {
if(out != null) {
try {
out.close();
} catch(IOException ioe) {
}
}
}
}
}

View file

@ -19,134 +19,136 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.handlers;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
* Parses station data from the synoptic station file.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 20, 2010 jkorman Initial creation
*
* Oct 12, 2015 4911 rjpeter Refactored.
* </pre>
*
*
* @author jkorman
* @version 1.0
* @version 1.0
*/
public class SynopticLandTableHandler extends AbstractTableHandler {
public static final String FILE = "synopticStationTable.txt";
private static final String UNKN_ICAO = "9999";
// ENJA 010010 JAN_MAYEN(NOR-NAVY) NO 7093 -867 9 046
// ENJA 010010 JAN_MAYEN(NOR-NAVY) NO 7093 -867 9 046
private static final int POS_ICAO = 0;
private static final int POS_WMO = 9;
private static final int POS_NAME = 16;
private static final int POS_COUNTRY = 52;
private static final int POS_LAT = 55;
private static final int POS_LON = 60;
private static final int POS_ELEV = 67;
private static final int POS_WMO_REGION = 77;
private static final int END_ICAO = 4;
private static final int END_WMO = 14;
private static final int END_NAME = 52;
private static final int END_COUNTRY = 54;
private static final int END_LAT = 60;
private static final int END_LON = 67;
private static final int END_ELEV = 73;
private static final int END_WMO_REGION = 78;
private Log logger = LogFactory.getLog(getClass());
private Pattern NUMERIC = Pattern.compile("\\d{5}");
private final Pattern NUMERIC = Pattern.compile("\\d{5}");
/**
*
*/
public SynopticLandTableHandler(RowStoreStrategy storeStrategy) {
super("SynopticLandTable", storeStrategy);
public SynopticLandTableHandler() {
super("SynopticLandTable");
}
/**
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
// 11111111112222222222333333333344444444445555555555666666666677777777778888888888
// 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
// ENJA 010010 JAN_MAYEN(NOR-NAVY) NO 7093 -867 9 046
// 9999 010020 VERLEGENHUKEN NO 8002 1625 8 046
/**
* <pre>
* 11111111112222222222333333333344444444445555555555666666666677777777778888888888
* 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
* ENJA 010010 JAN_MAYEN(NOR-NAVY) NO 7093 -867 9 046
* 9999 010020 VERLEGENHUKEN NO 8002 1625 8 046
* </pre>
*/
ObStationRow row = null;
if((data != null)&&(data.length() > 79)) {
if ((data != null) && (data.length() > 79)) {
String s = data.substring(POS_WMO, END_WMO).trim();
if(s.length() > 0) {
if(NUMERIC.matcher(s).matches()) {
if (!s.isEmpty()) {
if (NUMERIC.matcher(s).matches()) {
row = new ObStationRow(ObStation.CAT_TYPE_SFC_FXD);
row.setWmoIndex(getInt(s));
row.setStationId(s);
// Check for and set an associated ICAO identifier
s = data.substring(POS_ICAO,END_ICAO).trim();
if(!UNKN_ICAO.equals(s)) {
s = data.substring(POS_ICAO, END_ICAO).trim();
if (!UNKN_ICAO.equals(s)) {
row.setIcao(s);
}
Double lat = getDouble(data.substring(POS_LAT, END_LAT).trim(), null);
Double lon = getDouble(data.substring(POS_LON, END_LON).trim(), null);
if((lat != null) && (lon != null)) {
row.setLocation(ObStationRow.getPoint(lat / 100.0, lon / 100.0));
Integer elev = getInt(data.substring(POS_ELEV, END_ELEV).trim());
if(elev != null) {
if(elev == -9999) {
Double lat = getDouble(data.substring(POS_LAT, END_LAT)
.trim(), null);
Double lon = getDouble(data.substring(POS_LON, END_LON)
.trim(), null);
if ((lat != null) && (lon != null)) {
row.setLocation(ObStationRow.getPoint(lat / 100.0,
lon / 100.0));
Integer elev = getInt(data
.substring(POS_ELEV, END_ELEV).trim());
if (elev != null) {
if (elev == -9999) {
}
row.setElevation(elev);
} else {
}
s = data.substring(POS_NAME, END_NAME).trim();
if(s.length() > 0) {
if (!s.isEmpty()) {
row.setName(s);
}
s = data.substring(POS_COUNTRY, END_COUNTRY).trim();
if(s.length() > 0) {
if (!s.isEmpty()) {
row.setCountry(s);
}
s = data.substring(POS_WMO_REGION, END_WMO_REGION);
int i = "0123456789".indexOf(s);
if(i > -1) {
if (i > -1) {
row.setWmoRegion(i);
}
} else {
if(lat == null) {
setErrorPos(POS_LAT);
setStatusMsg("Invalid latitude value");
} else if(lon == null) {
setErrorPos(POS_LON);
setStatusMsg("Invalid longitude value");
}
row = null;
}
}
@ -154,30 +156,4 @@ public class SynopticLandTableHandler extends AbstractTableHandler {
}
return row;
}
public static final void main(String [] args) {
File file = new File("./utility/edex_static/base/spatialTables/synopticStationTable.txt");
File fout = new File("./utility/edex_static/base/spatialTables");
RowStoreStrategy out = null;
try {
out = new PrintStreamStoreStrategy(fout,"common_obs_spatial","sql",4000);
TableHandler handler = new SynopticLandTableHandler(out);
handler.processFile(file);
} catch(Exception e) {
} finally {
if(out != null) {
try {
out.close();
} catch(IOException ioe) {
}
}
}
}
}

View file

@ -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.plugin.loctables.util.handlers;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow;
import com.raytheon.uf.edex.plugin.loctables.util.store.PrintStreamStoreStrategy;
import com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 29, 2010 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class WMOPub9SynopticTableHandler extends AbstractTableHandler {
private Log logger = LogFactory.getLog(getClass());
private Pattern NUMERIC = Pattern.compile("\\d{5}");
/**
*
*/
public WMOPub9SynopticTableHandler(RowStoreStrategy storeStrategy) {
super("WMOPub9SynopticTable", storeStrategy);
}
/**
* @see com.raytheon.uf.edex.plugin.loctables.util.TableHandler#parseLine(java.lang.String)
*/
@Override
public ObStationRow parseLine(String data) {
ObStationRow row = null;
if ((data != null) && (data.length() > 79)) {
// Check for the table header. If so, throw it away.
if (!data.startsWith("RegionId")) {
ArrayList<String> tokens = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(data, "\t", true);
String lastToken = null;
String token = null;
while (st.hasMoreTokens()) {
token = st.nextToken();
if ("\t".equals(token)) {
if (token.equals(lastToken)) {
tokens.add("");
}
} else {
tokens.add(token);
}
lastToken = token;
}
// TODO: Change this value!
if(tokens.size() > 10) {
row = new ObStationRow(ObStation.CAT_TYPE_SFC_FXD);
String s = tokens.get(0);
row.setWmoRegion(new Integer(s));
// 1 RegionId
s = tokens.get(1);
// AFRICA / AFRIQUE RegionName
s = tokens.get(2);
// ALGERIA / ALGERIE Country name or area
s = tokens.get(3);
// 1030 Country code
s = tokens.get(4);
// 121 stationId
s = tokens.get(5);
row.setWmoIndex(new Integer(s));
row.setStationId(String.format("%05d",row.getWmoIndex()));
// 60559 IndexNbr
s = tokens.get(6);
// 0 Sub-index number
s = tokens.get(7);
// EL-OUED Station name
s = tokens.get(8);
Double lat = cvtLatLon(s);
// 33 30N Latitude
s = tokens.get(9);
Double lon = cvtLatLon(s);
// 06 47E Longitude
if((lat != null) && (lon != null)) {
row.setLocation(ObStationRow.getPoint(lat, lon));
s = tokens.get(10);
row.setElevation(new Integer(s));
// 69 Elevation
s = tokens.get(11);
// HpFlag (# == approx)
s = tokens.get(12);
// 64 Elevation
s = tokens.get(13);
// HpaFlag (# == approx)
s = tokens.get(14);
// PressureDefId
s = tokens.get(15);
// X SO-1
s = tokens.get(16);
// X SO-2
s = tokens.get(17);
// X SO-3
s = tokens.get(18);
// X SO-4
s = tokens.get(19);
// X SO-5
s = tokens.get(20);
// X SO-6
s = tokens.get(21);
// X SO-7
s = tokens.get(22);
// X SO-8
s = tokens.get(23);
// H00-24 ObsHrs
//*******************************
// X, P, R, W, WP, PR, .
//*******************************
s = tokens.get(24);
// P UA-1
s = tokens.get(25);
// . UA-2
s = tokens.get(26);
// P UA-3
s = tokens.get(27);
// . UA-4
s = tokens.get(28);
// A;CLIMAT(C);EVAP;M/B;METAR;SOILTEMP;SPECI;SUNDUR
} else {
row = null;
}
}
}
}
return row;
}
public static final void main(String [] args) {
Pattern LATLON = Pattern.compile("(\\d{1,3})(( +\\d{2})( +\\d{2})?)?([NESW])");
Matcher m = LATLON.matcher("136 49 31E");
if(m.find()) {
for(int i = 0;i <= m.groupCount();i++) {
System.out.println(m.group(i));
}
}
File file = new File("./utility/edex_static/base/spatialTables/Pub9volA100426.flatfile");
RowStoreStrategy out = null;
try {
out = new PrintStreamStoreStrategy(System.out);
TableHandler handler = new WMOPub9SynopticTableHandler(out);
// WMOPub9SynopticTableHandler handler = new
// WMOPub9SynopticTableHandler(out);
handler.processFile(file);
} catch (Exception e) {
System.out.println("Error processing data");
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (IOException ioe) {
System.out.println("Error closing store strategy");
ioe.printStackTrace();
}
}
}
}
}

View file

@ -1,69 +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.plugin.loctables.util.store;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 23, 2011 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public abstract class AbstractStoreStrategy implements RowStoreStrategy {
private TableHandler parentHandler = null;
/**
* Post status information to the parent handler if it exists.
* @param status The current status, informative status messages
* must be positive value greater than zero (0). Error status must
* be a negative value.
* @param statusMsg A String message describing the status.
*/
public void postStatus(int status, String statusMsg) {
if(parentHandler != null) {
parentHandler.setStatus(status);
parentHandler.setStatusMsg(statusMsg);
}
}
/**
*
* @param handler The handler containing (using) this store strategy.
* @see com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy#setParent(com.raytheon.uf.edex.plugin.loctables.util.TableHandler)
*/
@Override
public void setParent(TableHandler handler) {
parentHandler = handler;
}
}

View file

@ -1,241 +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.plugin.loctables.util.store;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.MaritimeTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.MesonetTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.MetarTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.PirepTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.RAOBTableHandler;
import com.raytheon.uf.edex.plugin.loctables.util.handlers.SynopticLandTableHandler;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 21, 2010 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class AggregatorStoreStrategy extends PrintStreamStoreStrategy {
private Map<String,ObStationRow> locMap = new HashMap<String,ObStationRow>();
/**
*
* @param file
*/
public AggregatorStoreStrategy(File file) throws IOException {
super(file);
}
/**
*
* @param file
*/
public AggregatorStoreStrategy(PrintStream stream) {
super(stream);
}
/**
*
* @param file
*/
public AggregatorStoreStrategy(File path, String name, String ext, int breakFile) {
super(path, name, ext, breakFile);
}
/**
*
* @param row
* @return Was the store successful.
* @see com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy#store(com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow)
*/
@Override
public boolean store(ObStationRow row) {
boolean stored = false;
String key = null;
if(row != null) {
// We may want to fold raob and synoptic surface.
if (ObStation.CAT_TYPE_SFC_RAOB.equals(row.getCatalogType())) {
key = ObStation.createGID(ObStation.CAT_TYPE_SFC_FXD, row.getStationId());
if (locMap.containsKey(key)) {
ObStationRow aggregate = locMap.get(key);
aggregate.setUpperAirElevation(row.getUpperAirElevation());
aggregate.setUpperAirGeometry(row.getUpperAirGeometry());
if (aggregate.getIcao() == null) {
aggregate.setIcao(row.getIcao());
}
}
// There wasn't a land synoptic site for this id.
key = row.getGid();
if (!locMap.containsKey(key)) {
locMap.put(key,row);
}
} else if (ObStation.CAT_TYPE_SFC_FXD.equals(row.getCatalogType())) {
key = ObStation.createGID(ObStation.CAT_TYPE_SFC_RAOB, row.getStationId());
if (locMap.containsKey(key)) {
ObStationRow aggregate = locMap.get(key);
row.setUpperAirElevation(aggregate.getUpperAirElevation());
row.setUpperAirGeometry(aggregate.getUpperAirGeometry());
if (row.getIcao() == null) {
row.setIcao(aggregate.getIcao());
}
}
key = row.getGid();
if (!locMap.containsKey(key)) {
locMap.put(key,row);
}
} else {
key = row.getGid();
if (!locMap.containsKey(key)) {
locMap.put(key,row);
}
}
}
return stored;
}
/**
*
*/
private void checkICAOs() {
ArrayList<ObStationRow> rows = new ArrayList<ObStationRow>();
for(ObStationRow row : locMap.values()) {
if (ObStation.CAT_TYPE_SFC_FXD.equals(row.getCatalogType())) {
// This synoptic has an associated ICAO, check to see if it is in the ICAOs
String icao = row.getIcao();
if(icao != null) {
String key = ObStation.createGID(ObStation.CAT_TYPE_ICAO, icao);
if (!locMap.containsKey(key)) {
ObStationRow icaoRow = new ObStationRow(ObStation.CAT_TYPE_ICAO);
icaoRow.setIcao(icao);
icaoRow.setStationId(icao);
icaoRow.setWmoIndex(row.getWmoIndex());
icaoRow.setWmoRegion(row.getWmoRegion());
icaoRow.setCountry(row.getCountry());
icaoRow.setState(row.getState());
icaoRow.setElevation(row.getElevation());
icaoRow.setLocation(row.getLocation());
icaoRow.setRbsnIndicator(row.getRbsnIndicator());
rows.add(icaoRow);
}
}
}
} // for
for(ObStationRow row : rows) {
locMap.put(row.getGid(),row);
}
}
/**
* Closes this aggregator. This method must be called so the
* aggregated row information is written to the output.
* @see java.io.Closeable#close()
*/
@Override
public void close() throws IOException {
// Reconcile some issues.
checkICAOs();
for(ObStationRow row : locMap.values()) {
super.store(row);
}
super.close();
}
public static final void main(String [] args) {
File fileA = new File("./utility/edex_static/base/spatialTables/raobStationInfo.txt");
File fileB = new File("./utility/edex_static/base/spatialTables/CMANStationInfo.txt");
File fileC = new File("./utility/edex_static/base/spatialTables/maritimeStationInfo.txt");
File fileD = new File("./utility/edex_static/base/spatialTables/metarStationInfo.txt");
File fileE = new File("./utility/edex_static/base/spatialTables/pirepsTable.txt");
File fileF = new File("./utility/edex_static/base/spatialTables/synopticStationTable.txt");
File fileG = new File(
"./utility/edex_static/base/spatialTables/mesonetStationInfo.txt");
File fout = new File("./utility/edex_static/base/spatialTables");
RowStoreStrategy out = null;
try {
out = new AggregatorStoreStrategy(fout,"common_obs_spatial_","sql",4000);
TableHandler handler = new RAOBTableHandler(out);
handler.processFile(fileA);
handler = new MaritimeTableHandler(out);
handler.processFile(fileB);
handler = new MaritimeTableHandler(out);
handler.processFile(fileC);
handler = new MetarTableHandler(out);
handler.processFile(fileD);
handler = new PirepTableHandler(out);
handler.processFile(fileE);
handler = new SynopticLandTableHandler(out);
handler.processFile(fileF);
handler = new MesonetTableHandler(out);
handler.processFile(fileG);
} catch(Exception e) {
System.out.println("Error processing data");
e.printStackTrace();
} finally {
if(out != null) {
try {
out.close();
} catch(IOException ioe) {
System.out.println("Error closing store strategy");
ioe.printStackTrace();
}
}
}
}
}

View file

@ -19,14 +19,14 @@
**/
package com.raytheon.uf.edex.plugin.loctables.util.store;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKBWriter;
import com.vividsolutions.jts.io.WKTReader;
/**
* TODO Add Description
* Represents an ObStation
*
* <pre>
*
@ -34,7 +34,7 @@ import com.vividsolutions.jts.io.WKTReader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 14, 2010 jkorman Initial creation
*
* Oct 12, 2015 4911 rjpeter Updated requiresUpdate.
* </pre>
*
* @author jkorman
@ -42,610 +42,379 @@ import com.vividsolutions.jts.io.WKTReader;
*/
public class ObStationRow {
private String icao;
// INSERT INTO common_obs_spatial (
// gid, country, elevation, icao, the_geom, name, rbsnindicator, state,
// upperairelevation, upperairgeom, wmoindex, wmoregion
// ) VALUES (
//
public static final String LEAD_IN = "insert into common_obs_spatial (gid,catalogType,stationId,icao,wmoIndex,wmoRegion,country,state,pressureLevel,aerodromeFlag,rbsnIndicator,elevation,the_geom,upperAirElevation,upperairgeom,name) values (";
private Integer wmoIndex;
public static final String CLOSE = ");";
private String stationId;
public static final String NULL = "NULL";
private Integer catalogType;
private static WKTReader wktReader = new WKTReader();
private String name;
private static WKBWriter wkbWriter = new WKBWriter();
private String country;
private String gid;
private String state;
private String icao;
private Integer wmoRegion;
private Integer wmoIndex;
// Surface observing location elevation
private Integer elevation;
private String stationId;
// Surface observing location latitude/longitude
private Point location;
private Integer catalogType;
// Upperair observing location elevation
private Integer upperAirElevation;
private String rbsnIndicator;
// Upperair observing location latitude/longitude
private Point upperAirGeometry;
private String name;
private String country;
private String state;
private Integer wmoRegion;
// Column(length = 16)
private String pressureLevel;
// Column(length = 1)
private String aerodromeFlag;
// Surface observing location elevation
private Integer elevation;
// Surface observing location latitude/longitude
private Point location;
// Upperair observing location elevation
private Integer upperAirElevation;
// Upperair observing location latitude/longitude
private Point upperAirGeometry;
/**
/**
*
*/
public ObStationRow() {
}
/**
*
* @param catType
*/
public ObStationRow(Integer catType) {
catalogType = catType;
}
/**
* @return the icao
*/
public String getIcao() {
return icao;
}
/**
* @param icao
* the icao to set
*/
public void setIcao(String icao) {
this.icao = icao;
}
/**
* @return the wmoIndex
*/
public Integer getWmoIndex() {
return wmoIndex;
}
/**
* @param wmoIndex
* the wmoIndex to set
*/
public void setWmoIndex(Integer wmoIndex) {
this.wmoIndex = wmoIndex;
}
/**
* @return the stationId
*/
public String getStationId() {
return stationId;
}
/**
* @param stationId
* the stationId to set
*/
public void setStationId(String stationId) {
this.stationId = stationId;
}
/**
* @return the catalogType
*/
public Integer getCatalogType() {
return catalogType;
}
/**
* @param catalogType
* the catalogType to set
*/
public void setCatalogType(Integer catalogType) {
this.catalogType = catalogType;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
if (name != null) {
StringBuilder sb = new StringBuilder(name);
for (int i = 0; i < sb.length(); i++) {
switch (sb.charAt(i)) {
case '\'': {
sb.setCharAt(i, ' ');
break;
}
case '\\': {
sb.setCharAt(i, '/');
break;
}
case ';': {
// This mod is required because the CoreDAO script
// runner splits on semicolons which breaks otherwise
// legal SQL.
sb.setCharAt(i, ':');
break;
}
}
}
name = sb.toString();
}
this.name = name;
}
/**
* @return the country
*/
public String getCountry() {
return country;
}
/**
* @param country
* the country to set
*/
public void setCountry(String country) {
this.country = country;
}
/**
* @return the state
*/
public String getState() {
return state;
}
/**
* @param state
* the state to set
*/
public void setState(String state) {
this.state = state;
}
/**
* @return the wmoRegion
*/
public Integer getWmoRegion() {
return wmoRegion;
}
/**
* @param wmoRegion
* the wmoRegion to set
*/
public void setWmoRegion(Integer wmoRegion) {
this.wmoRegion = wmoRegion;
}
/**
* @return the elevation
*/
public Integer getElevation() {
return elevation;
}
/**
* @param elevation
* the elevation to set
*/
public void setElevation(Integer elevation) {
this.elevation = elevation;
}
/**
* @return the upperAirElevation
*/
public Integer getUpperAirElevation() {
return upperAirElevation;
}
/**
* @param upperAirElevation
* the upperAirElevation to set
*/
public void setUpperAirElevation(Integer upperAirElevation) {
this.upperAirElevation = upperAirElevation;
}
/**
* @return the rbsnIndicator
*/
public String getRbsnIndicator() {
return rbsnIndicator;
}
/**
* @param rbsnIndicator
* the rbsnIndicator to set
*/
public void setRbsnIndicator(String rbsnIndicator) {
this.rbsnIndicator = rbsnIndicator;
}
/**
* @return the upperAirGeometry
*/
public Point getUpperAirGeometry() {
return upperAirGeometry;
}
/**
* @param upperAirGeometry
* the upperAirGeometry to set
*/
public void setUpperAirGeometry(Point upperAirGeometry) {
this.upperAirGeometry = upperAirGeometry;
}
/**
* @return the location
*/
public Point getLocation() {
return location;
}
/**
* @param location
* the location to set
*/
public void setLocation(Point location) {
this.location = location;
}
/**
* @return the gid
*/
public String getGid() {
return ObStation.createGID(catalogType, stationId);
}
/**
* @return the pressureLevel
*/
public String getPressureLevel() {
return pressureLevel;
}
/**
* @param pressureLevel
* the pressureLevel to set
*/
public void setPressureLevel(String pressureLevel) {
this.pressureLevel = pressureLevel;
}
/**
* @return the aerodromeFlag
*/
public String getAerodromeFlag() {
return aerodromeFlag;
}
/**
* @param aerodromeFlag
* the aerodromeFlag to set
*/
public void setAerodromeFlag(String aerodromeFlag) {
this.aerodromeFlag = aerodromeFlag;
}
/**
*
* @param value
* @param format
* @return
*/
private String fromInt(Integer value, String format) {
return (value != null) ? String.format(format, value) : NULL;
}
/**
*
* @param value
* @param format
* @return
*/
private String fromString(String value, String format) {
StringBuilder builder = null;
if (value != null) {
builder = new StringBuilder("'");
builder.append(String.format(format, value));
builder.append("'");
} else {
builder = new StringBuilder(NULL);
}
return builder.toString();
}
/**
*
* @param geo
* @return
*/
private String fromGeometry(Point geo) {
String geometry = null;
if (geo != null) {
StringBuilder builder = new StringBuilder("'");
builder.append(WKBWriter.bytesToHex(wkbWriter.write(geo)));
builder.append("'");
geometry = builder.toString();
} else {
geometry = NULL;
}
return geometry;
}
public static Point getPoint(double lat, double lon) {
Point geometry = null;
try {
geometry = (Point) wktReader
.read("POINT (" + lon + " " + lat + ")");
} catch (ParseException pe) {
pe.printStackTrace();
}
return geometry;
}
/**
*
* @return
*/
public ObStation toObStation() {
ObStation station = new ObStation();
// gid
station.setGid(getGid());
// catalogType
station.setCatalogType(getCatalogType());
// stationId
station.setStationId(getStationId());
// icao
station.setIcao(getIcao());
// wmoIndex
station.setWmoIndex(getWmoIndex());
// wmoRegion
station.setWmoRegion(getWmoRegion());
// country
station.setCountry(getCountry());
// state
station.setState(getState());
// pressureLevel
station.setPressureLevel(getPressureLevel());
// aerodromeFlag
station.setAerodromeFlag(getAerodromeFlag());
// rbsnIndicator
station.setRbsnIndicator(getRbsnIndicator());
// elevation
station.setElevation(getElevation());
// the_geom
station.setLocation(getLocation());
// upperAirElevation
station.setUpperAirElevation(getUpperAirElevation());
// upperairgeom
station.setUpperAirGeometry(getUpperAirGeometry());
// name
station.setName(getName());
return station;
}
/**
*
* @return
*/
public String toSQLInsertString() {
StringBuilder builder = new StringBuilder(LEAD_IN);
// gid,catalogType,stationId,icao,wmoIndex,wmoRegion,country,state,pressureLevel,aerodromeFlag,rbsnIndicator,elevation,the_geom,upperAirElevation,upperairgeom,name
// gid
builder.append(fromString(getGid(), "%s"));
builder.append(",");
// catalogtype
builder.append(fromInt(getCatalogType(), "%d"));
builder.append(",");
// stationid
builder.append(fromString(getStationId(), "%s"));
builder.append(",");
// icao
builder.append(fromString(getIcao(), "%s"));
builder.append(",");
// wmoindex
builder.append(fromInt(getWmoIndex(), "%d"));
builder.append(",");
// wmoregion
builder.append(fromInt(getWmoRegion(), "%d"));
builder.append(",");
// country
builder.append(fromString(getCountry(), "%s"));
builder.append(",");
// state
builder.append(fromString(getState(), "%s"));
builder.append(",");
// pressureLevel
builder.append(fromString(getPressureLevel(), "%s"));
builder.append(",");
// aerodromeFlag
String s = getAerodromeFlag();
builder.append(("A".equals(s)) ? "'A'" : "' '");
builder.append(",");
// rbsnindicator
s = getAerodromeFlag();
builder.append(("P".equals(s)) ? "'P'" : "' '");
builder.append(",");
// elevation
builder.append(fromInt(getElevation(), "%d"));
builder.append(",");
// the_geom
builder.append(fromGeometry(getLocation()));
builder.append(",");
// upperairelevation
builder.append(fromInt(getUpperAirElevation(), "%d"));
builder.append(",");
// upperairgeom
builder.append(fromGeometry(getUpperAirGeometry()));
builder.append(",");
// name
builder.append(fromString(getName(), "%s"));
builder.append(CLOSE);
return builder.toString();
}
/**
* Determine if a given ObStation instance needs to be updated from a second
* ObStation instance.
*
* @param a
* Target ObStation instance to be updated.
* @param b
* ObStation instance that may contain changes.
* @return Does the ObStation target instance need to be updated.
*/
public static boolean requiresUpdate(ObStation a, ObStation b) {
boolean newStation = false;
if (copyItem(a.getName(), b.getName())) {
a.setName(b.getName());
newStation = true;
}
if (copyItem(a.getCountry(), b.getCountry())) {
a.setCountry(b.getCountry());
newStation = true;
}
if (copyItem(a.getState(), b.getState())) {
a.setState(b.getState());
newStation = true;
}
if (copyItem(a.getWmoRegion(), b.getWmoRegion())) {
a.setWmoRegion(b.getWmoRegion());
newStation = true;
}
if (copyItem(a.getPressureLevel(), b.getPressureLevel())) {
a.setPressureLevel(b.getPressureLevel());
newStation = true;
}
if (copyItem(a.getAerodromeFlag(), b.getAerodromeFlag())) {
a.setAerodromeFlag(b.getAerodromeFlag());
newStation = true;
}
if (copyItem(a.getElevation(), b.getElevation())) {
a.setElevation(b.getElevation());
newStation = true;
}
if (copyItem(a.getUpperAirElevation(), b.getUpperAirElevation())) {
a.setUpperAirElevation(b.getUpperAirElevation());
newStation = true;
}
if (copyItem(a.getRbsnIndicator(), b.getRbsnIndicator())) {
a.setRbsnIndicator(b.getRbsnIndicator());
newStation = true;
}
if (copyItem(a.getUpperAirGeometry(), b.getUpperAirGeometry())) {
a.setUpperAirGeometry(b.getUpperAirGeometry());
newStation = true;
}
if (copyItem(a.getLocation(), b.getLocation())) {
a.setLocation(b.getLocation());
newStation = true;
}
return newStation;
}
private static boolean copyItem(Object a, Object b) {
boolean copy = false;
if ((a == null)) {
copy = (b != null);
} else {
if (b != null) {
if ((a instanceof Point) && (b instanceof Point)) {
Point aa = (Point) a;
Point bb = (Point) b;
copy = (aa.getX() != bb.getX()) || (aa.getY() != bb.getY());
} else {
copy = (!a.equals(b));
}
}
}
return copy;
}
/**
*
* @param args
*/
public static void main(String[] args) {
ObStationRow row = new ObStationRow();
row.setCatalogType(ObStation.CAT_TYPE_ACFT_PIREP);
row.setStationId("KOMA");
row.setIcao("KOMA");
row.setElevation(390);
row.setCountry("US");
row.setState("NE");
row.setName("Omaha, NE");
row.setLocation(getPoint(45.2, -103.25));
row.setWmoIndex(72553);
row.setUpperAirElevation(391);
row.setUpperAirGeometry(getPoint(45.5, -103.3));
row.setRbsnIndicator("Y");
row.setAerodromeFlag("A");
System.out.println(row.toSQLInsertString());
}
public ObStationRow() {
}
/**
*
* @param catType
*/
public ObStationRow(Integer catType) {
catalogType = catType;
}
/**
* @return the icao
*/
public String getIcao() {
return icao;
}
/**
* @param icao
* the icao to set
*/
public void setIcao(String icao) {
this.icao = icao;
}
/**
* @return the wmoIndex
*/
public Integer getWmoIndex() {
return wmoIndex;
}
/**
* @param wmoIndex
* the wmoIndex to set
*/
public void setWmoIndex(Integer wmoIndex) {
this.wmoIndex = wmoIndex;
}
/**
* @return the stationId
*/
public String getStationId() {
return stationId;
}
/**
* @param stationId
* the stationId to set
*/
public void setStationId(String stationId) {
this.stationId = stationId;
}
/**
* @return the catalogType
*/
public Integer getCatalogType() {
return catalogType;
}
/**
* @param catalogType
* the catalogType to set
*/
public void setCatalogType(Integer catalogType) {
this.catalogType = catalogType;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
if (name != null) {
StringBuilder sb = new StringBuilder(name);
for (int i = 0; i < sb.length(); i++) {
switch (sb.charAt(i)) {
case '\'': {
sb.setCharAt(i, ' ');
break;
}
case '\\': {
sb.setCharAt(i, '/');
break;
}
case ';': {
// This mod is required because the CoreDAO script
// runner splits on semicolons which breaks otherwise
// legal SQL.
sb.setCharAt(i, ':');
break;
}
}
}
name = sb.toString();
}
this.name = name;
}
/**
* @return the country
*/
public String getCountry() {
return country;
}
/**
* @param country
* the country to set
*/
public void setCountry(String country) {
this.country = country;
}
/**
* @return the state
*/
public String getState() {
return state;
}
/**
* @param state
* the state to set
*/
public void setState(String state) {
this.state = state;
}
/**
* @return the wmoRegion
*/
public Integer getWmoRegion() {
return wmoRegion;
}
/**
* @param wmoRegion
* the wmoRegion to set
*/
public void setWmoRegion(Integer wmoRegion) {
this.wmoRegion = wmoRegion;
}
/**
* @return the elevation
*/
public Integer getElevation() {
return elevation;
}
/**
* @param elevation
* the elevation to set
*/
public void setElevation(Integer elevation) {
this.elevation = elevation;
}
/**
* @return the upperAirElevation
*/
public Integer getUpperAirElevation() {
return upperAirElevation;
}
/**
* @param upperAirElevation
* the upperAirElevation to set
*/
public void setUpperAirElevation(Integer upperAirElevation) {
this.upperAirElevation = upperAirElevation;
}
/**
* @return the upperAirGeometry
*/
public Point getUpperAirGeometry() {
return upperAirGeometry;
}
/**
* @param upperAirGeometry
* the upperAirGeometry to set
*/
public void setUpperAirGeometry(Point upperAirGeometry) {
this.upperAirGeometry = upperAirGeometry;
}
/**
* @return the location
*/
public Point getLocation() {
return location;
}
/**
* @param location
* the location to set
*/
public void setLocation(Point location) {
this.location = location;
}
/**
* @return the gid
*/
public String getGid() {
return ObStation.createGID(catalogType, stationId);
}
public static Point getPoint(double lat, double lon) {
return new GeometryFactory().createPoint(new Coordinate(MapUtil
.correctLon(lon), MapUtil.correctLat(lat)));
}
/**
*
* @return
*/
public ObStation toObStation() {
ObStation station = new ObStation();
// gid
station.setGid(getGid());
// catalogType
station.setCatalogType(getCatalogType());
// stationId
station.setStationId(getStationId());
// icao
station.setIcao(getIcao());
// wmoIndex
station.setWmoIndex(getWmoIndex());
// wmoRegion
station.setWmoRegion(getWmoRegion());
// country
station.setCountry(getCountry());
// state
station.setState(getState());
// elevation
station.setElevation(getElevation());
// the_geom
station.setLocation(getLocation());
// upperAirElevation
station.setUpperAirElevation(getUpperAirElevation());
// upperairgeom
station.setUpperAirGeometry(getUpperAirGeometry());
// name
station.setName(getName());
return station;
}
/**
* Determine if a given ObStation instance needs to be updated from this
* ObStationRow.
*
* @param station
* Target ObStation instance to be updated.
* @return Does the ObStation target instance need to be updated.
*/
public boolean requiresUpdate(ObStation b) {
boolean newStation = false;
if (copyItem(getName(), b.getName())) {
b.setName(getName());
newStation = true;
}
if (copyItem(getCountry(), b.getCountry())) {
b.setCountry(getCountry());
newStation = true;
}
if (copyItem(getState(), b.getState())) {
b.setState(getState());
newStation = true;
}
if (copyItem(getWmoRegion(), b.getWmoRegion())) {
b.setWmoRegion(getWmoRegion());
newStation = true;
}
if (copyItem(getElevation(), b.getElevation())) {
b.setElevation(getElevation());
newStation = true;
}
if (copyItem(getUpperAirElevation(), b.getUpperAirElevation())) {
b.setUpperAirElevation(getUpperAirElevation());
newStation = true;
}
if (copyItem(getUpperAirGeometry(), b.getUpperAirGeometry())) {
b.setUpperAirGeometry(getUpperAirGeometry());
newStation = true;
}
if (copyItem(getLocation(), b.getLocation())) {
b.setLocation(getLocation());
newStation = true;
}
return newStation;
}
private static boolean copyItem(Object a, Object b) {
boolean copy = false;
if ((a == null)) {
copy = (b != null);
if (copy && (b instanceof String)) {
// null and empty string are the same
copy = !((String) b).trim().isEmpty();
}
} else {
if (b != null) {
if ((a instanceof Point) && (b instanceof Point)) {
Point aa = (Point) a;
Point bb = (Point) b;
copy = (aa.getX() != bb.getX()) || (aa.getY() != bb.getY());
} else {
copy = (!a.equals(b));
}
} else {
if (a instanceof String) {
copy = !((String) a).trim().isEmpty();
} else {
copy = true;
}
}
}
return copy;
}
}

View file

@ -1,132 +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.plugin.loctables.util.store;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2010 jkorman Initial creation
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class ObStationStoreStrategy extends AbstractStoreStrategy {
private static final String SAVE_STATUS = "Saved new common_obs_spatial for gid=[%s]";
private static final String UPDATE_STATUS = "Updated common_obs_spatial for gid=[%s]";
private static final String ERROR_STATUS = "Error updating common_obs_spatial for gid=[%s] ";
private Log logger = LogFactory.getLog(getClass());
private ObStationDao dao = null;
private boolean failed = true;
public ObStationStoreStrategy() {
dao = new ObStationDao();
failed = false;
}
/**
*
* @param row
* @return Was the store successful?
* @see com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy#store(com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow)
*/
@Override
public boolean store(ObStationRow row) {
boolean success = false;
String msg = null;
int status = 0;
if(dao != null) {
if((!failed)&&(row != null)) {
ObStation station = null;
try {
station = dao.queryByGid(row.getGid());
if(station == null) {
// Entry doesn't exist, so create a new station entry
// and save it.
station = row.toObStation();
dao.saveOrUpdate(station);
msg = String.format(SAVE_STATUS, row.getGid());
logger.info(msg);
success = true;
} else {
// Entry exists, see if we need to change it.
if(ObStationRow.requiresUpdate(station,row.toObStation())) {
// station has been updated with change info from row
dao.saveOrUpdate(station);
msg = String.format(UPDATE_STATUS, row.getGid());
logger.info(msg);
success = true;
} else {
success = true;
msg = "No update required for gid=["+ row.getGid() + "]";
}
}
} catch(Exception e) {
msg = String.format(ERROR_STATUS, row.getGid());
logger.info(msg,e);
status = -1;
}
}
} else {
msg = "ERROR:ObStationStoreStrategy.dao is null";
status = -1;
}
if(msg != null) {
postStatus(status,msg);
}
return success;
}
/**
* Close has no behavior in the strategy.
* @see java.io.Closeable#close()
*/
@Override
public void close() throws IOException {
if(dao != null) {
dao = null;
}
}
}

View file

@ -1,180 +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.plugin.loctables.util.store;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 20, 2010 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class PrintStreamStoreStrategy extends AbstractStoreStrategy {
private static final String SUFFIX = "%s%04d.%s";
private Log logger = LogFactory.getLog(getClass());
private File file = null;
private PrintStream pStream = null;
private File path = null;
private String name = null;
private String ext = null;
private int breakFile = -1;
private int lineCount = 0;
private int partCount = 0;
/**
*
* @param file
*/
public PrintStreamStoreStrategy(File file) throws IOException {
pStream = new PrintStream(file);
}
/**
*
* @param file
*/
public PrintStreamStoreStrategy(PrintStream stream) {
pStream = stream;
}
/**
*
* @param file
*/
public PrintStreamStoreStrategy(File path, String name, String ext, int breakFile) {
this.path = path;
this.name = name;
this.ext = ext;
this.breakFile = breakFile;
}
/**
*
* @param row
* @return Was the store successful.
* @see com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy#store(com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow)
*/
@Override
public boolean store(ObStationRow row) {
boolean stored = false;
PrintStream stream = getStream();
if((stream != null)&&(row != null)) {
stream.println(row.toSQLInsertString());
stored = true;
lineCount++;
}
return stored;
}
private void closeStream() throws IOException {
if(pStream != null) {
pStream.close();
}
}
/**
* Closes the currently open PrintStream. If the PrintStream is not
* open, no action occurs.
* @see java.io.Closeable#close()
*/
@Override
public void close() throws IOException {
closeStream();
}
/**
*
* @return
*/
private PrintStream getStream() {
PrintStream stream = null;
if(breakFile > 0) {
if (lineCount > breakFile) {
if (pStream != null) {
try {
closeStream();
} catch(IOException ioe) {
logger.error("Could not close stream", ioe);
}
pStream = null;
}
String s = String.format(SUFFIX, name, partCount++, ext);
file = new File(path, s);
try {
pStream = new PrintStream(file);
} catch (IOException ioe) {
logger.error("Could not create stream for " + file, ioe);
pStream = null;
}
lineCount = 0;
stream = pStream;
} else {
// create the stream if it hasn't been; first write
if (pStream == null) {
String s = String.format(SUFFIX, name, partCount++,
ext);
file = new File(path, s);
try {
pStream = new PrintStream(file);
} catch (IOException ioe) {
logger
.error("Could not create stream for " + file,
ioe);
pStream = null;
}
}
stream = pStream;
}
} else {
stream = pStream;
}
return stream;
}
}

View file

@ -1,68 +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.plugin.loctables.util.store;
import java.io.Closeable;
import com.raytheon.uf.edex.plugin.loctables.util.TableHandler;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2010 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public interface RowStoreStrategy extends Closeable {
/**
*
* @param row
* @return
*/
boolean store(ObStationRow row);
/**
*
* @param handler
*/
void setParent(TableHandler handler);
/**
* Post status information to the parent handler if it exists.
* @param status The current status, informative status messages
* must be positive value greater than zero (0). Error status must
* be a negative value.
* @param statusMsg A String message describing the status.
*/
void postStatus(int status, String statusMsg);
}

View file

@ -1,115 +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.plugin.loctables.util.store;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* The StationIdMap store strategy does not directly store data but allows
* a client to aggregate ObStationRow data for further processing once the
* map has been fully populated.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 21, 2011 jkorman Initial creation
*
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class StationIdMap extends AbstractStoreStrategy implements Iterable<ObStationRow> {
private Map<String,ObStationRow> locMap = new HashMap<String,ObStationRow>();
/**
*
* @see com.raytheon.uf.edex.plugin.loctables.util.store.RowStoreStrategy#store(com.raytheon.uf.edex.plugin.loctables.util.store.ObStationRow)
*/
@Override
public boolean store(ObStationRow row) {
boolean stored = false;
if((locMap != null) && (row != null)) {
System.out.println(row.toSQLInsertString());
if(!locMap.containsKey(row.getGid())) {
locMap.put(row.getGid(),row);
stored = true;
}
}
return stored;
}
/**
* Does the internal map contain a key to the specified row?
* @param row A row that provides the retrieval key.
* @return Returns true if the internal key exists, false otherwise.
*/
public boolean contains(ObStationRow row) {
boolean contained = false;
if((locMap != null) && (row != null)) {
contained = locMap.containsKey(row.getGid());
}
return contained;
}
/**
* Get this maps representation of a given external row.
* @param row A row that provides the retrieval key.
* @return The internal row if it exists, return a null otherwise.
*/
public ObStationRow get(ObStationRow row) {
ObStationRow containedRow = null;
if((locMap != null) && (row != null)) {
containedRow = locMap.get(row.getGid());
}
return containedRow;
}
/**
*
* @see java.io.Closeable#close()
*/
@Override
public void close() throws IOException {
locMap.clear();
locMap = null;
}
/**
* @see java.lang.Iterable#iterator()
*/
@Override
public Iterator<ObStationRow> iterator() {
ArrayList<ObStationRow> intList = new ArrayList<ObStationRow>();
if(locMap != null) {
intList.addAll(locMap.values());
}
return intList.iterator();
}
}

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<requestPatterns xmlns:ns2="group">
<regex>pirepsTable.txt</regex>
<regex>maritimeStationInfo.txt</regex>
<regex>metarStationInfo.txt</regex>
<regex>synopticStationInfo.txt</regex>
<regex>raobStationInfo.txt</regex>
<regex>mesonetStationInfo.txt</regex>
<regex>common_obs_spatial.txt</regex>
</requestPatterns>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -139,7 +139,6 @@ AMT 0 WEST UNION 3886 -8356 0 0
AMW 0 AMES,IA 4203 -9367 0 0
ANA 0 ANAHEIM,CA 3383 -11783 0 0
ANB 0 ANNISTON,AL 3358 -8585 0 0
ANC 0 ANCHORAGE 6115 -15021 0 0
AND 0 ANDERSON COUNTY 3450 -8271 0 0
ANE 0 MINNEAPOLIS,MN 4513 -9322 0 0
ANI 0 ANIAK 6159 -15960 0 0
@ -496,7 +495,6 @@ BTL 0 BATTLE CREEK 4231 -8525 0 0
BTM 0 BUTTE,MT 4595 -11250 0 0
BTN 0 BRITTON 4582 -9775 0 0
BTP 0 BUTLER,PA 4073 -7992 0 0
BTR 0 BATON ROUGE 3049 -9129 0 0
BTS 0 WOOD RIVER 5900 -15855 0 0
BTT 0 BETTLES 6691 -15154 0 0
BTV 0 BURLINGTON 4440 -7318 0 0
@ -2428,6 +2426,7 @@ LSN 0 LOS BANOS,CA 3698 -12088 0 0
LSO 0 KELSO 4616 -12291 0 0
LSQ 0 NEWARK,NJ 4070 -7417 0 0
LST 0 LONE STAR 3293 -9474 0 0
LSU 0 FLYING TIGER 3049 -9129 0 0
LSV 0 NELLIS AFB,NV 3625 -11503 0 0
LSW 0 DETROIT,MI 4223 -8353 0 0
LTA 0 LAKE TAHOE,CA -VOR- 3915 -12023 0 0
@ -3885,6 +3884,7 @@ TDW 0 TRADEWIND ARPT,TX 3518 -10182 0 0
TDZ 0 TOLEDO,OH 4158 -8380 0 0
TEB 0 TETERBORO 4085 -7406 0 0
TEC 0 TECH 3721 -8041 0 0
TED 0 TED AK US 6117 -14996 0 0
TEL 0 TELL CITY 3801 -8669 0 0
TEW 0 MASON MI US 4256 -8442 0 0
TEX 0 TELLURIDE,CO 3807 -10753 0 0

View file

@ -107,7 +107,6 @@
0000061902|FHAW | -7.96667| -14.40000| 79|WIDE AWAKE FIELD|US|RAOB
0000061967|DJDG | -7.30000| 72.40000| 3|DIEGO GARCIA IS.|DG|RAOB
0000070026|PABR | 71.28833|-156.80250| 12|BARROW, AK|US|RAOB
0000070086|PABA | 70.13300|-143.63000| 15|BARTER ISLAND, AK|US|RAOB
0000070133|PAOT | 66.86667|-162.63333| 5|KOTZEBUE, AK|US|RAOB
0000070200|PAOM | 64.51528|-165.44028| 5|NOME, AK|US|RAOB
0000070219|PABE | 60.78333|-161.84417| 36|BETHEL, AK|US|RAOB
@ -115,13 +114,12 @@
0000070261|PAFA | 64.81528|-147.87722| 135|FAIRBANKS, AK|US|RAOB
0000070273|PAFC | 61.15694|-149.98639| 50|ANCHORAGE, AK|US|RAOB
0000070308|PASN | 57.11667|-170.21667| 10|ST. PAUL ISLAND, AK|US|RAOB
0000070316|PACB | 55.20806|-162.72333| 30|COLD BAY, AK|US|RAOB
0000070316|PACD | 55.20806|-162.72333| 30|COLD BAY, AK|US|RAOB
0000070326|PAKN | 58.67944|-156.66833| 15|KING SALMON, AK|US|RAOB
0000070350|PADQ | 57.75000|-152.48333| 4|KODIAK, AK|US|RAOB
0000070361|PAYA | 59.50801|-139.67194| 12|YAKUTAT, AK|US|RAOB
0000070398|PANT | 55.03944|-131.57806| 37|ANNETTE IS, AK|US|RAOB
0000070414|PASY | 52.73000| 174.10000| 39|SHEMYA AFB, AK|US|RAOB
0000070454|70454| 51.88300|-176.65000| 8|ADAK/DAVIS AFB, AK|US|RAOB
0000071043|CYVQ | 65.28000|-126.80000| 60|NORMAN WELLS, NW|CN|RAOB
0000071081|CYUX | 68.78000| -81.25000| 7|HALL BEACH, NU|CN|RAOB
0000071082|CYLT | 82.50000| -62.33000| 66|ALERT, NU|CN|RAOB
@ -222,7 +220,7 @@
0000072659|KABR | 45.45444| -98.41389| 397|ABERDEEN, SD|US|RAOB
0000072662|KUNR | 44.07778|-103.21667| 1027|RAPID CITY, SD|US|RAOB
0000072672|KRIW | 43.06472|-108.47667| 1700|RIVERTON, WY|US|RAOB
0000072681|KBOI | 43.58000|-116.22639| 871|BOISE, ID|US|RAOB
0000072681|KBOI | 43.56760|-116.21120| 872|BOISE, ID|US|RAOB
0000072694|KSLE | 44.91667|-123.00000| 61|SALEM, OR|US|RAOB
0000072712|KCAR | 46.86667| -68.01667| 191|CARIBOU, ME|US|RAOB
0000072747|KINL | 48.56444| -93.39694| 361|INTERNATIONAL FALLS, MN|US|RAOB
@ -262,19 +260,19 @@
0000078016|TXKF | 32.36667| -64.68333| 6|BERMUDA|UK|RAOB
0000078073|MYNN | 25.05000| -77.46667| 2|NASSAU|BA|RAOB
0000078367|MUGM | 19.90000| -75.15000| 32|GUANTANAMO BAY, CU|CU|RAOB
0000078384|MKCG | 19.30000| -81.35000| 2|GRAND CAYMAN, CAYMAN IS|GC|RAOB
0000078384|MWCR | 19.30000| -81.35000| 2|GRAND CAYMAN, CAYMAN IS|GC|RAOB
0000078397|MKJP | 17.93333| -76.78333| 3|KINGSTON, JAMAICA|JM|RAOB
0000078486|MDSD | 18.48333| -69.91667| 14|SANTO DOMINGO, DR|DR|RAOB
0000078526|TJSJ | 18.43083| -65.99167| 3|SAN JUAN, PR|PU|RAOB
0000078583|MZBZ | 17.50000| -88.33333| 5|BELIZE CITY, BELIZE|BH|RAOB
0000078806|MPHO | 8.92000| -79.60000| 5|HOWARD AFB, PM|PM|RAOB
0000078808|MABK | 8.96700| -79.55000| 9|ALBROOK, PANAMA|PM|RAOB
0000078866|MACM | 18.05000| -63.11667| 9|ST. MAARTEN|SM|RAOB
0000078866|TNCM | 18.05000| -63.11667| 9|ST MAARTEN|SM|RAOB
0000078897|TFFR | 16.26700| -61.53300| 11|LE RAISET, GUADELOUPE|WI|RAOB
0000078954|MKPB | 13.06667| -59.50000| 57|BARBADOS|BR|RAOB
0000078970|MKPP | 10.58333| -61.35000| 12|TRINIDAD|TD|RAOB
0000078954|TBPB | 13.06667| -59.50000| 57|BARBADOS|BR|RAOB
0000078970|TTPP | 10.58333| -61.35000| 12|TRINIDAD|TD|RAOB
0000078988|MACC | 12.20000| -68.96667| 62|CURACAO|NA|RAOB
0000080001|MCSP | 12.58333| -81.71667| 6|SAN ANDRES ISLAND|IS|RAOB
0000080001|SKSP | 12.58333| -81.71667| 6|SAN ANDRES ISLAND|IS|RAOB
0000080035|SKRH | 11.53300| -72.93300| 4|RIOHACHA, COLOMBIA|CO|RAOB
0000081405|SOCA | 4.83300| -52.36700| 9|CAYENNE, FRENCH GUIANA|FG|RAOB
0000091066|PMDY | 28.21700|-177.35000| 3|MIDWAY ISLAND (NAVY)|MQ|RAOB
@ -288,8 +286,8 @@
0000091285|PHTO | 19.71667|-155.06667| 10|HILO, HI|US|RAOB
0000091334|PTKK | 7.45528| 151.83639| 3|CHUUK, EAST CAROLINE IS|CI|RAOB
0000091348|PTPN | 6.96667| 158.21667| 39|PONAPE, EAST CAROLINE IS|CI|RAOB
0000091366|PKWA | 8.73333| 167.73333| 8|KEAJALEIN ATOLL|MH|RAOB
0000091376|PMKJ | 7.08694| 171.38750| 3|MAJURO, MARSHALL ISLANDS|MH|RAOB
0000091366|PKWA | 8.73333| 167.73333| 8|KWAJALEIN ATOLL|MH|RAOB
0000091376|PKMR | 7.08694| 171.38750| 3|MAJURO, MARSHALL ISLANDS|MH|RAOB
0000091408|PTRO | 7.33333| 134.48333| 30|KOROR, PALAU ISLANDS|PI|RAOB
0000091413|PTYA | 9.48333| 138.08333| 14|YAP, WEST CAROLINE IS|CI|RAOB
0000091517|AGGH | -9.43300| 160.05000| 56|HONIARA|BP|RAOB