Issue #1815 Move DD phase3 code to 5-Data_Delivery
Change-Id: Ie2b2887c8238e8d2b495e6bdc3ef31499646e425 Former-commit-id: 126661592c42e16a07451868b87a33cff2a89cd1
This commit is contained in:
parent
e4c1e86d55
commit
8956d1ac17
284 changed files with 0 additions and 34981 deletions
|
@ -77,13 +77,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.spatial"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.edex.meteolib"
|
||||
download-size="0"
|
||||
|
|
|
@ -385,13 +385,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.spatial"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.alertmonitor"
|
||||
download-size="0"
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="filter-v_1_0_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="filter-v_1_1_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="gml-v_2_1_2-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="gml-v_3_1_1-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="jaxb2-basics-runtime-0.6.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="kml-v_2_2_0-schema-1.0.3.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="ows-v_1_0_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="ows-v_1_1_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="se-v_1_1_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="sld-v_1_0_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="sld-v_1_1_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="wcs-v_1_1_2-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="wfs-v_1_1_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="wms-v_1_3_0-schema-1.0.2.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="wmts-v_1_0_0-schema-1.0.3.1.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>net.opengis</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,8 +0,0 @@
|
|||
#Fri Jun 08 12:00:15 CDT 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,44 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Opengis
|
||||
Bundle-SymbolicName: net.opengis
|
||||
Bundle-Version: 1.0.2
|
||||
Bundle-ClassPath: filter-v_1_0_0-schema-1.0.2.jar,
|
||||
filter-v_1_1_0-schema-1.0.2.jar,
|
||||
gml-v_2_1_2-schema-1.0.2.jar,
|
||||
gml-v_3_1_1-schema-1.0.2.jar,
|
||||
jaxb2-basics-runtime-0.6.0.jar,
|
||||
kml-v_2_2_0-schema-1.0.3.jar,
|
||||
ows-v_1_0_0-schema-1.0.2.jar,
|
||||
ows-v_1_1_0-schema-1.0.2.jar,
|
||||
se-v_1_1_0-schema-1.0.2.jar,
|
||||
sld-v_1_0_0-schema-1.0.2.jar,
|
||||
sld-v_1_1_0-schema-1.0.2.jar,
|
||||
wcs-v_1_1_2-schema-1.0.2.jar,
|
||||
wfs-v_1_1_0-schema-1.0.2.jar,
|
||||
wms-v_1_3_0-schema-1.0.2.jar,
|
||||
wmts-v_1_0_0-schema-1.0.3.1.jar
|
||||
Export-Package: net.opengis.filter.v_1_0_0,
|
||||
net.opengis.filter.v_1_1_0,
|
||||
net.opengis.gml.v_2_1_2,
|
||||
net.opengis.gml.v_3_1_1,
|
||||
net.opengis.kml.v_2_2_0,
|
||||
net.opengis.ows.v_1_0_0,
|
||||
net.opengis.ows.v_1_1_0,
|
||||
net.opengis.se.v_1_1_0,
|
||||
net.opengis.sld.v_1_0_0,
|
||||
net.opengis.sld.v_1_1_0,
|
||||
net.opengis.wcs.v_1_1_2,
|
||||
net.opengis.wfs.v_1_1_0,
|
||||
net.opengis.wms.v_1_3_0,
|
||||
net.opengis.wmts.v_1_0_0,
|
||||
oasis.names.tc.ciq.xsdschema.xal._2,
|
||||
org.jvnet.jaxb2_commons.i18n,
|
||||
org.jvnet.jaxb2_commons.lang,
|
||||
org.jvnet.jaxb2_commons.locator,
|
||||
org.jvnet.jaxb2_commons.locator.util,
|
||||
org.jvnet.jaxb2_commons.xml.bind,
|
||||
org.jvnet.jaxb2_commons.xml.bind.annotation.adapters,
|
||||
org.w3.smil.v_2_0,
|
||||
org.w3.smil.v_2_0.language
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
@ -1,17 +0,0 @@
|
|||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
filter-v_1_0_0-schema-1.0.2.jar,\
|
||||
filter-v_1_1_0-schema-1.0.2.jar,\
|
||||
gml-v_2_1_2-schema-1.0.2.jar,\
|
||||
gml-v_3_1_1-schema-1.0.2.jar,\
|
||||
jaxb2-basics-runtime-0.6.0.jar,\
|
||||
kml-v_2_2_0-schema-1.0.3.jar,\
|
||||
ows-v_1_0_0-schema-1.0.2.jar,\
|
||||
ows-v_1_1_0-schema-1.0.2.jar,\
|
||||
se-v_1_1_0-schema-1.0.2.jar,\
|
||||
sld-v_1_0_0-schema-1.0.2.jar,\
|
||||
sld-v_1_1_0-schema-1.0.2.jar,\
|
||||
wcs-v_1_1_2-schema-1.0.2.jar,\
|
||||
wfs-v_1_1_0-schema-1.0.2.jar,\
|
||||
wms-v_1_3_0-schema-1.0.2.jar,\
|
||||
wmts-v_1_0_0-schema-1.0.3.1.jar
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="ogc-tools-gml-jts-1.0.2.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ogc.tools.gml</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,8 +0,0 @@
|
|||
#Fri Jun 08 11:56:09 CDT 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,11 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: ogc.tools.gml
|
||||
Bundle-SymbolicName: ogc.tools.gml
|
||||
Bundle-Version: 1.0.2
|
||||
Bundle-ClassPath: ogc-tools-gml-jts-1.0.2.jar
|
||||
Export-Package: org.jvnet.ogc.gml.v_3_1_1,
|
||||
org.jvnet.ogc.gml.v_3_1_1.jts
|
||||
Require-Bundle: org.geotools;bundle-version="2.6.4",
|
||||
net.opengis;bundle-version="1.0.2"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
@ -1,3 +0,0 @@
|
|||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
ogc-tools-gml-jts-1.0.2.jar
|
Binary file not shown.
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.common.spatial</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,8 +0,0 @@
|
|||
#Thu Dec 02 10:55:26 CST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,16 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: com.raytheon.uf.common.spatial
|
||||
Bundle-SymbolicName: com.raytheon.uf.common.spatial
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Export-Package: com.raytheon.uf.common.spatial.reprojection
|
||||
Require-Bundle: org.apache.commons.lang;bundle-version="2.3.0",
|
||||
org.apache.commons.logging;bundle-version="1.1.1",
|
||||
org.geotools;bundle-version="2.6.4",
|
||||
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.serialization;bundle-version="1.12.1174"
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 15, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
import javax.media.jai.RasterFactory;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.coverage.grid.GridCoverageFactory;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public abstract class AbstractDataReprojector<T extends IDataRecord> {
|
||||
|
||||
public static class RequestWrapper {
|
||||
public Request req;
|
||||
public ReferencedEnvelope env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy data record into geotools grid coverage object
|
||||
*
|
||||
* @param dataRecord
|
||||
* datset
|
||||
* @param env
|
||||
* geographics bounds for dataset
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected abstract GridCoverage2D getGridCoverage(IDataRecord dataRecord,
|
||||
ReferencedEnvelope env) throws Exception;
|
||||
|
||||
/**
|
||||
* Copy data record into geotools grid coverage object
|
||||
*
|
||||
* @param dataRecord
|
||||
* datset
|
||||
* @param env
|
||||
* geographics bounds for dataset
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected abstract GridCoverage2D getMaskCoverage(IDataRecord dataRecord,
|
||||
ReferencedEnvelope env) throws Exception;
|
||||
|
||||
/**
|
||||
* Extract data from geotools coverage object into data record object
|
||||
*
|
||||
* @param coverage
|
||||
* @return
|
||||
*/
|
||||
protected abstract T extractData(GridCoverage2D coverage);
|
||||
|
||||
/**
|
||||
* Extract data from geotools coverage object into data record object with a
|
||||
* mask for covering the non-data area.
|
||||
*
|
||||
* @param coverage
|
||||
* @param maskCoverage
|
||||
* @return
|
||||
*/
|
||||
protected abstract T extractData(GridCoverage2D coverage,
|
||||
GridCoverage2D maskCoverage);
|
||||
|
||||
/**
|
||||
* Apply slab request to data record, returning result in a new data record
|
||||
* object.
|
||||
*
|
||||
* @param dataRecord
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
protected abstract T getDataSlice(IDataRecord dataRecord, Request req);
|
||||
|
||||
/**
|
||||
* @param dataRecord
|
||||
* @return true if this object can operate on native type of data record
|
||||
*/
|
||||
protected abstract boolean compatible(IDataRecord dataRecord);
|
||||
|
||||
/**
|
||||
* Apply point request to data record, returning result in a new data record
|
||||
* object.
|
||||
*
|
||||
* @param record
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
protected abstract IDataRecord getDataPoints(IDataRecord record, Request req);
|
||||
|
||||
/**
|
||||
* Construct a new geotools grid coverage object using data buffer
|
||||
*
|
||||
* @param name
|
||||
* name of coverage
|
||||
* @param data
|
||||
* raw data
|
||||
* @param width
|
||||
* @param height
|
||||
* @param env
|
||||
* geographic bounds of coverage
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static GridCoverage2D constructGridCoverage(String name,
|
||||
DataBuffer data, int width, int height, ReferencedEnvelope env)
|
||||
throws Exception {
|
||||
WritableRaster raster = RasterFactory.createBandedRaster(data, width,
|
||||
height, width, new int[] { 0 }, new int[] { 0 }, null);
|
||||
return new GridCoverageFactory().create(name, raster, env);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,238 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 18, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ByteDataReprojector extends
|
||||
AbstractDataReprojector<ByteDataRecord> {
|
||||
|
||||
protected byte fill = 0;
|
||||
|
||||
protected byte dataMaskValue = -1;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getGridCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env)
|
||||
throws Exception {
|
||||
ByteDataRecord dataRecord = (ByteDataRecord) record;
|
||||
byte[] data = dataRecord.getByteData();
|
||||
DataBufferByte buff = new DataBufferByte(data, data.length);
|
||||
int x = (int) dataRecord.getSizes()[0];
|
||||
int y = (int) dataRecord.getSizes()[1];
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getMaskCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
int x = (int) record.getSizes()[0];
|
||||
int y = (int) record.getSizes()[1];
|
||||
byte[] mask = new byte[x * y];
|
||||
Arrays.fill(mask, dataMaskValue);
|
||||
DataBufferByte buff = new DataBufferByte(mask, mask.length);
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected ByteDataRecord extractData(GridCoverage2D coverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
|
||||
byte[] data = dataBuffer.getData();
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new ByteDataRecord("", "", data, 2, new long[] { width, height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D,
|
||||
* org.geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected ByteDataRecord extractData(GridCoverage2D coverage,
|
||||
GridCoverage2D maskCoverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
|
||||
byte[] data = dataBuffer.getData();
|
||||
|
||||
// Extract mask
|
||||
image = maskCoverage.getRenderedImage();
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
dataBuffer = (DataBufferByte) raster.getDataBuffer();
|
||||
byte[] mask = dataBuffer.getData();
|
||||
|
||||
if (mask.length == data.length) {
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
if (mask[i] != dataMaskValue) {
|
||||
data[i] = fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new ByteDataRecord("", "", data, 2, new long[] { width, height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
|
||||
* .raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* com.raytheon.uf.common.datastorage.Request)
|
||||
*/
|
||||
@Override
|
||||
protected ByteDataRecord getDataSlice(IDataRecord record, Request req) {
|
||||
ByteDataRecord dataRecord = (ByteDataRecord) record;
|
||||
int[] max = req.getMaxIndexForSlab();
|
||||
int[] min = req.getMinIndexForSlab();
|
||||
int toWidth = max[0] - min[0];
|
||||
int toHeight = max[1] - min[1];
|
||||
byte[] from = dataRecord.getByteData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
byte[] to = new byte[toWidth * toHeight];
|
||||
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
|
||||
int toRow = toY * toWidth;
|
||||
int fromRow = fromY * fromWidth;
|
||||
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
|
||||
to[toRow + toX] = from[fromRow + fromX];
|
||||
}
|
||||
}
|
||||
long[] sizes = { toWidth, toHeight };
|
||||
return new ByteDataRecord("", "", to, 2, sizes);
|
||||
}
|
||||
|
||||
public byte getFill() {
|
||||
return fill;
|
||||
}
|
||||
|
||||
public void setFill(byte fill) {
|
||||
this.fill = fill;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
|
||||
*/
|
||||
@Override
|
||||
protected boolean compatible(IDataRecord dataRecord) {
|
||||
return dataRecord instanceof ByteDataRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
|
||||
ByteDataRecord dataRecord = (ByteDataRecord) record;
|
||||
byte[] from = dataRecord.getByteData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
Point[] points = req.getPoints();
|
||||
byte[] to = new byte[points.length];
|
||||
for (int i = 0; i < to.length; ++i) {
|
||||
Point p = points[i];
|
||||
to[i] = from[p.y * fromWidth + p.x];
|
||||
}
|
||||
return new ByteDataRecord("", "", to, 1, new long[] { to.length });
|
||||
}
|
||||
|
||||
}
|
|
@ -1,624 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 18, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.media.jai.Interpolation;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GridCoordinates2D;
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.coverage.grid.ViewType;
|
||||
import org.geotools.coverage.processing.Operations;
|
||||
import org.geotools.geometry.DirectPosition2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.geometry.DirectPosition;
|
||||
import org.opengis.geometry.MismatchedDimensionException;
|
||||
import org.opengis.metadata.spatial.PixelOrientation;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.ReferenceIdentifier;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.operation.MathTransform2D;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector.RequestWrapper;
|
||||
import com.raytheon.uf.common.spatial.reprojection.KeyLocker.KeyLock;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DataReprojector {
|
||||
|
||||
protected IDataStore dataStore;
|
||||
|
||||
protected String dataSetBase = "Data-";
|
||||
|
||||
protected String dataSet = "Data";
|
||||
|
||||
private AbstractDataReprojector<? extends IDataRecord> _typeProjector;
|
||||
|
||||
protected static Log log = LogFactory.getLog(DataReprojector.class);
|
||||
|
||||
protected static KeyLocker locker = new KeyLocker();
|
||||
|
||||
public DataReprojector(IDataStore dataStore) {
|
||||
this.dataStore = dataStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param spatial
|
||||
* spatial object tied to requested dataset
|
||||
* @param nativeEnv
|
||||
* native bounds of dataset
|
||||
* @param crs
|
||||
* desired crs of returned data
|
||||
* @param coords
|
||||
* coordinates of requested data in requested crs
|
||||
* @return null if any of the coordinates are out of the bounds of the grid
|
||||
* geometry
|
||||
* @throws Exception
|
||||
*/
|
||||
public IDataRecord getProjectedPoints(String group, ISpatialObject spatial,
|
||||
ReferencedEnvelope nativeEnv, CoordinateReferenceSystem crs,
|
||||
Coordinate[] coords) throws Exception {
|
||||
// get envelope in requested projection
|
||||
ReferencedEnvelope targetEnv = nativeEnv.transform(crs, true);
|
||||
// get target grid geometry
|
||||
GridGeometry2D geom = getGridGeometry(targetEnv, spatial.getNx(),
|
||||
spatial.getNy());
|
||||
Point[] points = new Point[coords.length];
|
||||
for (int i = 0; i < points.length; ++i) {
|
||||
Coordinate coord = coords[i];
|
||||
GridCoordinates2D point = getGridPoint(geom, coord);
|
||||
int nx = spatial.getNx();
|
||||
int ny = spatial.getNy();
|
||||
// coordinate was out of bounds, bail
|
||||
if (point.x < 0 || point.x > nx || point.y < 0 || point.y > ny) {
|
||||
return null;
|
||||
}
|
||||
// need to repackage point due to pypies not knowing about
|
||||
// gridcoordinates2d
|
||||
points[i] = new Point(point);
|
||||
}
|
||||
String reprojectedDataset = buildDatasetName(crs);
|
||||
Request req = Request.buildPointRequest(points);
|
||||
return getDataRecordWithReproject(group, reprojectedDataset, spatial,
|
||||
crs, req);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param reprojectedDataset
|
||||
* dataset name for reprojected data
|
||||
* @param spatial
|
||||
* spatial object tied to requested dataset
|
||||
* @param crs
|
||||
* desired crs of returned data
|
||||
* @param req
|
||||
* datastore request object
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected IDataRecord getDataRecordWithReproject(String group,
|
||||
String reprojectedDataset, ISpatialObject spatial,
|
||||
CoordinateReferenceSystem crs, Request req) throws Exception {
|
||||
IDataRecord dataRecord;
|
||||
// check if data has already been reprojected
|
||||
if (!datasetExists(group, reprojectedDataset)) {
|
||||
// it hasn't lock and reproject
|
||||
dataRecord = reprojectLocked(group, reprojectedDataset, spatial,
|
||||
crs, req);
|
||||
} else {
|
||||
// it has, just request the data
|
||||
dataRecord = getDataRecord(group, reprojectedDataset, req);
|
||||
}
|
||||
return dataRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param reprojectedDataset
|
||||
* dataset name for reprojected data
|
||||
* @param spatial
|
||||
* spatial object tied to requested dataset
|
||||
* @param crs
|
||||
* desired crs of returned data
|
||||
* @param req
|
||||
* datastore request object
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected IDataRecord reprojectLocked(String group,
|
||||
String reprojectedDataset, ISpatialObject spatial,
|
||||
CoordinateReferenceSystem crs, Request req) throws Exception {
|
||||
KeyLock lock = null;
|
||||
IDataRecord dataRecord;
|
||||
try {
|
||||
// get reproject lock
|
||||
lock = locker.getLock(group + reprojectedDataset);
|
||||
lock.lock();
|
||||
// recheck that dataset still doesn't exist
|
||||
if (!datasetExists(group, reprojectedDataset)) {
|
||||
// still not there, reproject
|
||||
dataRecord = reprojectAndStore(spatial, group, crs, req);
|
||||
} else {
|
||||
// another thread created it, just grab it
|
||||
dataRecord = getDataRecord(group, reprojectedDataset, req);
|
||||
}
|
||||
lock.unlock();
|
||||
return dataRecord;
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
lock.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* @param dataset
|
||||
* @return true if dataset exists in datastore
|
||||
* @throws FileNotFoundException
|
||||
* @throws StorageException
|
||||
*/
|
||||
protected boolean datasetExists(String group, String dataset)
|
||||
throws FileNotFoundException, StorageException {
|
||||
String[] datasets = dataStore.getDatasets(group);
|
||||
return ArrayUtils.contains(datasets, dataset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param geom
|
||||
* Grid geometry
|
||||
* @param coord
|
||||
* desired geographic coordinate
|
||||
* @return grid point for coordinate
|
||||
* @throws PluginException
|
||||
*/
|
||||
public static GridCoordinates2D getGridPoint(GridGeometry2D geom,
|
||||
Coordinate coord) throws PluginException {
|
||||
DirectPosition src = new DirectPosition2D(coord.x, coord.y);
|
||||
DirectPosition inGrid = new DirectPosition2D();
|
||||
try {
|
||||
MathTransform2D crsToGrid2D = geom
|
||||
.getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
|
||||
crsToGrid2D.transform(src, inGrid);
|
||||
} catch (Exception e) {
|
||||
throw new PluginException("Unable to get grid point for geometry",
|
||||
e);
|
||||
}
|
||||
// floor of grid points should be upper left of pixel
|
||||
int x = (int) Math.floor(inGrid.getOrdinate(0));
|
||||
int y = (int) Math.floor(inGrid.getOrdinate(1));
|
||||
GridCoordinates2D rval = new GridCoordinates2D(x, y);
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param spatial
|
||||
* spatial object tied to requested dataset
|
||||
* @param nativeEnv
|
||||
* native bounds of dataset
|
||||
* @param targetEnv
|
||||
* bounds of requested data
|
||||
* @return null if target envelope is out of bounds for dataset
|
||||
* @throws Exception
|
||||
*/
|
||||
public GridCoverage2D getReprojectedCoverage(String group,
|
||||
ISpatialObject spatial, ReferencedEnvelope nativeEnv,
|
||||
ReferencedEnvelope targetEnv)
|
||||
throws Exception {
|
||||
ReferencedDataRecord rep = getReprojected(group, spatial, nativeEnv,
|
||||
targetEnv);
|
||||
if (rep == null) {
|
||||
return null;
|
||||
}
|
||||
ReferencedEnvelope re = rep.getEnvelope();
|
||||
IDataRecord record = rep.getRecord();
|
||||
return getTypeProjector(record).getGridCoverage(rep.getRecord(), re);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param spatial
|
||||
* spatial object tied to requested dataset
|
||||
* @param nativeEnvelope
|
||||
* native bounds of dataset
|
||||
* @param targetEnvelope
|
||||
* bounds of requested data
|
||||
* @return null if target envelope is out of bounds for dataset
|
||||
* @throws Exception
|
||||
*/
|
||||
public ReferencedDataRecord getReprojected(String group,
|
||||
ISpatialObject spatial, ReferencedEnvelope nativeEnvelope,
|
||||
ReferencedEnvelope targetEnvelope)
|
||||
throws Exception {
|
||||
RequestWrapper req = getRequest(spatial, nativeEnvelope, targetEnvelope);
|
||||
if (req == null) {
|
||||
return null;
|
||||
}
|
||||
CoordinateReferenceSystem targetCrs = targetEnvelope
|
||||
.getCoordinateReferenceSystem();
|
||||
String reprojectedDataset = buildDatasetName(targetCrs);
|
||||
IDataRecord dataRecord = getDataRecordWithReproject(group,
|
||||
reprojectedDataset, spatial, targetCrs, req.req);
|
||||
return new ReferencedDataRecord(dataRecord, req.env);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param targetDataset
|
||||
* dataset name for requested data
|
||||
* @param req
|
||||
* datastore request object
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected IDataRecord getDataRecord(String group, String targetDataset,
|
||||
Request req) throws Exception {
|
||||
IDataRecord rval = dataStore.retrieve(group, targetDataset, req);
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a projector that is compatible with record
|
||||
*
|
||||
* @param record
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
protected AbstractDataReprojector<? extends IDataRecord> getTypeProjector(
|
||||
IDataRecord record) throws Exception {
|
||||
if (_typeProjector == null || !_typeProjector.compatible(record)) {
|
||||
if (record instanceof ByteDataRecord) {
|
||||
_typeProjector = new ByteDataReprojector();
|
||||
} else if (record instanceof FloatDataRecord) {
|
||||
_typeProjector = new FloatDataReprojector();
|
||||
} else if (record instanceof ShortDataRecord) {
|
||||
_typeProjector = new ShortDataReprojector();
|
||||
} else if (record instanceof IntegerDataRecord) {
|
||||
_typeProjector = new IntDataReprojector();
|
||||
} else {
|
||||
throw new Exception("Unsupported data store type");
|
||||
}
|
||||
}
|
||||
return _typeProjector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire coverage from the store and reprojects it. Reprojected
|
||||
* coverage is then stored under a name derived from the projected crs.
|
||||
*
|
||||
* @param spatial
|
||||
* spatial object tied to requested dataset
|
||||
* @param group
|
||||
* name of the datastore group that contains requested dataset
|
||||
* @param targetCRS
|
||||
* desired crs of returned data
|
||||
* @param req
|
||||
* datastore request object
|
||||
* @return datarecord as per the request object
|
||||
* @throws Exception
|
||||
*/
|
||||
protected IDataRecord reprojectAndStore(ISpatialObject spatial,
|
||||
String group, CoordinateReferenceSystem targetCRS, Request req)
|
||||
throws Exception {
|
||||
GridGeometry2D geom = MapUtil.getGridGeometry(spatial);
|
||||
IDataRecord original = getDataRecord(group, dataSet, Request.ALL);
|
||||
ReferencedEnvelope env = new ReferencedEnvelope(geom.getEnvelope());
|
||||
AbstractDataReprojector<? extends IDataRecord> typeProjector = getTypeProjector(original);
|
||||
GridCoverage2D cov = typeProjector.getGridCoverage(original, env);
|
||||
GridCoverage2D reprojected = MapUtil.reprojectCoverage(cov, targetCRS);
|
||||
IDataRecord rval;
|
||||
|
||||
if (typeProjector instanceof FloatDataReprojector) {
|
||||
// TODO So far, the problem that this fixes has only appeared with
|
||||
// float data. If it happens with other data we can change this.
|
||||
GridCoverage2D maskCov = typeProjector.getMaskCoverage(original,
|
||||
env);
|
||||
GridCoverage2D reprojectedMask = (GridCoverage2D) Operations.DEFAULT
|
||||
.resample(maskCov.view(ViewType.GEOPHYSICS), targetCRS,
|
||||
null, Interpolation
|
||||
.getInstance(Interpolation.INTERP_NEAREST));
|
||||
rval = typeProjector.extractData(reprojected, reprojectedMask);
|
||||
} else {
|
||||
rval = typeProjector.extractData(reprojected);
|
||||
}
|
||||
|
||||
rval.setGroup(group);
|
||||
rval.setName(buildDatasetName(targetCRS));
|
||||
dataStore.addDataRecord(rval);
|
||||
dataStore.store();
|
||||
return getDataPerReq(rval, req);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param record
|
||||
* data record containing full coverage
|
||||
* @param req
|
||||
* datastore request object
|
||||
* @return result of applying request object to data record
|
||||
* @throws Exception
|
||||
*/
|
||||
protected IDataRecord getDataPerReq(IDataRecord record, Request req)
|
||||
throws Exception {
|
||||
AbstractDataReprojector<? extends IDataRecord> typeProjector = getTypeProjector(record);
|
||||
IDataRecord rval;
|
||||
switch (req.getType()) {
|
||||
case ALL:
|
||||
rval = record;
|
||||
break;
|
||||
case POINT:
|
||||
rval = typeProjector.getDataPoints(record, req);
|
||||
break;
|
||||
case SLAB:
|
||||
rval = typeProjector.getDataSlice(record, req);
|
||||
break;
|
||||
case XLINE:
|
||||
case YLINE:
|
||||
default:
|
||||
throw new Exception("Data reprojector " + req.getType()
|
||||
+ " not implemented");
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param env
|
||||
* geographic bounds of data
|
||||
* @param nx
|
||||
* length of x axis
|
||||
* @param ny
|
||||
* length of y axis
|
||||
* @return
|
||||
*/
|
||||
public static GridGeometry2D getGridGeometry(ReferencedEnvelope env,
|
||||
int nx, int ny) {
|
||||
// TODO cache
|
||||
GridGeometry2D mapGeom = null;
|
||||
mapGeom = new GridGeometry2D(new GeneralGridEnvelope(
|
||||
new int[] { 0, 0 }, new int[] { nx, ny }, false), env);
|
||||
return mapGeom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up slice request for reprojected dataset
|
||||
*
|
||||
* @param record
|
||||
* @param crs
|
||||
* @param targetEnvelope
|
||||
* bbox in crs
|
||||
* @return null if envelope is outside of data bounds
|
||||
* @throws TransformException
|
||||
* @throws MismatchedDimensionException
|
||||
* @throws FactoryException
|
||||
*/
|
||||
protected RequestWrapper getRequest(ISpatialObject spatial,
|
||||
ReferencedEnvelope nativeEnv, ReferencedEnvelope targetEnvelope)
|
||||
throws MismatchedDimensionException,
|
||||
TransformException, FactoryException {
|
||||
RequestWrapper rval = null;
|
||||
CoordinateReferenceSystem targetCrs = targetEnvelope
|
||||
.getCoordinateReferenceSystem();
|
||||
// get full bounds of reprojected dataset
|
||||
ReferencedEnvelope dataEnv = nativeEnv.transform(targetCrs, true);
|
||||
if (!dataEnv.intersects((Envelope) targetEnvelope)) {
|
||||
// request and data envelopes are disjoint, return null
|
||||
return null;
|
||||
}
|
||||
// get grid geometry for reprojected dataset
|
||||
GridGeometry2D geom = getGridGeometry(dataEnv, spatial.getNx(),
|
||||
spatial.getNy());
|
||||
int[] dims = { spatial.getNx(), spatial.getNy() };
|
||||
if (dataEnv.contains((Envelope) targetEnvelope)) {
|
||||
// requested slice is entirely inside data bounds
|
||||
// build slice based on requested bounds
|
||||
rval = getSubSlice(geom, targetEnvelope, dims);
|
||||
} else {
|
||||
// build slice based on intersection
|
||||
Envelope intersection = targetEnvelope.intersection(dataEnv);
|
||||
rval = getSubSlice(geom, intersection, dims);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param geom
|
||||
* grid geometry for projected dataset
|
||||
* @param env
|
||||
* geographic bounds for slice
|
||||
* @param dims
|
||||
* dimensions of dataset
|
||||
* @return grid slice that corresponds to env
|
||||
* @throws MismatchedDimensionException
|
||||
* @throws TransformException
|
||||
*/
|
||||
protected RequestWrapper getSubSlice(GridGeometry2D geom, Envelope env,
|
||||
int[] dims) throws MismatchedDimensionException, TransformException {
|
||||
RequestWrapper rval = new RequestWrapper();
|
||||
MathTransform2D crsToGrid2D = geom
|
||||
.getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
|
||||
// find a slice that has data for entire envelope (can have extra)
|
||||
int[][] minmax = transformEnv(crsToGrid2D, env, dims);
|
||||
MathTransform2D gridToCrs = crsToGrid2D.inverse();
|
||||
// find an envelope that matches the slice (could be a bit larger than
|
||||
// previous envelope)
|
||||
rval.env = transformGrid(gridToCrs, minmax,
|
||||
geom.getCoordinateReferenceSystem());
|
||||
rval.req = Request.buildSlab(minmax[0], minmax[1]);
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridToCrs
|
||||
* @param minmax
|
||||
* 2d array holding slice
|
||||
* @param crs
|
||||
* @return
|
||||
* @throws MismatchedDimensionException
|
||||
* @throws TransformException
|
||||
*/
|
||||
protected ReferencedEnvelope transformGrid(MathTransform2D gridToCrs,
|
||||
int[][] minmax, CoordinateReferenceSystem crs)
|
||||
throws MismatchedDimensionException, TransformException {
|
||||
int[] min = minmax[0];
|
||||
int[] max = minmax[1];
|
||||
DirectPosition lower = new DirectPosition2D(min[0], min[1]);
|
||||
DirectPosition upper = new DirectPosition2D(max[0], max[1]);
|
||||
DirectPosition lowerCrs = gridToCrs.transform(lower, null);
|
||||
DirectPosition upperCrs = gridToCrs.transform(upper, null);
|
||||
double x0 = lowerCrs.getOrdinate(0);
|
||||
double x1 = upperCrs.getOrdinate(0);
|
||||
// handle y axis flip
|
||||
double y0 = upperCrs.getOrdinate(1);
|
||||
double y1 = lowerCrs.getOrdinate(1);
|
||||
return new ReferencedEnvelope(x0, x1, y0, y1, crs);
|
||||
}
|
||||
|
||||
/**
|
||||
* transforms crs coordinates to grid indexes using given math transform
|
||||
*
|
||||
* @param crsToGrid
|
||||
* @param env
|
||||
* @param dims
|
||||
* max bounds to be limited to
|
||||
* @return an array with [[minx, miny], [maxx, maxy]]
|
||||
* @throws MismatchedDimensionException
|
||||
* @throws TransformException
|
||||
*/
|
||||
protected int[][] transformEnv(MathTransform2D crsToGrid, Envelope env,
|
||||
int[] dims) throws MismatchedDimensionException, TransformException {
|
||||
DirectPosition lower = new DirectPosition2D(env.getMinX(),
|
||||
env.getMinY());
|
||||
DirectPosition upper = new DirectPosition2D(env.getMaxX(),
|
||||
env.getMaxY());
|
||||
DirectPosition lowerGrid = crsToGrid.transform(lower, null);
|
||||
DirectPosition upperGrid = crsToGrid.transform(upper, null);
|
||||
int x0 = (int) Math.floor(lowerGrid.getOrdinate(0));
|
||||
// we want ceiling since slices are inclusive
|
||||
int x1 = (int) Math.ceil(upperGrid.getOrdinate(0));
|
||||
// handle y axis flip
|
||||
int y0 = (int) Math.floor(upperGrid.getOrdinate(1));
|
||||
// we want ceiling since slices are inclusive
|
||||
int y1 = (int) Math.ceil(lowerGrid.getOrdinate(1));
|
||||
// truncate requests to dataset dimensions
|
||||
if (x0 < 0) {
|
||||
x0 = 0;
|
||||
}
|
||||
if (y0 < 0) {
|
||||
y0 = 0;
|
||||
}
|
||||
if (x1 > dims[0]) {
|
||||
x1 = dims[0];
|
||||
}
|
||||
if (y1 > dims[1]) {
|
||||
y1 = dims[1];
|
||||
}
|
||||
return new int[][] { { x0, y0 }, { x1, y1 } };
|
||||
}
|
||||
|
||||
/**
|
||||
* construct the dataset name based on the name of the crs.
|
||||
*
|
||||
* @param crs
|
||||
* @return
|
||||
*/
|
||||
protected String buildDatasetName(CoordinateReferenceSystem crs) {
|
||||
Set<ReferenceIdentifier> ids = crs.getIdentifiers();
|
||||
String code;
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
code = crs.getName().toString();
|
||||
} else {
|
||||
Iterator<ReferenceIdentifier> i = ids.iterator();
|
||||
code = i.next().toString();
|
||||
while (i.hasNext()) {
|
||||
code += "-" + i.next().toString();
|
||||
}
|
||||
}
|
||||
return dataSetBase + code;
|
||||
}
|
||||
|
||||
public IDataStore getDataStore() {
|
||||
return dataStore;
|
||||
}
|
||||
|
||||
public void setDataStore(IDataStore dataStore) {
|
||||
this.dataStore = dataStore;
|
||||
}
|
||||
|
||||
public String getDataSetBase() {
|
||||
return dataSetBase;
|
||||
}
|
||||
|
||||
public void setDataSetBase(String dataSetBase) {
|
||||
this.dataSetBase = dataSetBase;
|
||||
}
|
||||
|
||||
public String getDataSet() {
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
public void setDataSet(String dataSet) {
|
||||
this.dataSet = dataSet;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 13, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.image.DataBufferFloat;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class FloatDataReprojector extends
|
||||
AbstractDataReprojector<FloatDataRecord> {
|
||||
|
||||
protected float fill = -999999.0f;
|
||||
|
||||
protected float dataMaskValue = -0;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getGridCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
FloatDataRecord dataRecord = (FloatDataRecord) record;
|
||||
float[] data = dataRecord.getFloatData();
|
||||
DataBufferFloat buff = new DataBufferFloat(data, data.length);
|
||||
int x = (int) dataRecord.getSizes()[0];
|
||||
int y = (int) dataRecord.getSizes()[1];
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getMaskCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
int x = (int) record.getSizes()[0];
|
||||
int y = (int) record.getSizes()[1];
|
||||
float[] mask = new float[x * y];
|
||||
Arrays.fill(mask, dataMaskValue);
|
||||
DataBufferFloat buff = new DataBufferFloat(mask, mask.length);
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected FloatDataRecord extractData(GridCoverage2D coverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferFloat dataBuffer = (DataBufferFloat) raster.getDataBuffer();
|
||||
float[] data = dataBuffer.getData();
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new FloatDataRecord("", "", data, 2,
|
||||
new long[] { width, height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D,
|
||||
* org.geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected FloatDataRecord extractData(GridCoverage2D coverage,
|
||||
GridCoverage2D maskCoverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferFloat dataBuffer = (DataBufferFloat) raster.getDataBuffer();
|
||||
float[] data = dataBuffer.getData();
|
||||
|
||||
// Extract mask
|
||||
image = maskCoverage.getRenderedImage();
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
dataBuffer = (DataBufferFloat) raster.getDataBuffer();
|
||||
float[] mask = dataBuffer.getData();
|
||||
|
||||
if (mask.length == data.length) {
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
if (mask[i] != dataMaskValue) {
|
||||
data[i] = fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new FloatDataRecord("", "", data, 2,
|
||||
new long[] { width, height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
|
||||
* .raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* com.raytheon.uf.common.datastorage.Request)
|
||||
*/
|
||||
@Override
|
||||
protected FloatDataRecord getDataSlice(IDataRecord record, Request req) {
|
||||
FloatDataRecord dataRecord = (FloatDataRecord) record;
|
||||
int[] max = req.getMaxIndexForSlab();
|
||||
int[] min = req.getMinIndexForSlab();
|
||||
int toWidth = max[0] - min[0];
|
||||
int toHeight = max[1] - min[1];
|
||||
float[] from = dataRecord.getFloatData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
float[] to = new float[toWidth * toHeight];
|
||||
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
|
||||
int toRow = toY * toWidth;
|
||||
int fromRow = fromY * fromWidth;
|
||||
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
|
||||
to[toRow + toX] = from[fromRow + fromX];
|
||||
}
|
||||
}
|
||||
long[] sizes = { toWidth, toHeight };
|
||||
return new FloatDataRecord("", "", to, 2, sizes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fill
|
||||
*/
|
||||
public float getFill() {
|
||||
return fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fill
|
||||
* the fill to set
|
||||
*/
|
||||
public void setFill(float fill) {
|
||||
this.fill = fill;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
|
||||
*/
|
||||
@Override
|
||||
protected boolean compatible(IDataRecord dataRecord) {
|
||||
return dataRecord instanceof FloatDataRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
|
||||
FloatDataRecord dataRecord = (FloatDataRecord) record;
|
||||
float[] from = dataRecord.getFloatData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
Point[] points = req.getPoints();
|
||||
float[] to = new float[points.length];
|
||||
for (int i = 0; i < to.length; ++i) {
|
||||
Point p = points[i];
|
||||
to[i] = from[p.y * fromWidth + p.x];
|
||||
}
|
||||
return new FloatDataRecord("", "", to, 1, new long[] { to.length });
|
||||
}
|
||||
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 13, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class IntDataReprojector extends
|
||||
AbstractDataReprojector<IntegerDataRecord> {
|
||||
|
||||
protected int fill = 0;
|
||||
|
||||
protected int dataMaskValue = -1;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getGridCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
IntegerDataRecord dataRecord = (IntegerDataRecord) record;
|
||||
int[] data = dataRecord.getIntData();
|
||||
DataBuffer buff = new DataBufferInt(data, data.length);
|
||||
int x = (int) dataRecord.getSizes()[0];
|
||||
int y = (int) dataRecord.getSizes()[1];
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getMaskCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
int x = (int) record.getSizes()[0];
|
||||
int y = (int) record.getSizes()[1];
|
||||
int[] mask = new int[x * y];
|
||||
Arrays.fill(mask, dataMaskValue);
|
||||
DataBufferInt buff = new DataBufferInt(mask, mask.length);
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected IntegerDataRecord extractData(GridCoverage2D coverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
|
||||
int[] data = dataBuffer.getData();
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new IntegerDataRecord("", "", data, 2, new long[] { width,
|
||||
height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D,
|
||||
* org.geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected IntegerDataRecord extractData(GridCoverage2D coverage,
|
||||
GridCoverage2D maskCoverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();
|
||||
int[] data = dataBuffer.getData();
|
||||
|
||||
// Extract mask
|
||||
image = maskCoverage.getRenderedImage();
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
dataBuffer = (DataBufferInt) raster.getDataBuffer();
|
||||
int[] mask = dataBuffer.getData();
|
||||
|
||||
if (mask.length == data.length) {
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
if (mask[i] != dataMaskValue) {
|
||||
data[i] = fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new IntegerDataRecord("", "", data, 2, new long[] { width,
|
||||
height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
|
||||
* .raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* com.raytheon.uf.common.datastorage.Request)
|
||||
*/
|
||||
@Override
|
||||
protected IntegerDataRecord getDataSlice(IDataRecord record, Request req) {
|
||||
IntegerDataRecord dataRecord = (IntegerDataRecord) record;
|
||||
int[] max = req.getMaxIndexForSlab();
|
||||
int[] min = req.getMinIndexForSlab();
|
||||
int toWidth = max[0] - min[0];
|
||||
int toHeight = max[1] - min[1];
|
||||
int[] from = dataRecord.getIntData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
int[] to = new int[toWidth * toHeight];
|
||||
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
|
||||
int toRow = toY * toWidth;
|
||||
int fromRow = fromY * fromWidth;
|
||||
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
|
||||
to[toRow + toX] = from[fromRow + fromX];
|
||||
}
|
||||
}
|
||||
long[] sizes = { toWidth, toHeight };
|
||||
return new IntegerDataRecord("", "", to, 2, sizes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fill
|
||||
*/
|
||||
public int getFill() {
|
||||
return fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fill
|
||||
* the fill to set
|
||||
*/
|
||||
public void setFill(int fill) {
|
||||
this.fill = fill;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
|
||||
*/
|
||||
@Override
|
||||
protected boolean compatible(IDataRecord dataRecord) {
|
||||
return dataRecord instanceof IntegerDataRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
|
||||
IntegerDataRecord dataRecord = (IntegerDataRecord) record;
|
||||
int[] from = dataRecord.getIntData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
Point[] points = req.getPoints();
|
||||
int[] to = new int[points.length];
|
||||
for (int i = 0; i < to.length; ++i) {
|
||||
Point p = points[i];
|
||||
to[i] = from[p.y * fromWidth + p.x];
|
||||
}
|
||||
return new IntegerDataRecord("", "", to, 1, new long[] { to.length });
|
||||
}
|
||||
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* Class for managing a pool of concurrency locks organized by string keys.
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class KeyLocker {
|
||||
|
||||
public class KeyLock {
|
||||
private final String key;
|
||||
|
||||
private final Lock lock;
|
||||
|
||||
private boolean released = false;
|
||||
|
||||
public KeyLock(String key, Lock lock) {
|
||||
this.key = key;
|
||||
this.lock = lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
release();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (!this.released) {
|
||||
releaseLock(this.key);
|
||||
this.released = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void lock() {
|
||||
this.lock.lock();
|
||||
}
|
||||
|
||||
public void unlock() {
|
||||
this.lock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class Entry {
|
||||
int count = 0;
|
||||
final Lock lock = new ReentrantLock();
|
||||
}
|
||||
|
||||
private final Map<String, Entry> locks = new HashMap<String, Entry>();
|
||||
|
||||
public KeyLock getLock(String key) {
|
||||
synchronized (locks) {
|
||||
Entry e = locks.get(key);
|
||||
if (e == null) {
|
||||
e = new Entry();
|
||||
locks.put(key, e);
|
||||
}
|
||||
e.count++;
|
||||
return new KeyLock(key, e.lock);
|
||||
}
|
||||
}
|
||||
|
||||
void releaseLock(String key) {
|
||||
synchronized (locks) {
|
||||
Entry e = locks.get(key);
|
||||
if (e != null) {
|
||||
e.count--;
|
||||
if (e.count <= 0) {
|
||||
locks.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 18, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
||||
public class ReferencedDataRecord{
|
||||
|
||||
protected IDataRecord record;
|
||||
|
||||
protected ReferencedEnvelope envelope;
|
||||
|
||||
public ReferencedDataRecord(IDataRecord record, ReferencedEnvelope envlope) {
|
||||
this.record = record;
|
||||
this.envelope = envlope;
|
||||
}
|
||||
|
||||
public IDataRecord getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
public void setRecord(IDataRecord record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
public ReferencedEnvelope getEnvelope() {
|
||||
return envelope;
|
||||
}
|
||||
|
||||
public void setEnvelope(ReferencedEnvelope envelope) {
|
||||
this.envelope = envelope;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,248 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 13, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.common.spatial.reprojection;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferShort;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ShortDataReprojector extends
|
||||
AbstractDataReprojector<ShortDataRecord> {
|
||||
|
||||
protected short fill = 0;
|
||||
|
||||
protected short dataMaskValue = -1;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getGridCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getGridCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
ShortDataRecord dataRecord = (ShortDataRecord) record;
|
||||
short[] data = dataRecord.getShortData();
|
||||
DataBuffer buff = new DataBufferShort(data, data.length);
|
||||
int x = (int) dataRecord.getSizes()[0];
|
||||
int y = (int) dataRecord.getSizes()[1];
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getMaskCoverage
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* org.opengis.referencing.crs.CoordinateReferenceSystem,
|
||||
* org.opengis.geometry.Envelope)
|
||||
*/
|
||||
@Override
|
||||
protected GridCoverage2D getMaskCoverage(IDataRecord record,
|
||||
ReferencedEnvelope env) throws Exception {
|
||||
int x = (int) record.getSizes()[0];
|
||||
int y = (int) record.getSizes()[1];
|
||||
short[] mask = new short[x * y];
|
||||
Arrays.fill(mask, dataMaskValue);
|
||||
DataBufferShort buff = new DataBufferShort(mask, mask.length);
|
||||
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
|
||||
return constructGridCoverage(crs.getName() + " Grid", buff, x, y, env);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected ShortDataRecord extractData(GridCoverage2D coverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferShort dataBuffer = (DataBufferShort) raster.getDataBuffer();
|
||||
short[] data = dataBuffer.getData();
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new ShortDataRecord("", "", data, 2,
|
||||
new long[] { width, height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#extractData(org
|
||||
* .geotools.coverage.grid.GridCoverage2D,
|
||||
* org.geotools.coverage.grid.GridCoverage2D)
|
||||
*/
|
||||
@Override
|
||||
protected ShortDataRecord extractData(GridCoverage2D coverage,
|
||||
GridCoverage2D maskCoverage) {
|
||||
RenderedImage image = coverage.getRenderedImage();
|
||||
Raster raster;
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
DataBufferShort dataBuffer = (DataBufferShort) raster.getDataBuffer();
|
||||
short[] data = dataBuffer.getData();
|
||||
|
||||
// Extract mask
|
||||
image = maskCoverage.getRenderedImage();
|
||||
if (image.getNumXTiles() == 1 && image.getNumYTiles() == 1) {
|
||||
// we can directly access data
|
||||
raster = image.getTile(0, 0);
|
||||
} else {
|
||||
// need to copy data out
|
||||
raster = image.getData();
|
||||
}
|
||||
dataBuffer = (DataBufferShort) raster.getDataBuffer();
|
||||
short[] mask = dataBuffer.getData();
|
||||
|
||||
if (mask.length == data.length) {
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
if (mask[i] != dataMaskValue) {
|
||||
data[i] = fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int height = raster.getHeight();
|
||||
int width = raster.getWidth();
|
||||
return new ShortDataRecord("", "", data, 2,
|
||||
new long[] { width, height });
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.DataReprojector#getDataSlice(com
|
||||
* .raytheon.uf.common.datastorage.records.IDataRecord,
|
||||
* com.raytheon.uf.common.datastorage.Request)
|
||||
*/
|
||||
@Override
|
||||
protected ShortDataRecord getDataSlice(IDataRecord record, Request req) {
|
||||
ShortDataRecord dataRecord = (ShortDataRecord) record;
|
||||
int[] max = req.getMaxIndexForSlab();
|
||||
int[] min = req.getMinIndexForSlab();
|
||||
int toWidth = max[0] - min[0];
|
||||
int toHeight = max[1] - min[1];
|
||||
short[] from = dataRecord.getShortData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
short[] to = new short[toWidth * toHeight];
|
||||
for (int fromY = min[1], toY = 0; fromY < max[1]; ++fromY, ++toY) {
|
||||
int toRow = toY * toWidth;
|
||||
int fromRow = fromY * fromWidth;
|
||||
for (int fromX = min[0], toX = 0; fromX < max[0]; ++fromX, ++toX) {
|
||||
to[toRow + toX] = from[fromRow + fromX];
|
||||
}
|
||||
}
|
||||
long[] sizes = { toWidth, toHeight };
|
||||
return new ShortDataRecord("", "", to, 2, sizes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fill
|
||||
*/
|
||||
public short getFill() {
|
||||
return fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fill
|
||||
* the fill to set
|
||||
*/
|
||||
public void setFill(short fill) {
|
||||
this.fill = fill;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.spatial.reprojection.AbstractDataReprojector#compatible
|
||||
* (com.raytheon.uf.common.datastorage.records.IDataRecord)
|
||||
*/
|
||||
@Override
|
||||
protected boolean compatible(IDataRecord dataRecord) {
|
||||
return dataRecord instanceof ShortDataRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDataRecord getDataPoints(IDataRecord record, Request req) {
|
||||
ShortDataRecord dataRecord = (ShortDataRecord) record;
|
||||
short[] from = dataRecord.getShortData();
|
||||
int fromWidth = (int) dataRecord.getSizes()[0];
|
||||
Point[] points = req.getPoints();
|
||||
short[] to = new short[points.length];
|
||||
for (int i = 0; i < to.length; ++i) {
|
||||
Point p = points[i];
|
||||
to[i] = from[p.y * fromWidth + p.x];
|
||||
}
|
||||
return new ShortDataRecord("", "", to, 1, new long[] { to.length });
|
||||
}
|
||||
|
||||
}
|
|
@ -112,13 +112,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.spatial"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.plugin.nwsauth"
|
||||
download-size="0"
|
||||
|
|
|
@ -31,12 +31,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="net.opengis"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="org.codehaus.jackson"
|
||||
download-size="0"
|
||||
|
@ -56,40 +50,6 @@
|
|||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.edex.ogc.common"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.edex.wms"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="ogc.tools.gml"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.edex.wcs"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.edex.plugin.grib.ogc"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.datadelivery.retrieval"
|
||||
download-size="0"
|
||||
|
@ -167,20 +127,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.edex.wfs"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.edex.plugin.obs.ogc"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.datadelivery.bandwidth"
|
||||
download-size="0"
|
||||
|
|
|
@ -15,8 +15,6 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
|||
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.comm;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.edex.database;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.plugin.grib.ogc;bundle-version="1.0.0",
|
||||
org.junit,
|
||||
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.datadelivery.event;bundle-version="1.0.0",
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.edex.ogc.common</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,8 +0,0 @@
|
|||
#Mon Jan 23 16:19:06 CST 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,39 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Common
|
||||
Bundle-SymbolicName: com.raytheon.uf.edex.ogc.common
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: net.opengis;bundle-version="1.0.2",
|
||||
org.apache.commons.logging;bundle-version="1.1.1",
|
||||
org.geotools;bundle-version="2.6.4",
|
||||
org.apache.commons.lang;bundle-version="2.3.0",
|
||||
org.apache.camel;bundle-version="1.0.0",
|
||||
javax.servlet;bundle-version="2.5.0",
|
||||
org.apache.commons.pool;bundle-version="1.3.0",
|
||||
javax.measure;bundle-version="1.0.0",
|
||||
javax.persistence;bundle-version="1.0.0",
|
||||
com.raytheon.edex.common;bundle-version="1.12.1174",
|
||||
org.apache.commons.collections;bundle-version="3.2.0",
|
||||
com.raytheon.uf.common.json;bundle-version="1.0.0",
|
||||
com.sun.xml.bind;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.ebxml;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.schemas.ebxml;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.schemas.iso19115;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.registry.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datadelivery.retrieval;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datadelivery.harvester;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.spatial;bundle-version="1.0.0"
|
||||
Export-Package: com.raytheon.uf.edex.ogc.common,
|
||||
com.raytheon.uf.edex.ogc.common.colormap,
|
||||
com.raytheon.uf.edex.ogc.common.db,
|
||||
com.raytheon.uf.edex.ogc.common.feature,
|
||||
com.raytheon.uf.edex.ogc.common.http,
|
||||
com.raytheon.uf.edex.ogc.common.interfaces,
|
||||
com.raytheon.uf.edex.ogc.common.jaxb,
|
||||
com.raytheon.uf.edex.ogc.common.output,
|
||||
com.raytheon.uf.edex.ogc.common.spatial,
|
||||
com.raytheon.uf.edex.ogc.common.time
|
|
@ -1,8 +0,0 @@
|
|||
source.. = src/
|
||||
bin.includes = .project,\
|
||||
.classpath,\
|
||||
META-INF/,\
|
||||
build.properties,\
|
||||
.settings/,\
|
||||
.,\
|
||||
res/
|
|
@ -1,13 +0,0 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
|
||||
<bean id="jsonFeatureFormatter" class="com.raytheon.uf.edex.ogc.common.feature.JsonFeatureFormatter" >
|
||||
</bean>
|
||||
|
||||
<bean id="shapeFeatureFormatter" class="com.raytheon.uf.edex.ogc.common.feature.ShpFeatureFormatter" >
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -1,86 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
public class OgcBoundingBox extends OgcGeoBoundingBox {
|
||||
|
||||
protected String crs;
|
||||
|
||||
protected double resx = Double.NaN;
|
||||
|
||||
protected double resy = Double.NaN;
|
||||
|
||||
public OgcBoundingBox() {
|
||||
}
|
||||
|
||||
public OgcBoundingBox(String crs, double minx, double maxx, double miny,
|
||||
double maxy, double resx, double resy) {
|
||||
this(crs, minx, maxx, miny, maxy);
|
||||
this.resx = resx;
|
||||
this.resy = resy;
|
||||
}
|
||||
|
||||
public OgcBoundingBox(String crs, double minx, double maxx, double miny,
|
||||
double maxy) {
|
||||
super(maxx, minx, maxy, miny);
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetCrs
|
||||
* @param env
|
||||
*/
|
||||
public OgcBoundingBox(String crs, Envelope env) {
|
||||
super(env);
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public String getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(String crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public double getResx() {
|
||||
return resx;
|
||||
}
|
||||
|
||||
public void setResx(double resx) {
|
||||
this.resx = resx;
|
||||
}
|
||||
|
||||
public double getResy() {
|
||||
return resy;
|
||||
}
|
||||
|
||||
public void setResy(double resy) {
|
||||
this.resy = resy;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcDimension {
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String units;
|
||||
|
||||
protected String unitSymbol;
|
||||
|
||||
protected List<String> values;
|
||||
|
||||
protected String defaultVal;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OgcDimension() {
|
||||
}
|
||||
|
||||
public OgcDimension(String name, List<String> values) {
|
||||
this(name, "", values);
|
||||
}
|
||||
|
||||
public OgcDimension(String name, String units, List<String> values) {
|
||||
this(name, units, null, values);
|
||||
}
|
||||
|
||||
public OgcDimension(String name, String units, String unitSymbol,
|
||||
List<String> values) {
|
||||
this.name = name;
|
||||
this.units = units;
|
||||
this.unitSymbol = unitSymbol;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the units
|
||||
*/
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param units
|
||||
* the units to set
|
||||
*/
|
||||
public void setUnits(String units) {
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unitSymbol
|
||||
*/
|
||||
public String getUnitSymbol() {
|
||||
return unitSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unitSymbol
|
||||
* the unitSymbol to set
|
||||
*/
|
||||
public void setUnitSymbol(String unitSymbol) {
|
||||
this.unitSymbol = unitSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the values
|
||||
*/
|
||||
public List<String> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param values
|
||||
* the values to set
|
||||
*/
|
||||
public void setValues(List<String> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultVal
|
||||
*/
|
||||
public String getDefaultVal() {
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultVal
|
||||
* the defaultVal to set
|
||||
*/
|
||||
public void setDefaultVal(String defaultVal) {
|
||||
this.defaultVal = defaultVal;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
|
||||
public class OgcException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5832661027013919871L;
|
||||
|
||||
public enum Code {
|
||||
InvalidFormat, InvalidCRS, LayerNotDefined, MissingDimensionValue, InvalidDimensionValue, OperationNotSupported, MissingParameterValue, InvalidParameterValue, InternalServerError
|
||||
}
|
||||
|
||||
protected Code code;
|
||||
|
||||
public OgcException(Code code) {
|
||||
super();
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public OgcException(Code code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public OgcException(Code code, Throwable cause) {
|
||||
super(cause);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public OgcException(Code code, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Code getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Code code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcGeoBoundingBox {
|
||||
|
||||
protected double maxx;
|
||||
|
||||
protected double minx;
|
||||
|
||||
protected double maxy;
|
||||
|
||||
protected double miny;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OgcGeoBoundingBox() {
|
||||
}
|
||||
|
||||
public OgcGeoBoundingBox(double eastLongitude, double westLongitude,
|
||||
double northLatitude, double southLatitude) {
|
||||
super();
|
||||
this.maxx = eastLongitude;
|
||||
this.minx = westLongitude;
|
||||
this.maxy = northLatitude;
|
||||
this.miny = southLatitude;
|
||||
}
|
||||
|
||||
public OgcGeoBoundingBox(Polygon polygon, CoordinateReferenceSystem crs) {
|
||||
Geometry env = polygon.getEnvelope();
|
||||
Coordinate[] coords = env.getCoordinates();
|
||||
Coordinate ur = coords[2];
|
||||
Coordinate ll = coords[0];
|
||||
this.maxx = ur.x;
|
||||
this.minx = ll.x;
|
||||
this.maxy = ur.y;
|
||||
this.miny = ll.y;
|
||||
}
|
||||
|
||||
public OgcGeoBoundingBox(Envelope env) {
|
||||
this.maxx = env.getMaxX();
|
||||
this.maxy = env.getMaxY();
|
||||
this.minx = env.getMinX();
|
||||
this.miny = env.getMinY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(maxx);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(maxy);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(miny);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(minx);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
OgcGeoBoundingBox other = (OgcGeoBoundingBox) obj;
|
||||
if (Double.doubleToLongBits(maxx) != Double
|
||||
.doubleToLongBits(other.maxx))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(maxy) != Double
|
||||
.doubleToLongBits(other.maxy))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(miny) != Double
|
||||
.doubleToLongBits(other.miny))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(minx) != Double
|
||||
.doubleToLongBits(other.minx))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public double getMaxx() {
|
||||
return maxx;
|
||||
}
|
||||
|
||||
public void setMaxx(double maxx) {
|
||||
this.maxx = maxx;
|
||||
}
|
||||
|
||||
public double getMinx() {
|
||||
return minx;
|
||||
}
|
||||
|
||||
public void setMinx(double minx) {
|
||||
this.minx = minx;
|
||||
}
|
||||
|
||||
public double getMaxy() {
|
||||
return maxy;
|
||||
}
|
||||
|
||||
public void setMaxy(double maxy) {
|
||||
this.maxy = maxy;
|
||||
}
|
||||
|
||||
public double getMiny() {
|
||||
return miny;
|
||||
}
|
||||
|
||||
public void setMiny(double miny) {
|
||||
this.miny = miny;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,292 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcLayer {
|
||||
|
||||
protected OgcLayer parent;
|
||||
|
||||
protected List<OgcLayer> children;
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String title;
|
||||
|
||||
protected List<String> keywords;
|
||||
|
||||
protected String abs;
|
||||
|
||||
protected List<OgcStyle> styles;
|
||||
|
||||
protected OgcGeoBoundingBox geoBoundingBox;
|
||||
|
||||
protected List<OgcBoundingBox> boundingBox;
|
||||
|
||||
protected List<String> crs;
|
||||
|
||||
protected double minScaleDenom = Double.NaN;
|
||||
|
||||
protected double maxScaleDenom = Double.NaN;
|
||||
|
||||
protected boolean opaque;
|
||||
|
||||
protected int sizeRecord = 0;
|
||||
|
||||
protected List<OgcDimension> dimensions;
|
||||
|
||||
protected static String keySeparator = "/";
|
||||
|
||||
public void addCRS(String crs) {
|
||||
this.crs = addToList(this.crs, crs);
|
||||
}
|
||||
|
||||
protected <T> List<T> addToList(List<T> l, T item) {
|
||||
if (l == null) {
|
||||
l = new ArrayList<T>();
|
||||
}
|
||||
l.add(item);
|
||||
return l;
|
||||
}
|
||||
|
||||
public void addBoundingBox(OgcBoundingBox bbox) {
|
||||
this.boundingBox = addToList(boundingBox, bbox);
|
||||
}
|
||||
|
||||
public void addStyle(OgcStyle style) {
|
||||
this.styles = addToList(styles, style);
|
||||
}
|
||||
|
||||
public void addChildLayer(OgcLayer child) {
|
||||
this.children = addToList(children, child);
|
||||
}
|
||||
|
||||
public void addDimension(OgcDimension dimention) {
|
||||
this.dimensions = addToList(dimensions, dimention);
|
||||
}
|
||||
|
||||
public void addKeyword(String keyword) {
|
||||
this.keywords = addToList(keywords, keyword);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return getKey(name);
|
||||
}
|
||||
|
||||
public String[] separateKey() {
|
||||
return separateKey(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unique key for the source of the layer
|
||||
*/
|
||||
public static String getKey(String layerName) {
|
||||
if (layerName == null) {
|
||||
return null;
|
||||
}
|
||||
return separateKey(layerName)[0];
|
||||
}
|
||||
|
||||
public static String[] separateKey(String layerName) {
|
||||
if (layerName == null) {
|
||||
return null;
|
||||
}
|
||||
String lname;
|
||||
try {
|
||||
lname = URLDecoder.decode(layerName, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return lname.split(OgcLayer.keySeparator, 2);
|
||||
}
|
||||
|
||||
public String getFullTitle() {
|
||||
return getKey() + keySeparator + title;
|
||||
}
|
||||
|
||||
protected String createName(String key, String name) {
|
||||
try {
|
||||
return URLEncoder.encode(key + keySeparator + name, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dimentions
|
||||
*/
|
||||
public List<OgcDimension> getDimensions() {
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dimensions
|
||||
* the dimentions to set
|
||||
*/
|
||||
public void setDimensions(List<OgcDimension> dimensions) {
|
||||
this.dimensions = dimensions;
|
||||
}
|
||||
|
||||
public OgcLayer getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(OgcLayer parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public List<OgcLayer> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<OgcLayer> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public List<OgcStyle> getStyles() {
|
||||
return styles;
|
||||
}
|
||||
|
||||
public void setStyles(List<OgcStyle> styles) {
|
||||
this.styles = styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the geoBoundingBox
|
||||
*/
|
||||
public OgcGeoBoundingBox getGeoBoundingBox() {
|
||||
return geoBoundingBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param geoBoundingBox
|
||||
* the geoBoundingBox to set
|
||||
*/
|
||||
public void setGeoBoundingBox(OgcGeoBoundingBox geoBoundingBox) {
|
||||
this.geoBoundingBox = geoBoundingBox;
|
||||
}
|
||||
|
||||
public List<String> getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(List<String> crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the boundingBox
|
||||
*/
|
||||
public List<OgcBoundingBox> getBoundingBox() {
|
||||
return boundingBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boundingBox
|
||||
* the boundingBox to set
|
||||
*/
|
||||
public void setBoundingBox(List<OgcBoundingBox> boundingBox) {
|
||||
this.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
public double getMinScaleDenom() {
|
||||
return minScaleDenom;
|
||||
}
|
||||
|
||||
public void setMinScaleDenom(double minScaleDenom) {
|
||||
this.minScaleDenom = minScaleDenom;
|
||||
}
|
||||
|
||||
public double getMaxScaleDenom() {
|
||||
return maxScaleDenom;
|
||||
}
|
||||
|
||||
public void setMaxScaleDenom(double maxScaleDenom) {
|
||||
this.maxScaleDenom = maxScaleDenom;
|
||||
}
|
||||
|
||||
public boolean isOpaque() {
|
||||
return opaque;
|
||||
}
|
||||
|
||||
public void setOpaque(boolean opaque) {
|
||||
this.opaque = opaque;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* a key that is used in all layers from the layer's source
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String key, String name) {
|
||||
this.name = createName(key, name);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public List<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public String getAbs() {
|
||||
return abs;
|
||||
}
|
||||
|
||||
public void setAbs(String abs) {
|
||||
this.abs = abs;
|
||||
}
|
||||
|
||||
public int getSizeRecord() {
|
||||
return sizeRecord;
|
||||
}
|
||||
|
||||
public void setSizeRecord(int sizeRecord) {
|
||||
this.sizeRecord = sizeRecord;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcNamespace {
|
||||
public static final String GML = "http://www.opengis.net/gml";
|
||||
|
||||
public static final String ISM = "urn:us:gov:ic:ism:v2";
|
||||
|
||||
public static final String OGC = "http://www.opengis.net/ogc";
|
||||
|
||||
public static final String OM100 = "http://www.opengis.net/om/1.0";
|
||||
|
||||
public static final String OWS110 = "http://www.opengis.net/ows/1.1";
|
||||
|
||||
public static final String OWS = "http://www.opengis.net/ows";
|
||||
|
||||
public static final String Sampling100 = "http://www.opengis.net/sampling/1.0";
|
||||
|
||||
public static final String SMIL = "http://www.w3.org/2001/SMIL20/";
|
||||
|
||||
public static final String SMIL_LANG = "http://www.w3.org/2001/SMIL20/Language";
|
||||
|
||||
public static final String SensorML101 = "http://www.opengis.net/sensorML/1.0.1";
|
||||
|
||||
public static final String SOS100 = "http://www.opengis.net/sos/1.0";
|
||||
|
||||
public static final String SWE101 = "http://www.opengis.net/swe/1.0.1";
|
||||
|
||||
public static final String TML = "http://www.opengis.net/tml";
|
||||
|
||||
public static final String XLINK = "http://www.w3.org/1999/xlink";
|
||||
|
||||
public static final String XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
||||
|
||||
public static final String WCS111 = "http://www.opengis.net/wcs/1.1.1";
|
||||
|
||||
public static final String WCS112 = "http://www.opengis.net/wcs/1.1.2";
|
||||
|
||||
public static final String WMS = "http://www.opengis.net/wms";
|
||||
|
||||
public static final String WFS = "http://www.opengis.net/wfs";
|
||||
|
||||
public static final String EDEX = "http://edex.uf.raytheon.com";
|
||||
|
||||
public static final String SLD = "http://www.opengis.net/sld";
|
||||
|
||||
public static final String SE = "http://www.opengis.net/se";
|
||||
|
||||
public static final String WMTS100 = "http://www.opengis.net/wmts/1.0";
|
||||
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcOperationInfo<T> {
|
||||
|
||||
protected T type;
|
||||
|
||||
protected String httpPostRes;
|
||||
|
||||
protected String httpGetRes;
|
||||
|
||||
protected List<String> formats = new LinkedList<String>();
|
||||
|
||||
protected List<String> versions = new LinkedList<String>();
|
||||
|
||||
protected List<String> acceptversions = new LinkedList<String>();
|
||||
|
||||
protected List<String> services = new LinkedList<String>();
|
||||
|
||||
protected List<String> identifiers = new LinkedList<String>();
|
||||
|
||||
protected List<String> interpolationtypes = new LinkedList<String>();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OgcOperationInfo(T type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public OgcOperationInfo(T type, String httpPostRes, String httpGetRes) {
|
||||
this(type);
|
||||
this.httpGetRes = httpGetRes;
|
||||
this.httpPostRes = httpPostRes;
|
||||
}
|
||||
|
||||
public void addFormat(String format) {
|
||||
formats.add(format);
|
||||
}
|
||||
|
||||
public void addVersion(String version) {
|
||||
versions.add(version);
|
||||
}
|
||||
|
||||
public void addAcceptVersions(String version) {
|
||||
acceptversions.add(version);
|
||||
}
|
||||
|
||||
public void addService(String service) {
|
||||
services.add(service);
|
||||
}
|
||||
|
||||
public void addIdentifier(String identifier) {
|
||||
identifiers.add(identifier);
|
||||
}
|
||||
|
||||
public void addInterpolationType(String interpolationtype) {
|
||||
interpolationtypes.add(interpolationtype);
|
||||
}
|
||||
|
||||
public boolean hasHttpPost() {
|
||||
return httpPostRes != null;
|
||||
}
|
||||
|
||||
public boolean hasHttpGet() {
|
||||
return httpGetRes != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the httpPostRes
|
||||
*/
|
||||
public String getHttpPostRes() {
|
||||
return httpPostRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param httpPostRes
|
||||
* the httpPostRes to set
|
||||
*/
|
||||
public void setHttpPostRes(String httpPostRes) {
|
||||
this.httpPostRes = httpPostRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the httpGetRes
|
||||
*/
|
||||
public String getHttpGetRes() {
|
||||
return httpGetRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param httpGetRes
|
||||
* the httpGetRes to set
|
||||
*/
|
||||
public void setHttpGetRes(String httpGetRes) {
|
||||
this.httpGetRes = httpGetRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public T getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(T type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the formats
|
||||
*/
|
||||
public List<String> getFormats() {
|
||||
return formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param formats
|
||||
* the formats to set
|
||||
*/
|
||||
public void setFormats(List<String> formats) {
|
||||
this.formats = formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the versions
|
||||
*/
|
||||
public List<String> getVersions() {
|
||||
return versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param versions
|
||||
* the versions to set
|
||||
*/
|
||||
public void setVersions(List<String> versions) {
|
||||
this.versions = versions;
|
||||
}
|
||||
|
||||
public List<String> getAcceptversions() {
|
||||
return acceptversions;
|
||||
}
|
||||
|
||||
public void setAcceptversions(List<String> acceptversions) {
|
||||
this.acceptversions = acceptversions;
|
||||
}
|
||||
|
||||
public List<String> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<String> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public List<String> getIdentifiers() {
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
public void setIdentifiers(List<String> identifiers) {
|
||||
this.identifiers = identifiers;
|
||||
}
|
||||
|
||||
public List<String> getInterpolationtypes() {
|
||||
return interpolationtypes;
|
||||
}
|
||||
|
||||
public void setInterpolationtypes(List<String> interpolationtypes) {
|
||||
this.interpolationtypes = interpolationtypes;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcPrefix {
|
||||
/**
|
||||
* Geography Markup Language
|
||||
*/
|
||||
public static final String GML = "gml";
|
||||
|
||||
public static final String ISM = "ism";
|
||||
|
||||
/**
|
||||
* Open Geospatial Consortium
|
||||
*/
|
||||
public static final String OGC = "ogc";
|
||||
|
||||
/**
|
||||
* Observations & Measurements
|
||||
*/
|
||||
public static final String OM = "om";
|
||||
|
||||
public static final String OWS = "ows";
|
||||
|
||||
/**
|
||||
* Sampling
|
||||
*/
|
||||
public static final String Sampling = "sa";
|
||||
|
||||
/**
|
||||
* Synchronized Multimedia Integration Language
|
||||
*/
|
||||
public static final String SMIL = "smil";
|
||||
|
||||
/**
|
||||
* Synchronized Multimedia Integration Language
|
||||
*/
|
||||
public static final String SMIL_LANG = "smilLang";
|
||||
|
||||
/**
|
||||
* Sensor Markup Language
|
||||
*/
|
||||
public static final String SensorML = "sml";
|
||||
|
||||
/**
|
||||
* Sensor Observation Service
|
||||
*/
|
||||
public static final String SOS = "sos";
|
||||
|
||||
/**
|
||||
* Sensor Web Enablement
|
||||
*/
|
||||
public static final String SWE = "swe";
|
||||
|
||||
/**
|
||||
* Transducer Markup Language
|
||||
*/
|
||||
public static final String TML = "tml";
|
||||
|
||||
/**
|
||||
* XML Linking Language
|
||||
*/
|
||||
public static final String XLINK = "xlink";
|
||||
|
||||
/**
|
||||
* XML Schema Instance
|
||||
*/
|
||||
public static final String XSI = "xsi";
|
||||
|
||||
public static final String WCS = "wcs";
|
||||
|
||||
public static final String WMS = "wms";
|
||||
|
||||
public static final String WFS = "wfs";
|
||||
|
||||
public static final String WMTS = "wmts";
|
||||
|
||||
public static final String EDEX = "edex";
|
||||
|
||||
public static final String SLD = "sld";
|
||||
|
||||
public static final String SE = "se";
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
public class OgcResponse {
|
||||
public static final String TEXT_XML_MIME = "text/xml";
|
||||
|
||||
public static final String TEXT_HTML_MIME = "text/html";
|
||||
|
||||
public static final String APP_VND_OGC_SE_XML = "application/vnd.ogc.se_xml";
|
||||
|
||||
public enum TYPE {
|
||||
TEXT, IMAGE, BYTE, MULTIPART
|
||||
};
|
||||
|
||||
public enum ErrorType {
|
||||
NONE, BAD_REQ, INT_ERR, NOT_IMPLEMENTED
|
||||
};
|
||||
|
||||
protected String mimetype;
|
||||
|
||||
protected Object body;
|
||||
|
||||
protected boolean multipart = false;
|
||||
|
||||
protected TYPE type;
|
||||
|
||||
protected ErrorType error = ErrorType.NONE;
|
||||
|
||||
private String exceptionFormat = OgcResponse.TEXT_XML_MIME;
|
||||
|
||||
public OgcResponse(Object body, String mimetype, TYPE type) {
|
||||
this.body = body;
|
||||
this.mimetype = mimetype;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMimetype() {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
public void setMimetype(String mimetype) {
|
||||
this.mimetype = mimetype;
|
||||
}
|
||||
|
||||
public Object getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(Object body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public boolean isMultipart() {
|
||||
return multipart;
|
||||
}
|
||||
|
||||
public void setMultipart(boolean multipart) {
|
||||
this.multipart = multipart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exceptionFormat
|
||||
* the exceptionFormat to set
|
||||
*/
|
||||
public void setExceptionFormat(String exceptionFormat) {
|
||||
this.exceptionFormat = exceptionFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the exceptionFormat
|
||||
*/
|
||||
public String getExceptionFormat() {
|
||||
return exceptionFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public TYPE getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(TYPE type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the error
|
||||
*/
|
||||
public ErrorType getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param error
|
||||
* the error to set
|
||||
*/
|
||||
public void setError(ErrorType error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcServiceInfo<T> {
|
||||
protected String onlineResource;
|
||||
|
||||
protected List<OgcOperationInfo<T>> operations = new LinkedList<OgcOperationInfo<T>>();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OgcServiceInfo(String onlineResouce) {
|
||||
this.onlineResource = onlineResouce;
|
||||
}
|
||||
|
||||
public void addOperationInfo(OgcOperationInfo<T> info) {
|
||||
operations.add(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the onlineResource
|
||||
*/
|
||||
public String getOnlineResource() {
|
||||
return onlineResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param onlineResource
|
||||
* the onlineResource to set
|
||||
*/
|
||||
public void setOnlineResource(String onlineResource) {
|
||||
this.onlineResource = onlineResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operations
|
||||
*/
|
||||
public List<OgcOperationInfo<T>> getOperations() {
|
||||
return operations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operations
|
||||
* the operations to set
|
||||
*/
|
||||
public void setOperations(List<OgcOperationInfo<T>> operations) {
|
||||
this.operations = operations;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
public class OgcStyle {
|
||||
|
||||
protected String name;
|
||||
|
||||
protected String title;
|
||||
|
||||
protected String abs;
|
||||
|
||||
protected String legendUrl;
|
||||
|
||||
protected boolean isDefault = false;
|
||||
|
||||
public OgcStyle() {
|
||||
}
|
||||
|
||||
public OgcStyle(String name, String title, String abs) {
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
this.abs = abs;
|
||||
}
|
||||
|
||||
public OgcStyle(String name, String title) {
|
||||
this(name, title, null);
|
||||
}
|
||||
|
||||
public OgcStyle(String name) {
|
||||
this(name, null, null);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAbs() {
|
||||
return abs;
|
||||
}
|
||||
|
||||
public void setAbs(String abs) {
|
||||
this.abs = abs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the legendUrl
|
||||
*/
|
||||
public String getLegendUrl() {
|
||||
return legendUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param legendUrl
|
||||
* the legendUrl to set
|
||||
*/
|
||||
public void setLegendUrl(String legendUrl) {
|
||||
this.legendUrl = legendUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isDefault
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isDefault
|
||||
* the isDefault to set
|
||||
*/
|
||||
public void setDefault(boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 29, 2012 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface StyleLookup {
|
||||
|
||||
/**
|
||||
* @param layername
|
||||
* @return the name of the default style for layer
|
||||
*/
|
||||
public String lookup(String layername);
|
||||
|
||||
public List<OgcStyle> getStyles();
|
||||
|
||||
public void setLoader(ClassLoader loader);
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.colormap;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
|
||||
public class ColorbarLabeling {
|
||||
@XmlElement
|
||||
String increment;
|
||||
|
||||
@XmlElement
|
||||
String values;
|
||||
|
||||
public String getIncrement() {
|
||||
return increment;
|
||||
}
|
||||
|
||||
public void setIncriment(String increment) {
|
||||
this.increment = increment;
|
||||
}
|
||||
|
||||
public String getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(String values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 9, 2011 ekladstrup Initial creation
|
||||
*
|
||||
*/
|
||||
|
||||
package com.raytheon.uf.edex.ogc.common.colormap;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* @author ekladstrup
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
|
||||
public class LevelRange {
|
||||
|
||||
@XmlAttribute
|
||||
private String level;
|
||||
|
||||
@XmlElement
|
||||
private Float upper;
|
||||
|
||||
@XmlElement
|
||||
private Float lower;
|
||||
|
||||
@XmlAttribute
|
||||
private String unit;
|
||||
|
||||
public LevelRange() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Float getUpper() {
|
||||
return upper;
|
||||
}
|
||||
|
||||
public void setUpper(Float upper) {
|
||||
this.upper = upper;
|
||||
}
|
||||
|
||||
public Float getLower() {
|
||||
return lower;
|
||||
}
|
||||
|
||||
public void setLower(Float lower) {
|
||||
this.lower = lower;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 9, 2011 ekladstrup Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.colormap;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* @author ekladstrup
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
|
||||
public class MapRange {
|
||||
|
||||
@XmlAttribute
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* indicates that this range was pulled from "thin air" and can be replaced
|
||||
* if a better range is known
|
||||
*/
|
||||
@XmlAttribute
|
||||
private boolean replaceable = false;
|
||||
|
||||
@XmlElement
|
||||
private Float upperMinimum;
|
||||
|
||||
@XmlElement
|
||||
private Float upperMaximum;
|
||||
|
||||
@XmlElement
|
||||
private Float lowerMinimum;
|
||||
|
||||
@XmlElement
|
||||
private Float lowerMaximum;
|
||||
|
||||
public MapRange() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Float getUpperMinimum() {
|
||||
return upperMinimum;
|
||||
}
|
||||
|
||||
public void setUpperMinimum(Float upperMinimum) {
|
||||
this.upperMinimum = upperMinimum;
|
||||
}
|
||||
|
||||
public Float getUpperMaximum() {
|
||||
return upperMaximum;
|
||||
}
|
||||
|
||||
public void setUpperMaximum(Float upperMaximum) {
|
||||
this.upperMaximum = upperMaximum;
|
||||
}
|
||||
|
||||
public Float getLowerMinimum() {
|
||||
return lowerMinimum;
|
||||
}
|
||||
|
||||
public void setLowerMinimum(Float lowerMinimum) {
|
||||
this.lowerMinimum = lowerMinimum;
|
||||
}
|
||||
|
||||
public Float getLowerMaximum() {
|
||||
return lowerMaximum;
|
||||
}
|
||||
|
||||
public void setLowerMaximum(Float lowerMaximum) {
|
||||
this.lowerMaximum = lowerMaximum;
|
||||
}
|
||||
|
||||
public void setReplaceable(boolean replaceable) {
|
||||
this.replaceable = replaceable;
|
||||
}
|
||||
|
||||
public boolean isReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 8, 2011 ekladstrup Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.colormap;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorOrder;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* @author ekladstrup
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
|
||||
public class StyleRule {
|
||||
@XmlElement
|
||||
private String layerRegex;
|
||||
|
||||
@XmlElement
|
||||
private LevelRange levelRange;
|
||||
|
||||
@XmlElement
|
||||
private MapRange mapRange;
|
||||
|
||||
@XmlElement
|
||||
private MapRange dataRange;
|
||||
|
||||
@XmlElement
|
||||
private ColorbarLabeling colorbarLabeling;
|
||||
|
||||
@XmlElement
|
||||
private String colorMapName;
|
||||
|
||||
@XmlElement
|
||||
private String displayUnits;
|
||||
|
||||
public StyleRule() {
|
||||
|
||||
}
|
||||
|
||||
public String getLayerRegex() {
|
||||
return layerRegex;
|
||||
}
|
||||
|
||||
public void setLayerRegex(String layerRegex) {
|
||||
this.layerRegex = layerRegex;
|
||||
}
|
||||
|
||||
public void setLevelRange(LevelRange levelRange) {
|
||||
this.levelRange = levelRange;
|
||||
}
|
||||
|
||||
public LevelRange getLevelRange() {
|
||||
return levelRange;
|
||||
}
|
||||
|
||||
public void setMapRange(MapRange mapRange) {
|
||||
this.mapRange = mapRange;
|
||||
}
|
||||
|
||||
public MapRange getMapRange() {
|
||||
return mapRange;
|
||||
}
|
||||
|
||||
public void setDataRange(MapRange dataRange) {
|
||||
this.dataRange = dataRange;
|
||||
}
|
||||
|
||||
public MapRange getDataRange() {
|
||||
return dataRange;
|
||||
}
|
||||
|
||||
public void setColorbarLabeling(ColorbarLabeling colorbarLabeling) {
|
||||
this.colorbarLabeling = colorbarLabeling;
|
||||
}
|
||||
|
||||
public ColorbarLabeling getColorbarLabeling() {
|
||||
return colorbarLabeling;
|
||||
}
|
||||
|
||||
public void setColorMapName(String colorMapName) {
|
||||
this.colorMapName = colorMapName;
|
||||
}
|
||||
|
||||
public String getColorMapName() {
|
||||
return colorMapName;
|
||||
}
|
||||
|
||||
public void setDisplayUnits(String displayUnits) {
|
||||
this.displayUnits = displayUnits;
|
||||
}
|
||||
|
||||
public String getDisplayUnits() {
|
||||
return displayUnits;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,241 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 8, 2011 ekladstrup Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.colormap;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.measure.unit.UnitFormat;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* @author ekladstrup
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class StyleRuleLibrary {
|
||||
|
||||
@XmlElements({ @XmlElement(name = "styleRule", type = StyleRule.class) })
|
||||
private List<StyleRule> rules;
|
||||
|
||||
private Log log = LogFactory.getLog(this.getClass());
|
||||
|
||||
private Map<String, List<StyleRule>> _ruleMap;
|
||||
|
||||
public StyleRuleLibrary() {
|
||||
|
||||
}
|
||||
|
||||
public static StyleRuleLibrary load(InputStream inputStream)
|
||||
throws JAXBException {
|
||||
JAXBContext context = JAXBContext.newInstance(StyleRuleLibrary.class);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
Object lib = unmarshaller.unmarshal(inputStream);
|
||||
if (lib instanceof StyleRuleLibrary) {
|
||||
return (StyleRuleLibrary) lib;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setRules(List<StyleRule> rules) {
|
||||
this.rules = rules;
|
||||
}
|
||||
|
||||
public List<StyleRule> getRules() {
|
||||
return rules;
|
||||
}
|
||||
|
||||
protected Map<String, List<StyleRule>> getRuleMap() {
|
||||
if (_ruleMap == null && rules != null) {
|
||||
_ruleMap = new HashMap<String, List<StyleRule>>();
|
||||
for (StyleRule rule : rules) {
|
||||
String cmap = rule.getColorMapName();
|
||||
List<StyleRule> list = _ruleMap.get(cmap);
|
||||
if (list == null) {
|
||||
list = new ArrayList<StyleRule>();
|
||||
_ruleMap.put(cmap, list);
|
||||
}
|
||||
list.add(rule);
|
||||
}
|
||||
}
|
||||
return _ruleMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rule
|
||||
* @param dimensions
|
||||
* @param levelUnits
|
||||
* @return false if there was a range and it was out of bounds, true
|
||||
* otherwise
|
||||
* @throws ParseException
|
||||
*/
|
||||
protected boolean initRule(StyleRule rule, Map<String, String> dimensions,
|
||||
Map<String, String> levelUnits) throws ParseException {
|
||||
LevelRange range = rule.getLevelRange();
|
||||
if (range != null) {
|
||||
// only accept if range is ok
|
||||
return initRange(rule, dimensions, levelUnits);
|
||||
}
|
||||
// if there is no range, we accept the rule
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rule
|
||||
* @param dimensions
|
||||
* @param levelUnits
|
||||
* @return true if range is in bounds
|
||||
* @throws ParseException
|
||||
*/
|
||||
protected boolean initRange(StyleRule rule, Map<String, String> dimensions,
|
||||
Map<String, String> levelUnits) throws ParseException {
|
||||
LevelRange range = rule.getLevelRange();
|
||||
String level = range.getLevel();
|
||||
String levelValue = dimensions.get(level);
|
||||
if (levelValue != null) {
|
||||
Double lvlVal = Double.parseDouble(levelValue);
|
||||
String styleLevelUnit = range.getUnit();
|
||||
lvlVal = convert(lvlVal, styleLevelUnit, styleLevelUnit, levelUnits);
|
||||
if (lvlVal >= range.getLower() && lvlVal <= range.getUpper()) {
|
||||
setupLevelRange(rule, lvlVal);
|
||||
// range is in bounds
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// range is out of bounds
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Double convert(Double lvlVal, String styleLevelUnit,
|
||||
String level, Map<String, String> levelUnits) throws ParseException {
|
||||
if (styleLevelUnit == null || levelUnits == null) {
|
||||
return lvlVal;
|
||||
}
|
||||
String dataLevelUnit = levelUnits.get(level);
|
||||
if (dataLevelUnit == null) {
|
||||
return lvlVal;
|
||||
}
|
||||
UnitFormat formatter = UnitFormat.getInstance();
|
||||
try {
|
||||
Unit<?> ruleUnit = formatter.parseSingleUnit(styleLevelUnit,
|
||||
new ParsePosition(0));
|
||||
Unit<?> dataUnit = formatter.parseSingleUnit(dataLevelUnit,
|
||||
new ParsePosition(0));
|
||||
|
||||
UnitConverter dataToRuleConv = dataUnit.getConverterTo(ruleUnit);
|
||||
|
||||
return dataToRuleConv.convert(lvlVal.doubleValue());
|
||||
|
||||
} catch (ParseException e) {
|
||||
log.error("Cannot convert units", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public StyleRule getMatchForLayer(String layer,
|
||||
Map<String, String> dimensions, Map<String, String> levelUnits)
|
||||
throws ParseException {
|
||||
if (layer == null) {
|
||||
return null;
|
||||
}
|
||||
for (StyleRule rule : rules) {
|
||||
String pattern = rule.getLayerRegex();
|
||||
if (layer.matches(pattern)) {
|
||||
// do not return rule if there is an invalid range
|
||||
if (initRule(rule, dimensions, levelUnits)) {
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public StyleRule getLayerStyleWithNewCmap(String layer,
|
||||
Map<String, String> dimensions, Map<String, String> levelUnits,
|
||||
String newColormap) throws ParseException {
|
||||
StyleRule rule = getMatchForLayer(layer, dimensions, levelUnits);
|
||||
if (rule != null && newColormap != null) {
|
||||
rule.setColorMapName(newColormap);
|
||||
return rule;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setupLevelRange(StyleRule rule, Double lvlVal) {
|
||||
MapRange range = rule.getMapRange();
|
||||
LevelRange lRange = rule.getLevelRange();
|
||||
if (range != null && lRange != null) {
|
||||
if (range.getLowerMaximum() != null
|
||||
&& range.getLowerMinimum() != null) {
|
||||
// calculate upper and lower
|
||||
double maxRange = Math.abs(range.getUpperMaximum()
|
||||
- range.getLowerMaximum());
|
||||
double minRange = Math.abs(range.getUpperMinimum()
|
||||
- range.getLowerMinimum());
|
||||
double levelRange = Math.abs(lRange.getUpper()
|
||||
- lRange.getLower());
|
||||
|
||||
double lvlRatioOffset = (lvlVal - lRange.getLower())
|
||||
/ levelRange;
|
||||
|
||||
Double newMax = (maxRange * lvlRatioOffset)
|
||||
+ range.getLowerMaximum();
|
||||
Double newMin = (minRange * lvlRatioOffset)
|
||||
+ range.getLowerMinimum();
|
||||
|
||||
range.setUpperMaximum(newMax.floatValue());
|
||||
range.setUpperMinimum(newMin.floatValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,167 +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.
|
||||
**/
|
||||
/**
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 1, 2011 bclement Initial creation
|
||||
*
|
||||
**/
|
||||
|
||||
package com.raytheon.uf.edex.ogc.common.db;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* Default Layer Collector
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/09/2012 754 dhladky initial creation, based on B Clements original
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class DefaultLayerCollector<L extends SimpleLayer, R extends PluginDataObject>
|
||||
extends LayerCollector<L> {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DefaultLayerCollector.class);
|
||||
|
||||
protected Class<R> recordClass;
|
||||
|
||||
protected Class<L> layerClass;
|
||||
|
||||
public DefaultLayerCollector(LayerTransformer transformer,
|
||||
Class<L> layerClass, Class<R> recordClass) {
|
||||
super(transformer);
|
||||
this.recordClass = recordClass;
|
||||
this.layerClass = layerClass;
|
||||
}
|
||||
|
||||
public void add(PluginDataObject... pdos) {
|
||||
if (pdos.length > 0) {
|
||||
addAll(Arrays.asList(pdos));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addAll(Collection<? extends PluginDataObject> coll) {
|
||||
HashMap<String, L> layermap = new HashMap<String, L>(coll.size());
|
||||
for (PluginDataObject pdo : coll) {
|
||||
if (recordClass.equals(pdo.getClass())) {
|
||||
R rec = (R) pdo;
|
||||
String name = getLayerName(rec);
|
||||
L layer = layermap.get(name);
|
||||
if (layer == null) {
|
||||
layer = newLayer();
|
||||
layer.setName(name);
|
||||
if (initializeLayer(layer, rec)) {
|
||||
layermap.put(name, layer);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
addToTimes(layer, rec);
|
||||
addToDims(layer, rec);
|
||||
|
||||
statusHandler.info("Adding layer " + layer.getName());
|
||||
}
|
||||
}
|
||||
for (String key : layermap.keySet()) {
|
||||
try {
|
||||
updateLayer(layermap.get(key));
|
||||
} catch (DataAccessLayerException e) {
|
||||
statusHandler.error("Problem updating the layer table", e);
|
||||
}
|
||||
}
|
||||
|
||||
sendMetaData(layermap, coll);
|
||||
}
|
||||
|
||||
protected L newLayer() {
|
||||
try {
|
||||
return layerClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.error("Unable to instantiate class: " + layerClass, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addToTimes(L layer, R rec) {
|
||||
Date refTime = rec.getDataTime().getRefTime();
|
||||
layer.getTimes().add(refTime);
|
||||
}
|
||||
|
||||
protected void addToDims(L layer, R rec) {
|
||||
// default is to do nothing
|
||||
}
|
||||
|
||||
protected abstract boolean initializeLayer(L layer, R rec);
|
||||
|
||||
protected abstract String getLayerName(R rec);
|
||||
|
||||
protected abstract void sendMetaData(HashMap<String, L> layermap,
|
||||
Collection<? extends PluginDataObject> coll);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void purgeExpired() {
|
||||
try {
|
||||
clearLayers(layerClass);
|
||||
DaoConfig conf = DaoConfig.forClass(recordClass);
|
||||
CoreDao dao = new CoreDao(conf);
|
||||
DatabaseQuery q = new DatabaseQuery(recordClass);
|
||||
q.setMaxResults(500);
|
||||
q.addOrder("dataTime.refTime", false);
|
||||
List<R> recs = (List<R>) dao.queryByCriteria(q);
|
||||
addAll(recs);
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Problem purging layers", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void purgeAll() {
|
||||
try {
|
||||
clearLayers(layerClass);
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("problem purging layers", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,511 +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.ogc.common.db;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfig;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.HarvesterConfigurationManager;
|
||||
import com.raytheon.uf.common.datadelivery.harvester.OGCAgent;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataLevelType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSet;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetName;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Levels;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Parameter;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Provider;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetHandler;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.IDataSetMetaDataHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* Layer Collector
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/09/2012 754 dhladky initial creation, based on B Clements original
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class LayerCollector<L extends SimpleLayer> {
|
||||
|
||||
protected LayerTransformer transformer;
|
||||
|
||||
protected L layer;
|
||||
|
||||
protected HarvesterConfig config = null;
|
||||
|
||||
protected OGCAgent agent = null;
|
||||
|
||||
protected Map<String, Parameter> parameters = null;
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(LayerCollector.class);
|
||||
|
||||
public LayerCollector(LayerTransformer transformer) {
|
||||
setTransformer(transformer);
|
||||
this.config = (HarvesterConfig) HarvesterConfigurationManager.getOGCConfiguration();
|
||||
setAgent((OGCAgent)config.getAgent());
|
||||
storeProvider(config.getProvider());
|
||||
}
|
||||
|
||||
public HarvesterConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(HarvesterConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public <T extends SimpleLayer> void clearLayers(Class<T> c)
|
||||
throws DataAccessLayerException {
|
||||
DaoConfig conf = DaoConfig.forClass(c);
|
||||
CoreDao dao = new CoreDao(conf);
|
||||
List<?> res = dao.queryByCriteria(new DatabaseQuery(c));
|
||||
dao.deleteAll(res);
|
||||
}
|
||||
|
||||
public <T extends SimpleLayer> void replaceTimes(T layer)
|
||||
throws DataAccessLayerException {
|
||||
DaoConfig conf = DaoConfig.forClass(layer.getClass());
|
||||
CoreDao dao = new CoreDao(conf);
|
||||
Session sess = dao.getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = sess.beginTransaction();
|
||||
List<T> list = query(sess, layer);
|
||||
if (list.isEmpty()) {
|
||||
sess.save(layer);
|
||||
} else {
|
||||
if (list.size() > 1) {
|
||||
statusHandler.warn("Multiple layers found with same name, using first");
|
||||
}
|
||||
T old = list.get(0);
|
||||
Set<Date> times = old.getTimes();
|
||||
times.clear();
|
||||
Set<Date> newTimes = layer.getTimes();
|
||||
if (newTimes != null) {
|
||||
times.addAll(newTimes);
|
||||
}
|
||||
}
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
tx.rollback();
|
||||
throw new DataAccessLayerException("Problem replacing layer times",
|
||||
e);
|
||||
} finally {
|
||||
sess.close();
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends SimpleLayer> void updateLayer(T layer)
|
||||
throws DataAccessLayerException {
|
||||
DaoConfig conf = DaoConfig.forClass(layer.getClass());
|
||||
CoreDao dao = new CoreDao(conf);
|
||||
Session sess = dao.getSessionFactory().openSession();
|
||||
Transaction tx = null;
|
||||
try {
|
||||
tx = sess.beginTransaction();
|
||||
List<T> list = query(sess, layer);
|
||||
if (list.isEmpty()) {
|
||||
Set<? extends SimpleDimension> dims = layer.getDimensions();
|
||||
if (dims != null) {
|
||||
for (SimpleDimension d : dims) {
|
||||
sess.save(d);
|
||||
}
|
||||
}
|
||||
sess.save(layer);
|
||||
} else {
|
||||
if (!list.isEmpty()) {
|
||||
statusHandler.warn("Multiple layers found with same name, using first");
|
||||
}
|
||||
T old = list.get(0);
|
||||
update(old, layer);
|
||||
}
|
||||
tx.commit();
|
||||
} catch (Exception e) {
|
||||
tx.rollback();
|
||||
throw new DataAccessLayerException("Problem updating layer", e);
|
||||
} finally {
|
||||
sess.close();
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends SimpleLayer> void update(T old, T shiny) {
|
||||
updateDates(old, shiny);
|
||||
updateDims(old, shiny);
|
||||
}
|
||||
|
||||
public <T extends SimpleLayer> void updateDates(T old, T shiny) {
|
||||
Set<Date> shinyTimes = shiny.getTimes();
|
||||
Set<Date> oldTimes = old.getTimes();
|
||||
if (shinyTimes != null && shinyTimes != null) {
|
||||
for (Date time : shinyTimes) {
|
||||
oldTimes.add(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public <T extends SimpleLayer> void updateDims(T old, T shiny) {
|
||||
Set oldDims = old.getDimensions();
|
||||
Set shinyDims = shiny.getDimensions();
|
||||
if (oldDims != null) {
|
||||
if (shinyDims != null) {
|
||||
updateDimLists(oldDims, shinyDims);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends SimpleDimension> HashMap<String, T> getDimMap(Set<T> dims) {
|
||||
HashMap<String, T> rval = new HashMap<String, T>(dims.size());
|
||||
for (T sd : dims) {
|
||||
rval.put(sd.getName(), sd);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
public <T extends SimpleDimension> void updateDimLists(Set<T> oldDims,
|
||||
Set<T> shinyDims) {
|
||||
HashMap<String, T> oldMap = getDimMap(oldDims);
|
||||
HashMap<String, T> shinyMap = getDimMap(shinyDims);
|
||||
for (String name : shinyMap.keySet()) {
|
||||
T shinyDim = shinyMap.get(name);
|
||||
T oldDim = oldMap.get(name);
|
||||
if (oldDim == null) {
|
||||
oldDims.add(shinyDim);
|
||||
} else {
|
||||
updateDimValues(oldDim, shinyDim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDimValues(SimpleDimension oldDim, SimpleDimension shinyDim) {
|
||||
Set<String> oldValues = oldDim.getValues();
|
||||
Set<String> shinyValues = shinyDim.getValues();
|
||||
if (oldValues != null && shinyValues != null) {
|
||||
for (String val : shinyValues) {
|
||||
oldValues.add(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends SimpleLayer> List<T> query(Session sess, T layer)
|
||||
throws DataAccessLayerException {
|
||||
Class<? extends SimpleLayer> layerClass = transformer.getLayerClass();
|
||||
Criteria criteria = sess.createCriteria(layerClass);
|
||||
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||
criteria.add(Restrictions.eq("name", layer.getName()));
|
||||
return criteria.list();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends SimpleLayer> List<T> query(Session sess, String layerName)
|
||||
throws DataAccessLayerException {
|
||||
Class<? extends SimpleLayer> layerClass = transformer.getLayerClass();
|
||||
Criteria criteria = sess.createCriteria(layerClass);
|
||||
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
|
||||
criteria.add(Restrictions.eq("name", layerName));
|
||||
return criteria.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the Calendar back to the first instant of the current hour. This is
|
||||
* equivalent to calling roundToHour with cutoff of 59
|
||||
*
|
||||
* @param cal
|
||||
* @return
|
||||
*/
|
||||
public static Calendar truncateToHour(Calendar cal) {
|
||||
return DateUtils.truncate(cal, Calendar.HOUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the Date back to the first instant of the current hour. This is
|
||||
* equivalent to calling roundToHour with cutoff of 59
|
||||
*
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static Date truncateToHour(Date d) {
|
||||
return DateUtils.truncate(d, Calendar.HOUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the Calendar to the nearest hour determined by cutoff
|
||||
*
|
||||
* @param cal
|
||||
* @param cutoff
|
||||
* if cal's minute value is greater than cutoff, the return will
|
||||
* be rounded up to the next hour, else rounded down
|
||||
* @return
|
||||
*/
|
||||
public static Calendar roundToHour(Calendar cal, int cutoff) {
|
||||
if (cutoff < 0 || cutoff > 59) {
|
||||
cutoff %= 60;
|
||||
}
|
||||
if (cal.get(Calendar.MINUTE) > cutoff) {
|
||||
cal = (Calendar) cal.clone();
|
||||
cal.add(Calendar.HOUR, 1);
|
||||
}
|
||||
return truncateToHour(cal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Round the Date to the nearest hour determined by cutoff
|
||||
*
|
||||
* @param d
|
||||
* @param cutoff
|
||||
* if d's minute value is greater than cutoff, the return will be
|
||||
* rounded up to the next hour, else rounded down
|
||||
* @return
|
||||
*/
|
||||
public static Date roundToHour(Date d, int cutoff) {
|
||||
Calendar tmp = Calendar.getInstance();
|
||||
tmp.setTime(d);
|
||||
tmp = roundToHour(tmp, cutoff);
|
||||
return tmp.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the DPA config
|
||||
* @return
|
||||
*/
|
||||
public HarvesterConfig getConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stroe Data objects
|
||||
* @param metaDatas
|
||||
* @param dataSet
|
||||
*/
|
||||
public void storeMetaData(final DataSetMetaData metaData) {
|
||||
|
||||
IDataSetMetaDataHandler handler = DataDeliveryHandlers
|
||||
.getDataSetMetaDataHandler();
|
||||
|
||||
final String description = metaData.getDataSetDescription();
|
||||
statusHandler.info("Attempting store of DataSetMetaData["+description+"]");
|
||||
|
||||
try {
|
||||
handler.update(metaData);
|
||||
statusHandler.info("DataSetMetaData [" + description
|
||||
+ "] successfully stored in Registry");
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.info("DataSetMetaData [" + description
|
||||
+ "] failed to store in Registry");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataSetToStore
|
||||
*/
|
||||
protected void storeDataSetName(DataSet dataSetToStore) {
|
||||
|
||||
DataSetName dsn = new DataSetName();
|
||||
// Set the RegistryObject Id keys for this Object
|
||||
// using the values from the DataSetMetaData Object.
|
||||
dsn.setProviderName(dataSetToStore.getProviderName());
|
||||
dsn.setDataSetType(dataSetToStore.getDataSetType());
|
||||
dsn.setDataSetName(dataSetToStore.getDataSetName());
|
||||
|
||||
// Now add the parameter Objects so we can associate
|
||||
// the DataSetName with parameters..
|
||||
dsn.setParameters(dataSetToStore.getParameters());
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getDataSetNameHandler().update(dsn);
|
||||
statusHandler.info("DataSetName object store complete, dataset ["
|
||||
+ dsn.getDataSetName() + "]");
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.error("DataSetName object store failed:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dataSet
|
||||
*/
|
||||
protected void storeDataSet(final DataSet dataSet) {
|
||||
|
||||
DataSet dataSetToStore = getDataSetToStore(dataSet);
|
||||
final String dataSetName = dataSetToStore.getDataSetName();
|
||||
IDataSetHandler handler = DataDeliveryHandlers.getDataSetHandler();
|
||||
|
||||
try {
|
||||
handler.update(dataSetToStore);
|
||||
statusHandler.info("Dataset [" + dataSetName
|
||||
+ "] successfully stored in Registry");
|
||||
storeDataSetName(dataSet);
|
||||
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.info("Dataset [" + dataSetName
|
||||
+ "] failed to store in Registry");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure our provider is contained in the Registry
|
||||
* @param provider
|
||||
*/
|
||||
protected void storeProvider(final Provider provider) {
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getProviderHandler().update(provider);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.info("Provider [" + provider.getName()
|
||||
+ "] failed to store in Registry");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for a {@link DataSet} already existing with the same name in the
|
||||
* Registry. If so, then combine the objects.
|
||||
*
|
||||
* @param dataSet
|
||||
* the dataSet
|
||||
* @return the dataSet instance that should be stored to the registry
|
||||
*/
|
||||
protected DataSet getDataSetToStore(DataSet dataSet) {
|
||||
try {
|
||||
DataSet result = DataDeliveryHandlers.getDataSetHandler()
|
||||
.getByNameAndProvider(dataSet.getDataSetName(),
|
||||
dataSet.getProviderName());
|
||||
if (result != null) {
|
||||
dataSet.combine(result);
|
||||
}
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to retrieve dataset.", e);
|
||||
}
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a parameter object to the registry. If necessary, also store the
|
||||
* ParameterLevel Objects needed to successfully store the Parameter Object.
|
||||
*
|
||||
* @param parameter
|
||||
* The Parameter Object to store.
|
||||
*/
|
||||
protected void storeParameter(Parameter parameter) {
|
||||
|
||||
try {
|
||||
DataDeliveryHandlers.getParameterHandler().update(parameter);
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.info("Failed to store parameter ["
|
||||
+ parameter.getName() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get me my level types for this param
|
||||
*
|
||||
* @param cp
|
||||
* @return
|
||||
*/
|
||||
public List<DataLevelType> getDataLevelTypes(Parameter cp) {
|
||||
return cp.getLevelType();
|
||||
}
|
||||
|
||||
protected abstract L newLayer();
|
||||
|
||||
protected abstract void setCoverage(L layer);
|
||||
|
||||
protected abstract Coverage getCoverage();
|
||||
|
||||
public void setParameters(L layer) {
|
||||
synchronized (layer) {
|
||||
if (getParameters() == null || getParameters().isEmpty()) {
|
||||
parameters = new HashMap<String, Parameter>();
|
||||
for (Parameter parm : agent.getLayer(layer.getName())
|
||||
.getParameters()) {
|
||||
// place in map
|
||||
parameters.put(parm.getName(), parm);
|
||||
storeParameter(parm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Parameter> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
protected abstract void setDataSet(L layer);
|
||||
|
||||
protected abstract DataSet getDataSet();
|
||||
|
||||
protected abstract void setDataSetMetaData(L layer);
|
||||
|
||||
protected abstract DataSetMetaData getDataSetMetaData();
|
||||
|
||||
protected abstract DataType getDataType();
|
||||
|
||||
public abstract Levels getLevels(DataLevelType type, String collectionName);
|
||||
|
||||
public LayerTransformer getTransformer() {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
public void setTransformer(LayerTransformer transformer) {
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
public OGCAgent getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void setAgent(OGCAgent agent) {
|
||||
this.agent = agent;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +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.ogc.common.db;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 29, 2011 bclement Initial creation
|
||||
*
|
||||
**/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class LayerHolder<L extends SimpleLayer> {
|
||||
@XmlElement
|
||||
protected L value;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Class<LayerHolder<SimpleLayer>> getDefaultClass() {
|
||||
return (Class<LayerHolder<SimpleLayer>>) new LayerHolder<SimpleLayer>()
|
||||
.getClass();
|
||||
}
|
||||
|
||||
public L getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(L value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,585 +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.ogc.common.db;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.geotools.geometry.jts.JTS;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.referencing.ReferenceIdentifier;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataquery.db.QueryParam;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcBoundingBox;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcDimension;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcLayer;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcStyle;
|
||||
import com.raytheon.uf.edex.ogc.common.StyleLookup;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 13, 2011 bclement Initial creation
|
||||
*
|
||||
**/
|
||||
|
||||
public class LayerTransformer {
|
||||
|
||||
public enum TimeFormat {
|
||||
LIST, HOUR_RANGES
|
||||
};
|
||||
|
||||
protected String key;
|
||||
|
||||
protected static String timeUnit = "ISO8601";
|
||||
|
||||
protected Class<? extends SimpleLayer> layerClass = SimpleLayer.class;
|
||||
|
||||
protected static Log log = LogFactory.getLog(LayerTransformer.class);
|
||||
|
||||
protected static final int MILLIS_IN_HOUR = 60 * 60 * 1000;
|
||||
|
||||
public static final Pattern frontDot = Pattern
|
||||
.compile("^(-?[0-9]*\\.?[0-9]+)(.*)$");
|
||||
public static final Pattern backDot = Pattern
|
||||
.compile("^(-?[0-9]+\\.?[0-9]*)(.*)$");
|
||||
|
||||
/**
|
||||
* Construct a LayerTransformer that uses a different layerClass and
|
||||
* layerWrapperClass than the default SimpleLayer and LayerHolder
|
||||
*
|
||||
* @param key
|
||||
* @param layerTable
|
||||
* @param das
|
||||
* @param layerClass
|
||||
* @param layerHolderClass
|
||||
*/
|
||||
public LayerTransformer(String key, Class<? extends SimpleLayer> layerClass) {
|
||||
this.key = key;
|
||||
this.layerClass = layerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return null if layer not found
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public SimpleLayer find(String name) throws DataAccessLayerException {
|
||||
String field = "name";
|
||||
List<QueryParam> params = Arrays.asList(new QueryParam(field, name));
|
||||
List<? extends SimpleLayer> res;
|
||||
res = query(layerClass, params);
|
||||
if (res == null || res.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (res.size() > 1) {
|
||||
log.warn("Multiple layers found with the same name, returning first");
|
||||
}
|
||||
return layerClass.cast(res.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @param dimension
|
||||
* @return null if layer/dimension not found
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public SimpleDimension getDimension(String layer, String dimension)
|
||||
throws DataAccessLayerException {
|
||||
SimpleLayer l = find(layer);
|
||||
return getDimension(l, dimension);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @param dimension
|
||||
* @return null if layer/dimension not found
|
||||
*/
|
||||
public static SimpleDimension getDimension(SimpleLayer layer,
|
||||
String dimension) {
|
||||
if (layer == null) {
|
||||
return null;
|
||||
}
|
||||
SimpleDimension rval = null;
|
||||
for (SimpleDimension d : layer.getDimensions()) {
|
||||
if (d.getName().equalsIgnoreCase(dimension)) {
|
||||
rval = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dim
|
||||
* @return empty set if dim is null or doesn't have any parsable values
|
||||
*/
|
||||
public static TreeSet<Double> getDimValuesAsDouble(SimpleDimension dim) {
|
||||
TreeSet<Double> rval = new TreeSet<Double>();
|
||||
if (dim == null) {
|
||||
return rval;
|
||||
}
|
||||
for (String val : dim.getValues()) {
|
||||
try {
|
||||
Matcher m = frontDot.matcher(val);
|
||||
if (m.matches()) {
|
||||
val = m.group(1);
|
||||
} else {
|
||||
m = backDot.matcher(val);
|
||||
if (m.matches()) {
|
||||
val = m.group(1);
|
||||
}
|
||||
}
|
||||
rval.add(Double.parseDouble(val));
|
||||
} catch (Throwable e) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
public List<OgcBoundingBox> getBoundingBoxes(SimpleLayer layer) {
|
||||
String crs = layer.getTargetCrsCode();
|
||||
double minx = layer.getTargetMinx();
|
||||
double maxx = layer.getTargetMaxx();
|
||||
double miny = layer.getTargetMiny();
|
||||
double maxy = layer.getTargetMaxy();
|
||||
OgcBoundingBox rval = new OgcBoundingBox(crs, minx, maxx, miny, maxy);
|
||||
return Arrays.asList(rval);
|
||||
}
|
||||
|
||||
public static String getCrsName(CoordinateReferenceSystem crs) {
|
||||
if (crs == null) {
|
||||
return null;
|
||||
}
|
||||
Set<ReferenceIdentifier> ids = crs.getIdentifiers();
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return crs.getName().toString();
|
||||
} else {
|
||||
return ids.iterator().next().toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
public static OgcGeoBoundingBox getGeoBoundingBox(SimpleLayer layer) {
|
||||
Polygon crs84Bounds = layer.getCrs84Bounds();
|
||||
if (crs84Bounds == null) {
|
||||
return null;
|
||||
}
|
||||
ReferencedEnvelope env = JTS.toEnvelope(crs84Bounds);
|
||||
return new OgcGeoBoundingBox(env);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @param tformat
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getTimes(SimpleLayer layer) {
|
||||
return getTimes(layer, TimeFormat.LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @param tformat
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getTimes(SimpleLayer layer, TimeFormat tformat) {
|
||||
List<String> rval;
|
||||
// TODO this could be adapted to a pattern that allows for formatters to
|
||||
// be externally added
|
||||
switch (tformat) {
|
||||
case LIST:
|
||||
rval = getTimesAsList(layer);
|
||||
break;
|
||||
case HOUR_RANGES:
|
||||
rval = getTimesAsHourRanges(layer);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("No handler for time format: "
|
||||
+ tformat);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
protected static List<String> getTimesAsHourRanges(SimpleLayer layer) {
|
||||
Set<Date> times = layer.getTimes();
|
||||
if (times == null || times.isEmpty()) {
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
Set<Date> set = new TreeSet<Date>();
|
||||
set.addAll(times);
|
||||
Iterator<Date> i = set.iterator();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<String> rval = new ArrayList<String>();
|
||||
Date curr = i.next();
|
||||
while (curr != null) {
|
||||
startRange(sb, curr);
|
||||
curr = endRange(curr, i, sb);
|
||||
if (curr != null) {
|
||||
rval.add(sb.toString());
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
}
|
||||
String last = sb.toString();
|
||||
if (!last.isEmpty()) {
|
||||
rval.add(last);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* End a range started by startRange()
|
||||
*
|
||||
* @param d
|
||||
* start of range
|
||||
* @param i
|
||||
* iterator to rest of times that possibly include the rest of
|
||||
* the range
|
||||
* @param sb
|
||||
* where the formatted output goes
|
||||
* @return the start of the next range, null if there are no more ranges
|
||||
*/
|
||||
protected static Date endRange(Date d, Iterator<Date> i, StringBuilder sb) {
|
||||
long milliStart = d.getTime();
|
||||
long milliPrev = milliStart;
|
||||
Date rval = null;
|
||||
Date prev = null;
|
||||
Date curr = null;
|
||||
while (i.hasNext()) {
|
||||
curr = i.next();
|
||||
if (curr.getTime() - milliPrev > MILLIS_IN_HOUR) {
|
||||
// we've reached the end of the range return rval
|
||||
rval = curr;
|
||||
break;
|
||||
}
|
||||
prev = curr;
|
||||
milliPrev = prev.getTime();
|
||||
}
|
||||
if (prev == null) {
|
||||
// iterator didn't have anything
|
||||
prev = new Date(milliStart + MILLIS_IN_HOUR);
|
||||
} else {
|
||||
// we want the range to end at the next hour
|
||||
prev = new Date(prev.getTime() + MILLIS_IN_HOUR);
|
||||
}
|
||||
sb.append(format(prev));
|
||||
// FIXME 0 indicates a continuum range, we should support discrete
|
||||
// periods in the range
|
||||
sb.append("/0");
|
||||
return rval;
|
||||
}
|
||||
|
||||
public static String format(Date d) {
|
||||
Calendar c = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
c.setTime(d);
|
||||
return DatatypeConverter.printDateTime(c);
|
||||
}
|
||||
|
||||
protected static void startRange(StringBuilder sb, Date d) {
|
||||
sb.append(format(d));
|
||||
sb.append('/');
|
||||
}
|
||||
|
||||
protected static List<String> getTimesAsList(SimpleLayer layer) {
|
||||
Set<Date> times = layer.getTimes();
|
||||
if (times == null || times.isEmpty()) {
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
TreeSet<Date> sorted = new TreeSet<Date>(times);
|
||||
Iterator<Date> i = sorted.iterator();
|
||||
List<String> rval = new ArrayList<String>(sorted.size());
|
||||
while (i.hasNext()) {
|
||||
rval.add(format(i.next()));
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
public TreeSet<Date> getAllTimes() {
|
||||
TreeSet<Date> rval = new TreeSet<Date>();
|
||||
List<SimpleLayer> layers = getLayers();
|
||||
for (SimpleLayer l : layers) {
|
||||
rval.addAll(l.getTimes());
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<SimpleLayer> getLayers() {
|
||||
List<SimpleLayer> rval;
|
||||
rval = (List<SimpleLayer>) query(layerClass);
|
||||
return rval;
|
||||
}
|
||||
|
||||
public List<OgcLayer> getLayersAsOgc(TimeFormat tformat, StyleLookup lookup) {
|
||||
return transform(getLayers(), tformat, lookup);
|
||||
}
|
||||
|
||||
public List<OgcLayer> getLayersAsOgc(StyleLookup lookup) {
|
||||
return getLayersAsOgc(TimeFormat.LIST, lookup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layers
|
||||
* @return
|
||||
*/
|
||||
protected List<OgcLayer> transform(List<? extends SimpleLayer> layers,
|
||||
TimeFormat tformat, StyleLookup lookup) {
|
||||
List<OgcLayer> rval = new ArrayList<OgcLayer>(layers.size());
|
||||
for (SimpleLayer simple : layers) {
|
||||
rval.add(transform(simple, tformat, lookup));
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a simple layer as represented in the data storage area to an
|
||||
* OgcLayer that can be viewed through getCapabilities
|
||||
* <p>
|
||||
* Override this method to add additional Dimensions.
|
||||
*
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
public OgcLayer transform(SimpleLayer layer, TimeFormat tformat,
|
||||
StyleLookup lookup) {
|
||||
OgcLayer rval = new OgcLayer();
|
||||
String name = layer.getName();
|
||||
rval.setName(key, name);
|
||||
rval.setTitle(name);
|
||||
setStylesForLayer(rval.getName(), layer, rval, lookup);
|
||||
OgcDimension timeDim = new OgcDimension("time", timeUnit, getTimes(layer,
|
||||
tformat));
|
||||
Date time = layer.getDefaultTime();
|
||||
String defaultTime;
|
||||
if (tformat.equals(TimeFormat.HOUR_RANGES)) {
|
||||
defaultTime = getTimeRange(time);
|
||||
} else {
|
||||
defaultTime = format(time);
|
||||
}
|
||||
timeDim.setDefaultVal(defaultTime);
|
||||
rval.addDimension(timeDim);
|
||||
for (OgcDimension dim : getDims(layer, layer.getDimensions())) {
|
||||
rval.addDimension(dim);
|
||||
}
|
||||
rval.setGeoBoundingBox(getGeoBoundingBox(layer));
|
||||
rval.setBoundingBox(getBoundingBoxes(layer));
|
||||
// rval.setCrs(Arrays.asList(layer.getTargetCrs()));
|
||||
return rval;
|
||||
}
|
||||
|
||||
public String getTimeRange(Date d) {
|
||||
Date start = DateUtils.truncate(d, Calendar.HOUR);
|
||||
Date end = DateUtils.addHours(start, 1);
|
||||
return format(start) + '/' + format(end);
|
||||
}
|
||||
|
||||
protected void setStylesForLayer(String layerName, SimpleLayer layer,
|
||||
OgcLayer rval, StyleLookup lookup) {
|
||||
if (lookup != null) {
|
||||
String style = lookup.lookup(layerName);
|
||||
if (style != null) {
|
||||
OgcStyle ogcstyle = new OgcStyle(style);
|
||||
String url = "&layer=" + layerName + "&style=" + style
|
||||
+ "&format=image/png";
|
||||
ogcstyle.setLegendUrl(url.replaceAll(" ", "%20"));
|
||||
ogcstyle.setDefault(true);
|
||||
rval.setStyles(Arrays.asList(ogcstyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
protected OgcDimension[] getDims(SimpleLayer layer,
|
||||
Set<? extends SimpleDimension> dims) {
|
||||
if (dims == null) {
|
||||
return new OgcDimension[0];
|
||||
}
|
||||
ArrayList<OgcDimension> rval = new ArrayList<OgcDimension>(dims.size());
|
||||
for (SimpleDimension dim : dims) {
|
||||
OgcDimension ogcdim = transform(layer, dim);
|
||||
if (ogcdim != null) {
|
||||
rval.add(ogcdim);
|
||||
}
|
||||
}
|
||||
return rval.toArray(new OgcDimension[rval.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param simpleDimension
|
||||
* @return
|
||||
*/
|
||||
protected OgcDimension transform(SimpleLayer layer, SimpleDimension dim) {
|
||||
if (dim == null || dim.getName() == null || dim.getValues() == null) {
|
||||
return null;
|
||||
}
|
||||
OgcDimension rval;
|
||||
List<String> values = new ArrayList<String>(dim.getValues());
|
||||
if (dim.getUnits() == null) {
|
||||
rval = new OgcDimension(dim.getName(), values);
|
||||
} else {
|
||||
rval = new OgcDimension(dim.getName(), dim.getUnits(), values);
|
||||
}
|
||||
rval.setDefaultVal(dim.getDefaultValue(layer));
|
||||
return rval;
|
||||
}
|
||||
|
||||
protected OgcLayer transform(SimpleLayer layer, StyleLookup lookup) {
|
||||
return transform(layer, TimeFormat.LIST, lookup);
|
||||
}
|
||||
|
||||
protected <T> List<T> query(Class<T> c) {
|
||||
return query(c, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> List<T> query(Class<T> c, List<QueryParam> params) {
|
||||
try {
|
||||
DatabaseQuery query = new DatabaseQuery(c);
|
||||
if (params != null && !params.isEmpty()) {
|
||||
for (QueryParam p : params) {
|
||||
query.addQueryParam(p);
|
||||
}
|
||||
}
|
||||
DaoConfig config = DaoConfig.forClass(layerClass);
|
||||
CoreDao dao = new CoreDao(config);
|
||||
return (List<T>) dao.queryByCriteria(query);
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to query entity: " + c, e);
|
||||
return new ArrayList<T>(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected <H extends LayerHolder<? extends SimpleLayer>> List<SimpleLayer> unwrap(
|
||||
List<H> holders) {
|
||||
List<SimpleLayer> rval = new ArrayList<SimpleLayer>(holders.size());
|
||||
for (H holder : holders) {
|
||||
rval.add(holder.getValue());
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layerName
|
||||
* @return null if layer name isn't found
|
||||
* @throws DataAccessLayerException
|
||||
*/
|
||||
public Date getLatestTime(String layerName) throws DataAccessLayerException {
|
||||
SimpleLayer simpleLayer = find(layerName);
|
||||
return getLatestTime(simpleLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* @return null if layer name isn't found
|
||||
*/
|
||||
public static Date getLatestTime(SimpleLayer layer) {
|
||||
if (layer == null) {
|
||||
return null;
|
||||
}
|
||||
Set<Date> times = layer.getTimes();
|
||||
TreeSet<Date> sorted = new TreeSet<Date>(times);
|
||||
return sorted.last();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param layerClass
|
||||
* the layerClass to set
|
||||
*/
|
||||
public void setLayerClass(Class<? extends SimpleLayer> layerClass) {
|
||||
this.layerClass = layerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the layerClass
|
||||
*/
|
||||
public Class<? extends SimpleLayer> getLayerClass() {
|
||||
return layerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public TreeSet<Date> getLatestTimes() {
|
||||
List<SimpleLayer> layers = getLayers();
|
||||
TreeSet<Date> rval = new TreeSet<Date>();
|
||||
for (SimpleLayer l : layers) {
|
||||
TreeSet<Date> times = new TreeSet<Date>(l.getTimes());
|
||||
rval.add(times.last());
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,189 +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.
|
||||
**/
|
||||
/**
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 1, 2011 bclement Initial creation
|
||||
*
|
||||
**/
|
||||
|
||||
package com.raytheon.uf.edex.ogc.common.db;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
@Entity
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
public abstract class SimpleDimension implements Comparable<SimpleDimension> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
protected int id;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected String name;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected String units;
|
||||
|
||||
/**
|
||||
* @return live reference to values set, should not return null
|
||||
*/
|
||||
public abstract Set<String> getValues();
|
||||
|
||||
/**
|
||||
* @param layer
|
||||
* the layer that this dimension belongs to. Used by method to
|
||||
* determine the best default for dimension.
|
||||
* @return
|
||||
*/
|
||||
public abstract String getDefaultValue(SimpleLayer layer);
|
||||
|
||||
public SimpleDimension() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lowest
|
||||
* set true to return lowest value, otherwise highest is returned
|
||||
* @return null if there are no values for this dimension
|
||||
*/
|
||||
protected String getDouble(boolean lowest) {
|
||||
Double rval = getValue(lowest);
|
||||
return rval != null ? rval.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lowest
|
||||
* set true to return lowest value, otherwise highest is returned
|
||||
* @return null if there are no values for this dimension
|
||||
*/
|
||||
protected Double getValue(boolean lowest) {
|
||||
Double rval;
|
||||
TreeSet<Double> vals = LayerTransformer.getDimValuesAsDouble(this);
|
||||
if (vals.isEmpty()) {
|
||||
rval = null;
|
||||
} else {
|
||||
rval = lowest ? vals.first() : vals.last();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lowest
|
||||
* set true to return lowest value, otherwise highest is returned
|
||||
* @return null if there are no values for this dimension
|
||||
*/
|
||||
protected String getInt(boolean lowest) {
|
||||
Double val = getValue(lowest);
|
||||
return val != null ? String.valueOf(val.intValue()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the units
|
||||
*/
|
||||
public String getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param units
|
||||
* the units to set
|
||||
*/
|
||||
public void setUnits(String units) {
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(SimpleDimension o) {
|
||||
return this.name.compareTo(o.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SimpleDimension other = (SimpleDimension) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,218 +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.ogc.common.db;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.hibernate.annotations.Index;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistableDataObject;
|
||||
import com.raytheon.uf.common.serialization.adapters.GeometryAdapter;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
|
||||
/**
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 29, 2011 bclement Initial creation
|
||||
*
|
||||
**/
|
||||
|
||||
@Entity
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
@DynamicSerialize
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
public abstract class SimpleLayer implements IPersistableDataObject<Object> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
protected int id;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected int nx;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected int ny;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
@Index(name = "name_idx")
|
||||
protected String name;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected String targetCrsCode;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected double targetMinx;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected double targetMiny;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected double targetMaxx;
|
||||
|
||||
@Column
|
||||
@XmlElement
|
||||
@DynamicSerializeElement
|
||||
protected double targetMaxy;
|
||||
|
||||
@Column(name = "the_geom", columnDefinition = "geometry")
|
||||
@Type(type = "com.raytheon.edex.db.objects.hibernate.GeometryType")
|
||||
@XmlJavaTypeAdapter(value = GeometryAdapter.class)
|
||||
@DynamicSerializeElement
|
||||
protected Polygon crs84Bounds;
|
||||
|
||||
/**
|
||||
* @return live reference to dimensions list, should not return null
|
||||
*/
|
||||
public abstract Set<? extends SimpleDimension> getDimensions();
|
||||
|
||||
/**
|
||||
* @return live reference to times set, should not return null
|
||||
*/
|
||||
public abstract SortedSet<Date> getTimes();
|
||||
|
||||
public Date getDefaultTime() {
|
||||
return this.getTimes().last();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name == null ? super.toString() : name;
|
||||
}
|
||||
|
||||
public int getNx() {
|
||||
return nx;
|
||||
}
|
||||
|
||||
public void setNx(int nx) {
|
||||
this.nx = nx;
|
||||
}
|
||||
|
||||
public int getNy() {
|
||||
return ny;
|
||||
}
|
||||
|
||||
public void setNy(int ny) {
|
||||
this.ny = ny;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTargetCrsCode() {
|
||||
return targetCrsCode;
|
||||
}
|
||||
|
||||
public void setTargetCrsCode(String targetCrsCode) {
|
||||
this.targetCrsCode = targetCrsCode;
|
||||
}
|
||||
|
||||
public double getTargetMinx() {
|
||||
return targetMinx;
|
||||
}
|
||||
|
||||
public void setTargetMinx(double targetMinx) {
|
||||
this.targetMinx = targetMinx;
|
||||
}
|
||||
|
||||
public double getTargetMiny() {
|
||||
return targetMiny;
|
||||
}
|
||||
|
||||
public void setTargetMiny(double targetMiny) {
|
||||
this.targetMiny = targetMiny;
|
||||
}
|
||||
|
||||
public double getTargetMaxx() {
|
||||
return targetMaxx;
|
||||
}
|
||||
|
||||
public void setTargetMaxx(double targetMaxx) {
|
||||
this.targetMaxx = targetMaxx;
|
||||
}
|
||||
|
||||
public double getTargetMaxy() {
|
||||
return targetMaxy;
|
||||
}
|
||||
|
||||
public void setTargetMaxy(double targetMaxy) {
|
||||
this.targetMaxy = targetMaxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getIdentifier() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Polygon getCrs84Bounds() {
|
||||
return crs84Bounds;
|
||||
}
|
||||
|
||||
public void setCrs84Bounds(Polygon crs84Bounds) {
|
||||
this.crs84Bounds = crs84Bounds;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,247 +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.ogc.common.db;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataLevelType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataLevelType.LevelType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSet;
|
||||
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Levels;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
import com.raytheon.uf.common.datadelivery.retrieval.util.LookupManager;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.edex.database.DataAccessLayerException;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
import com.raytheon.uf.edex.ogc.common.interfaces.IWCSMetaData;
|
||||
|
||||
/**
|
||||
*
|
||||
* WCS Layer Collector
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/09/2012 754 dhladky Modified from a class written by Brian Clements
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class WCSLayerCollector<L extends SimpleLayer, R extends PluginDataObject>
|
||||
extends LayerCollector<L> implements IWCSMetaData {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(WCSLayerCollector.class);
|
||||
|
||||
protected Class<R> recordClass;
|
||||
|
||||
protected Class<L> layerClass;
|
||||
|
||||
protected GriddedDataSet gds = null;
|
||||
|
||||
protected GriddedDataSetMetaData gdsmd = null;
|
||||
|
||||
protected Time time = null;
|
||||
|
||||
|
||||
public WCSLayerCollector(LayerTransformer transformer,
|
||||
Class<L> layerClass, Class<R> recordClass) {
|
||||
super(transformer);
|
||||
this.recordClass = recordClass;
|
||||
this.layerClass = layerClass;
|
||||
}
|
||||
|
||||
public void add(PluginDataObject... pdos) {
|
||||
if (pdos.length > 0) {
|
||||
addAll(Arrays.asList(pdos));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addAll(Collection<? extends PluginDataObject> coll) {
|
||||
HashMap<String, L> layermap = new HashMap<String, L>(coll.size());
|
||||
for (PluginDataObject pdo : coll) {
|
||||
if (recordClass.equals(pdo.getClass())) {
|
||||
R rec = (R) pdo;
|
||||
String name = getLayerName(rec);
|
||||
L layer = layermap.get(name);
|
||||
if (layer == null) {
|
||||
layer = newLayer();
|
||||
layer.setName(name);
|
||||
if (initializeLayer(layer, rec)) {
|
||||
layermap.put(name, layer);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
addToTimes(layer, rec);
|
||||
addToDims(layer, rec);
|
||||
|
||||
statusHandler.info("Adding layer " + layer.getName());
|
||||
}
|
||||
}
|
||||
for (String key : layermap.keySet()) {
|
||||
try {
|
||||
updateLayer(layermap.get(key));
|
||||
} catch (DataAccessLayerException e) {
|
||||
statusHandler.error("Problem updating the layer table", e);
|
||||
}
|
||||
}
|
||||
|
||||
sendMetaData(layermap, coll);
|
||||
}
|
||||
|
||||
public L newLayer() {
|
||||
try {
|
||||
return layerClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.error("Unable to instantiate class: " + layerClass, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addToTimes(L layer, R rec) {
|
||||
Date refTime = rec.getDataTime().getRefTime();
|
||||
layer.getTimes().add(refTime);
|
||||
}
|
||||
|
||||
protected void addToDims(L layer, R rec) {
|
||||
// default is to do nothing
|
||||
}
|
||||
|
||||
protected abstract boolean initializeLayer(L layer, R rec);
|
||||
|
||||
protected abstract String getLayerName(R rec);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void purgeExpired() {
|
||||
try {
|
||||
clearLayers(layerClass);
|
||||
DaoConfig conf = DaoConfig.forClass(recordClass);
|
||||
CoreDao dao = new CoreDao(conf);
|
||||
DatabaseQuery q = new DatabaseQuery(recordClass);
|
||||
q.setMaxResults(500);
|
||||
q.addOrder("dataTime.refTime", false);
|
||||
List<R> recs = (List<R>) dao.queryByCriteria(q);
|
||||
addAll(recs);
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Problem purging layers", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void purgeAll() {
|
||||
try {
|
||||
clearLayers(layerClass);
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("problem purging layers", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void setCoverage(L layer) {
|
||||
//TODO: NOt yet implemented
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Coverage getCoverage() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDataSet(L layer) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDataSetMetaData(L layer) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
/**
|
||||
* WFS uses Point Data type
|
||||
* @return
|
||||
*/
|
||||
public DataType getDataType() {
|
||||
return DataType.GRID;
|
||||
}
|
||||
|
||||
public GriddedDataSet getDataSet() {
|
||||
return gds;
|
||||
}
|
||||
|
||||
public GriddedDataSetMetaData getDataSetMetaData() {
|
||||
return gdsmd;
|
||||
}
|
||||
|
||||
//TODO implement this when we do WCS
|
||||
public Levels getLevels(DataLevelType type, String collectionName) {
|
||||
|
||||
Levels levels = new Levels();
|
||||
|
||||
try {
|
||||
|
||||
double dz = 0.0;
|
||||
|
||||
levels.setName(type.getType().getLevelType());
|
||||
levels.setLevelType(type.getId());
|
||||
|
||||
if (type.getType().equals(LevelType.MB.getLevelType())) {
|
||||
List<Double> levelList = LookupManager.getInstance()
|
||||
.getLevels(collectionName).getLevelXml();
|
||||
levels.setLevel(levelList);
|
||||
|
||||
} else if (type.getType().equals(LevelType.SEAB.getLevelType())) {
|
||||
List<Double> levelList = LookupManager.getInstance()
|
||||
.getLevels(collectionName).getLevelXml();
|
||||
levels.setLevel(levelList);
|
||||
} else {
|
||||
// default added when only one
|
||||
levels.addLevel(Double.NaN);
|
||||
}
|
||||
|
||||
levels.setDz(dz);
|
||||
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Level info" + collectionName + " url: "
|
||||
+ getDataSetMetaData().getUrl(), e);
|
||||
}
|
||||
|
||||
return levels;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
package com.raytheon.uf.edex.ogc.common.db;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.harvester.ConfigLayer;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataLevelType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataType;
|
||||
import com.raytheon.uf.common.datadelivery.registry.EnvelopeUtils;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Levels;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PointDataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PointTime;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Time;
|
||||
import com.raytheon.uf.common.datadelivery.registry.WFSPointDataSet;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.util.ImmutableDate;
|
||||
import com.raytheon.uf.edex.ogc.common.interfaces.IWFSMetaData;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
*
|
||||
* WFS Layer Collector
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/09/2012 754 dhladky initial creation
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class WFSLayerCollector<L extends SimpleLayer> extends LayerCollector<L> implements IWFSMetaData<L> {
|
||||
|
||||
protected WFSPointDataSet wpds = wpds = new WFSPointDataSet();
|
||||
|
||||
protected PointDataSetMetaData pdsmd = new PointDataSetMetaData();
|
||||
|
||||
protected PointTime time = new PointTime();
|
||||
|
||||
protected Coverage coverage = new Coverage();
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(WFSLayerCollector.class);
|
||||
|
||||
|
||||
public WFSLayerCollector(LayerTransformer transformer) {
|
||||
super(transformer);
|
||||
}
|
||||
|
||||
public WFSPointDataSet getDataSet() {
|
||||
return wpds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the times
|
||||
* @param layer
|
||||
*/
|
||||
protected void setTime(L layer) {
|
||||
synchronized (layer) {
|
||||
// always creating a new time object for transfer
|
||||
List<Date> times = new ArrayList<Date>();
|
||||
// for dataset we just create a place holder object
|
||||
// DataSetMetaData gets the actual times
|
||||
if (layer.getTimes() != null) {
|
||||
for (Date time : layer.getTimes()) {
|
||||
times.add(time);
|
||||
}
|
||||
|
||||
time.setTimes(times);
|
||||
time.setNumTimes(times.size());
|
||||
time.setFormat(getConfiguration().getAgent().getDateFormat());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
getConfiguration().getAgent().getDateFormat());
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
time.setStart(dateFormat.format(times.get(0)));
|
||||
time.setEnd(dateFormat.format(times.size() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Time getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
protected void setDataSet(L layer) {
|
||||
// set general settings
|
||||
synchronized (layer) {
|
||||
// set coverage if not set
|
||||
setCoverage(layer);
|
||||
wpds.setCoverage(getCoverage());
|
||||
wpds.setDataSetName(layer.getName());
|
||||
wpds.setProviderName(getConfiguration().getProvider().getName());
|
||||
wpds.setCollectionName(getConfiguration().getProvider()
|
||||
.getServiceType().name());
|
||||
// set parameters if not already
|
||||
setParameters(layer);
|
||||
wpds.setParameters(getParameters());
|
||||
// set time if not already
|
||||
setTime(layer);
|
||||
wpds.setTime(getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public PointDataSetMetaData getDataSetMetaData() {
|
||||
return pdsmd;
|
||||
}
|
||||
|
||||
protected void setDataSetMetaData(L layer) {
|
||||
// set the dataset first
|
||||
synchronized(layer) {
|
||||
setDataSet(layer);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(layer.getName()).append(" ");
|
||||
sb.append(layer.getTargetMaxx()).append(", ");
|
||||
sb.append(layer.getTargetMiny()).append(" : ");
|
||||
sb.append(layer.getTargetMinx()).append(", ");
|
||||
sb.append(layer.getTargetMaxy());
|
||||
pdsmd.setDataSetDescription(sb.toString());
|
||||
pdsmd.setDataSetName(layer.getName());
|
||||
pdsmd.setProviderName(getConfiguration().getProvider().getName());
|
||||
StringBuilder sb2 = new StringBuilder();
|
||||
sb2.append(getConfiguration().getProvider().getConnection().getUrl());
|
||||
sb2.append("/");
|
||||
sb2.append(getAgent().getWcs());
|
||||
pdsmd.setUrl(sb2.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the coverage
|
||||
*/
|
||||
protected void setCoverage(L layer) {
|
||||
synchronized (layer) {
|
||||
ConfigLayer configLayer = getAgent().getLayer(layer.getName());
|
||||
Coordinate lowerRight = new Coordinate(configLayer.getMaxx(),
|
||||
configLayer.getMiny());
|
||||
Coordinate upperLeft = new Coordinate(configLayer.getMinx(),
|
||||
configLayer.getMaxy());
|
||||
ReferencedEnvelope re = EnvelopeUtils.createLatLonEnvelope(
|
||||
lowerRight, upperLeft);
|
||||
coverage.setEnvelope(re);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the coverage
|
||||
* @param layer
|
||||
* @return
|
||||
*/
|
||||
protected Coverage getCoverage() {
|
||||
return coverage;
|
||||
}
|
||||
|
||||
/**
|
||||
* WFS uses Point Data type
|
||||
* @return
|
||||
*/
|
||||
public DataType getDataType() {
|
||||
return DataType.POINT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the metaData to the registry
|
||||
*/
|
||||
public void sendMetaData(L layer) {
|
||||
|
||||
//TODO: A lot of this is preliminary.
|
||||
// As we start doing retrievals (Redmine #752)
|
||||
// we will better figure out exactly what we need to
|
||||
// place into a WFS metadata object.
|
||||
synchronized (layer) {
|
||||
// creates a new PointTime object
|
||||
time = new PointTime();
|
||||
// harvests the times from the layer
|
||||
setTime(layer);
|
||||
// make sure you populate the metadata
|
||||
setDataSetMetaData(layer);
|
||||
getDataSetMetaData().setTime(getTime());
|
||||
ImmutableDate date = null;
|
||||
try {
|
||||
date = new ImmutableDate(getTime().getEndDate());
|
||||
} catch (ParseException e) {
|
||||
statusHandler.handle(Priority.ERROR, "Date failed to parse!");
|
||||
}
|
||||
getDataSetMetaData().setDate(date);
|
||||
storeMetaData(getDataSetMetaData());
|
||||
}
|
||||
statusHandler.info("*************** Sending MetaData for "+layer.getName()+" to Registry ***************");
|
||||
}
|
||||
|
||||
public Levels getLevels(DataLevelType type, String collectionName) {
|
||||
// not implement in point data yet
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 16, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.feature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.opengis.feature.simple.SimpleFeature;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface FeatureFactory {
|
||||
|
||||
public List<SimpleFeature> convert(PluginDataObject[] pdos);
|
||||
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 9, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.feature;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.geotools.data.memory.MemoryFeatureCollection;
|
||||
import org.geotools.feature.FeatureCollection;
|
||||
import org.opengis.feature.simple.SimpleFeature;
|
||||
import org.opengis.feature.simple.SimpleFeatureType;
|
||||
|
||||
import com.raytheon.uf.common.json.geo.GeoJsonUtil;
|
||||
import com.raytheon.uf.common.json.geo.GeoJsonUtilSimpleImpl;
|
||||
import com.raytheon.uf.common.json.geo.MixedFeatureCollection;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcResponse;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class JsonFeatureFormatter implements SimpleFeatureFormatter {
|
||||
|
||||
public static String mimeType = "application/json";
|
||||
|
||||
protected GeoJsonUtil jsonUtil = new GeoJsonUtilSimpleImpl();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#format(java.util
|
||||
* .List)
|
||||
*/
|
||||
@Override
|
||||
public OgcResponse format(List<List<SimpleFeature>> features)
|
||||
throws Exception {
|
||||
List<FeatureCollection<SimpleFeatureType, SimpleFeature>> colls = new ArrayList<FeatureCollection<SimpleFeatureType, SimpleFeature>>(
|
||||
features.size());
|
||||
for (List<SimpleFeature> l : features) {
|
||||
if (l != null && !l.isEmpty()) {
|
||||
SimpleFeatureType t = l.get(0).getFeatureType();
|
||||
MemoryFeatureCollection c = new MemoryFeatureCollection(t);
|
||||
c.addAll(l);
|
||||
colls.add(c);
|
||||
}
|
||||
}
|
||||
MixedFeatureCollection mixed = new MixedFeatureCollection(colls);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
jsonUtil.serialize(mixed, baos);
|
||||
return new OgcResponse(baos.toString(), mimeType, TYPE.TEXT);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#getMimeType()
|
||||
*/
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter#matchesFormat
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean matchesFormat(String format) {
|
||||
return mimeType.equalsIgnoreCase(format);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,240 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 28, 2012 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.feature;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.geotools.data.DefaultTransaction;
|
||||
import org.geotools.data.FeatureSource;
|
||||
import org.geotools.data.FeatureStore;
|
||||
import org.geotools.data.Transaction;
|
||||
import org.geotools.data.memory.MemoryFeatureCollection;
|
||||
import org.geotools.data.shapefile.ShapefileDataStore;
|
||||
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
|
||||
import org.geotools.feature.FeatureCollection;
|
||||
import org.opengis.feature.simple.SimpleFeature;
|
||||
import org.opengis.feature.simple.SimpleFeatureType;
|
||||
|
||||
import sun.misc.IOUtils;
|
||||
|
||||
import com.raytheon.uf.edex.ogc.common.OgcResponse;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ShpFeatureFormatter implements SimpleFeatureFormatter {
|
||||
|
||||
public static final String mimeType = "application/zip";
|
||||
|
||||
protected Log log = LogFactory.getLog(this.getClass());
|
||||
|
||||
protected byte[] buffer = new byte[1024 * 4];
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter#format(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public OgcResponse format(List<List<SimpleFeature>> features)
|
||||
throws Exception {
|
||||
List<FeatureCollection<SimpleFeatureType, SimpleFeature>> colls = new ArrayList<FeatureCollection<SimpleFeatureType, SimpleFeature>>(
|
||||
features.size());
|
||||
for (List<SimpleFeature> l : features) {
|
||||
if (l != null && !l.isEmpty()) {
|
||||
SimpleFeatureType t = l.get(0).getFeatureType();
|
||||
MemoryFeatureCollection c = new MemoryFeatureCollection(t);
|
||||
c.addAll(l);
|
||||
colls.add(c);
|
||||
}
|
||||
}
|
||||
// TODO handle multiple schemas
|
||||
if (colls.size() > 1) {
|
||||
log.error("Too many feature types sent to shapefile formatter");
|
||||
}
|
||||
if (colls.isEmpty()) {
|
||||
return new OgcResponse(new byte[0], mimeType, TYPE.BYTE);
|
||||
}
|
||||
|
||||
File tmpDir = createTempDir();
|
||||
try {
|
||||
writeShape(tmpDir, colls.get(0));
|
||||
File zip = createZip(tmpDir);
|
||||
byte[] bytes = readFile(zip);
|
||||
return new OgcResponse(bytes, mimeType, TYPE.BYTE);
|
||||
} finally {
|
||||
if (tmpDir != null && tmpDir.exists()) {
|
||||
deleteDir(tmpDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected File createZip(File dir) throws IOException {
|
||||
File rval = new File(dir, "res.zip");
|
||||
ZipOutputStream out = null;
|
||||
try {
|
||||
out = new ZipOutputStream(new FileOutputStream(rval));
|
||||
writeDirToZip(dir, rval, out);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
protected void writeDirToZip(File dir, File zip, ZipOutputStream out)
|
||||
throws IOException {
|
||||
for (File f : dir.listFiles()) {
|
||||
if (f.equals(zip)) {
|
||||
continue;
|
||||
}
|
||||
out.putNextEntry(new ZipEntry(f.getName()));
|
||||
FileInputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(f);
|
||||
copy(in, out);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
out.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void copy(InputStream in, OutputStream out) throws IOException {
|
||||
int read;
|
||||
while ((read = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteDir(File dir) {
|
||||
File[] files = dir.listFiles();
|
||||
for (File f : files) {
|
||||
f.delete();
|
||||
}
|
||||
dir.delete();
|
||||
}
|
||||
|
||||
protected static File createTempDir() throws Exception {
|
||||
File sysTmp = new File(System.getProperty("java.io.tmpdir"));
|
||||
String tstamp = "wfs" + System.currentTimeMillis() + "-";
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
File rval = new File(sysTmp, tstamp + i);
|
||||
if (rval.mkdir()) {
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
throw new Exception("Unable to create temp directory");
|
||||
}
|
||||
|
||||
protected byte[] readFile(File f) throws FileNotFoundException, IOException {
|
||||
return IOUtils.readFully(new FileInputStream(f), -1, true);
|
||||
}
|
||||
|
||||
protected void writeShape(File dir,
|
||||
FeatureCollection<SimpleFeatureType, SimpleFeature> coll)
|
||||
throws Exception {
|
||||
SimpleFeatureType schema = coll.getSchema();
|
||||
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
|
||||
File f = new File(dir, schema.getTypeName() + ".shp");
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>();
|
||||
params.put("url", f.toURI().toURL());
|
||||
params.put("create spatial index", Boolean.TRUE);
|
||||
ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory
|
||||
.createNewDataStore(params);
|
||||
newDataStore.createSchema(schema);
|
||||
Transaction transaction = new DefaultTransaction("create");
|
||||
String typeName = newDataStore.getTypeNames()[0];
|
||||
FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = newDataStore
|
||||
.getFeatureSource(typeName);
|
||||
if (featureSource instanceof FeatureStore) {
|
||||
FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
|
||||
|
||||
featureStore.setTransaction(transaction);
|
||||
try {
|
||||
featureStore.addFeatures(coll);
|
||||
transaction.commit();
|
||||
|
||||
} catch (Exception problem) {
|
||||
transaction.rollback();
|
||||
throw problem;
|
||||
} finally {
|
||||
transaction.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter#getMimeType()
|
||||
*/
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter#matchesFormat
|
||||
* (java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean matchesFormat(String format) {
|
||||
if (mimeType.equalsIgnoreCase(format)) {
|
||||
return true;
|
||||
}
|
||||
if (format.equalsIgnoreCase("shape-zip")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 8, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.feature;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.opengis.feature.simple.SimpleFeature;
|
||||
|
||||
import com.raytheon.uf.edex.ogc.common.OgcResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface SimpleFeatureFormatter {
|
||||
|
||||
public OgcResponse format(List<List<SimpleFeature>> features)
|
||||
throws Exception;
|
||||
|
||||
public String getMimeType();
|
||||
|
||||
public boolean matchesFormat(String format);
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*****************************************************************************************
|
||||
* COPYRIGHT (c), 2006, RAYTHEON COMPANY
|
||||
* ALL RIGHTS RESERVED, An Unpublished Work
|
||||
*
|
||||
* RAYTHEON PROPRIETARY
|
||||
* If the end user is not the U.S. Government or any agency thereof, use
|
||||
* or disclosure of data contained in this source code file is subject to
|
||||
* the proprietary restrictions set forth in the Master Rights File.
|
||||
*
|
||||
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
|
||||
* If the end user is the U.S. Government or any agency thereof, this source
|
||||
* code is provided to the U.S. Government with Government Purpose Rights.
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the "Government Purpose Rights" restriction in the Master Rights File.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* Use or disclosure of data contained in this source code file is subject to
|
||||
* the export restrictions set forth in the Master Rights File.
|
||||
******************************************************************************************/
|
||||
|
||||
package com.raytheon.uf.edex.ogc.common.http;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
|
||||
/**
|
||||
* TODO - Class comment here
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author
|
||||
* @version 1
|
||||
*/
|
||||
public class OgcHttpEndpoint implements Processor {
|
||||
|
||||
protected OgcHttpPool pool;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OgcHttpEndpoint(OgcHttpPool pool) {
|
||||
this.pool = pool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Exchange ex) throws Exception {
|
||||
|
||||
Map<String, Object> headers = ex.getIn().getHeaders();
|
||||
|
||||
HttpServletResponse response = ex.getIn().getBody(
|
||||
HttpServletResponse.class);
|
||||
HttpServletRequest httpRequest = ex.getIn().getBody(
|
||||
HttpServletRequest.class);
|
||||
|
||||
long id = Thread.currentThread().getId();
|
||||
OgcHttpHandler handler = (OgcHttpHandler) pool.borrowObject(id);
|
||||
OgcHttpRequest ogcReq = new OgcHttpRequest(httpRequest, response,
|
||||
headers);
|
||||
if (httpRequest.getMethod().equalsIgnoreCase("POST")) {
|
||||
ogcReq.setInputStream(ex.getIn().getBody(InputStream.class));
|
||||
}
|
||||
handler.handle(ogcReq);
|
||||
pool.returnObject(id, handler);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.http;
|
||||
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public interface OgcHttpHandler {
|
||||
|
||||
public static final String USER_HEADER = "username";
|
||||
|
||||
public static final String ROLES_HEADER = "roles";
|
||||
|
||||
public static final String EXCEP_FORMAT_HEADER = "exceptions";
|
||||
|
||||
public void handle(OgcHttpRequest request);
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/**********************************************************************
|
||||
*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
**********************************************************************/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.http;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.pool.KeyedPoolableObjectFactory;
|
||||
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
|
||||
|
||||
/**
|
||||
* @author bclement
|
||||
*
|
||||
*/
|
||||
public class OgcHttpPool extends GenericKeyedObjectPool {
|
||||
|
||||
/** The logger */
|
||||
private transient Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public OgcHttpPool(KeyedPoolableObjectFactory ogcFactory) {
|
||||
super(ogcFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object borrowObject(Object key) {
|
||||
Object retVal = null;
|
||||
try {
|
||||
retVal = super.borrowObject(key);
|
||||
} catch (IllegalStateException e) {
|
||||
logger.error(
|
||||
"Unable to borrow Ogc HTTP instance from pool for key: "
|
||||
+ key, e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (Throwable e) {
|
||||
// handle when OSGi removes object but pool still has key
|
||||
returnObject(key, retVal);
|
||||
clear(key);
|
||||
retVal = borrowObject(key);
|
||||
|
||||
if (retVal == null) {
|
||||
// it still didn't work, blow up
|
||||
logger.error(
|
||||
"Unable to borrow Ogc HTTP instance from pool for key: "
|
||||
+ key, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnObject(Object key, Object borrowed) {
|
||||
try {
|
||||
if (borrowed != null && key != null) {
|
||||
super.returnObject(key, borrowed);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to return Ogc HTTP instance to pool for key: "
|
||||
+ key, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void drain() {
|
||||
clear();
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.http;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class OgcHttpRequest {
|
||||
|
||||
protected HttpServletRequest request;
|
||||
|
||||
protected HttpServletResponse response;
|
||||
|
||||
protected Map<String, Object> headers;
|
||||
|
||||
protected InputStream inputStream;
|
||||
|
||||
public OgcHttpRequest(HttpServletRequest request,
|
||||
HttpServletResponse response, Map<String, Object> headers) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public boolean isPost() {
|
||||
return inputStream != null;
|
||||
}
|
||||
|
||||
public HttpServletRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public HttpServletResponse getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(HttpServletResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public Map<String, Object> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public void setHeaders(Map<String, Object> headers) {
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public InputStream getInputStream() {
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
public void setInputStream(InputStream inputStream) {
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package com.raytheon.uf.edex.ogc.common.interfaces;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* WCS Interface
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/09/2012 754 dhladky Initial
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IWCSMetaData {
|
||||
|
||||
public void sendMetaData(Map<String, ? extends SimpleLayer> layermap,
|
||||
Collection<? extends PluginDataObject> coll);
|
||||
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package com.raytheon.uf.edex.ogc.common.interfaces;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* WFS Interface
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 08/09/2012 754 dhladky Initial
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IWFSMetaData<L extends SimpleLayer> {
|
||||
|
||||
public void sendMetaData(L layer);
|
||||
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 30, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.jaxb;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
|
||||
|
||||
/**
|
||||
* Cache and utility class for OGC JAXB
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class OgcJaxbManager {
|
||||
|
||||
protected JAXBContext jaxbContext = null;
|
||||
|
||||
protected int QUEUE_SIZE = 10;
|
||||
|
||||
protected Queue<Unmarshaller> unmarshallers = new ConcurrentLinkedQueue<Unmarshaller>();
|
||||
|
||||
protected Queue<Marshaller> marshallers = new ConcurrentLinkedQueue<Marshaller>();
|
||||
|
||||
protected int unmarshallersCreated = 0;
|
||||
|
||||
protected int marshallersCreated = 0;
|
||||
|
||||
protected Log log = LogFactory.getLog(this.getClass());
|
||||
|
||||
protected Map<String, String> prefixMap = null;
|
||||
|
||||
private NamespacePrefixMapper mapper;
|
||||
|
||||
protected static final String JAXB_NAMESPACE_MAPPER = "com.sun.xml.bind.namespacePrefixMapper";
|
||||
|
||||
public OgcJaxbManager(Class<?>[] classes) throws JAXBException {
|
||||
jaxbContext = JAXBContext.newInstance(classes);
|
||||
}
|
||||
|
||||
protected Unmarshaller getUnmarshaller() throws JAXBException {
|
||||
Unmarshaller m = unmarshallers.poll();
|
||||
if (m == null) {
|
||||
if (unmarshallersCreated < QUEUE_SIZE) {
|
||||
m = jaxbContext.createUnmarshaller();
|
||||
++unmarshallersCreated;
|
||||
} else {
|
||||
int tries = 0;
|
||||
do {
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
m = unmarshallers.poll();
|
||||
tries++;
|
||||
if (tries >= 20) {
|
||||
log.debug("Unable to get jaxb unmarshaller from pool after "
|
||||
+ tries + " tries. Growing pool size.");
|
||||
m = jaxbContext.createUnmarshaller();
|
||||
++unmarshallersCreated;
|
||||
}
|
||||
} while (m == null);
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
protected Marshaller getMarshaller() throws JAXBException {
|
||||
Marshaller m = marshallers.poll();
|
||||
if (m == null) {
|
||||
if (marshallersCreated < QUEUE_SIZE) {
|
||||
m = jaxbContext.createMarshaller();
|
||||
++marshallersCreated;
|
||||
} else {
|
||||
int tries = 0;
|
||||
do {
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
m = marshallers.poll();
|
||||
tries++;
|
||||
if (tries >= 20) {
|
||||
log.debug("Unable to get jaxb marshaller from pool after "
|
||||
+ tries + " tries. Growing pool size.");
|
||||
m = jaxbContext.createMarshaller();
|
||||
++marshallersCreated;
|
||||
}
|
||||
} while (m == null);
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
public Object unmarshal(String xml) throws JAXBException {
|
||||
Unmarshaller msh = null;
|
||||
try {
|
||||
msh = getUnmarshaller();
|
||||
StringReader reader = new StringReader(xml);
|
||||
Object obj = msh.unmarshal(reader);
|
||||
if (obj instanceof JAXBElement<?>) {
|
||||
obj = ((JAXBElement<?>) obj).getValue();
|
||||
}
|
||||
return obj;
|
||||
} finally {
|
||||
if (msh != null) {
|
||||
unmarshallers.add(msh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object unmarshal(InputStream xml) throws JAXBException {
|
||||
Unmarshaller msh = null;
|
||||
try {
|
||||
msh = getUnmarshaller();
|
||||
Object obj = msh.unmarshal(xml);
|
||||
if (obj instanceof JAXBElement<?>) {
|
||||
obj = ((JAXBElement<?>) obj).getValue();
|
||||
}
|
||||
return obj;
|
||||
} finally {
|
||||
if (msh != null) {
|
||||
unmarshallers.add(msh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String marshal(Object obj) throws JAXBException {
|
||||
return marshal(obj, true);
|
||||
}
|
||||
|
||||
public String marshal(Object obj, boolean formatted) throws JAXBException {
|
||||
return marshal(obj, null, formatted);
|
||||
}
|
||||
|
||||
public void marshal(Object obj, OutputStream out, String schemaLocation,
|
||||
boolean formatted) throws JAXBException {
|
||||
Marshaller msh = getMarshaller();
|
||||
try {
|
||||
|
||||
msh.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formatted);
|
||||
if (mapper != null) {
|
||||
msh.setProperty(JAXB_NAMESPACE_MAPPER, mapper);
|
||||
}
|
||||
if (schemaLocation != null && !schemaLocation.isEmpty()) {
|
||||
msh.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation);
|
||||
}
|
||||
msh.marshal(obj, out);
|
||||
} finally {
|
||||
marshallers.add(msh);
|
||||
}
|
||||
}
|
||||
|
||||
public String marshal(Object obj, String schemaLocation, boolean formatted)
|
||||
throws JAXBException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
marshal(obj, out, schemaLocation, formatted);
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public Map<String, String> getPrefixMap() {
|
||||
return prefixMap;
|
||||
}
|
||||
|
||||
public void setPrefixMap(final Map<String, String> prefixMap) {
|
||||
this.prefixMap = prefixMap;
|
||||
this.mapper = new NamespacePrefixMapper() {
|
||||
@Override
|
||||
public String getPreferredPrefix(String namespaceUri,
|
||||
String suggestion, boolean requirePrefix) {
|
||||
return prefixMap.get(namespaceUri);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public JAXBContext getJaxbContext() {
|
||||
return jaxbContext;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 28, 2012 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.output;
|
||||
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageWriter;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.raytheon.uf.edex.ogc.common.OgcException;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcException.Code;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class OgcResponseOutput {
|
||||
|
||||
public static void output(OgcResponse response, HttpServletResponse httpRes)
|
||||
throws Exception {
|
||||
switch (response.getType()) {
|
||||
case TEXT:
|
||||
sendText(response, httpRes);
|
||||
break;
|
||||
case IMAGE:
|
||||
sendImage(response, httpRes);
|
||||
break;
|
||||
case BYTE:
|
||||
case MULTIPART:
|
||||
sendByteArray(response, httpRes);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unsupported type: " + response.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static void checkError(OgcResponse response,
|
||||
HttpServletResponse httpRes) {
|
||||
int code = HttpServletResponse.SC_OK;
|
||||
switch (response.getError()) {
|
||||
case INT_ERR:
|
||||
code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||
break;
|
||||
case BAD_REQ:
|
||||
code = HttpServletResponse.SC_BAD_REQUEST;
|
||||
break;
|
||||
case NOT_IMPLEMENTED:
|
||||
code = HttpServletResponse.SC_NOT_IMPLEMENTED;
|
||||
break;
|
||||
}
|
||||
httpRes.setStatus(code);
|
||||
}
|
||||
|
||||
public static void sendText(OgcResponse response,
|
||||
HttpServletResponse httpRes) throws Exception {
|
||||
httpRes.setContentType(response.getMimetype());
|
||||
checkError(response, httpRes);
|
||||
Object obj = response.getBody();
|
||||
ServletOutputStream out = null;
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
if (obj instanceof byte[]) {
|
||||
// UTF8 bytes
|
||||
httpRes.setCharacterEncoding("UTF-8");
|
||||
out = httpRes.getOutputStream();
|
||||
out.write((byte[]) obj);
|
||||
} else {
|
||||
writer = httpRes.getWriter();
|
||||
writer.write(obj.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
httpRes.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
throw e;
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendImage(OgcResponse response,
|
||||
HttpServletResponse httpRes) throws Exception {
|
||||
String mimetype = response.getMimetype();
|
||||
checkError(response, httpRes);
|
||||
httpRes.setContentType(mimetype);
|
||||
ImageOutputStream out = null;
|
||||
try {
|
||||
Iterator<?> it = ImageIO.getImageWritersByMIMEType(mimetype);
|
||||
if (!it.hasNext()) {
|
||||
throw new OgcException(Code.InvalidFormat,
|
||||
"Format not supported: " + mimetype);
|
||||
}
|
||||
ImageWriter writer = (ImageWriter) it.next();
|
||||
out = ImageIO.createImageOutputStream(httpRes.getOutputStream());
|
||||
writer.setOutput(out);
|
||||
writer.write((RenderedImage) response.getBody());
|
||||
} catch (Exception e) {
|
||||
httpRes.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
throw e;
|
||||
} finally {
|
||||
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendByteArray(OgcResponse response,
|
||||
HttpServletResponse httpRes) throws Exception {
|
||||
httpRes.setContentType(response.getMimetype());
|
||||
checkError(response, httpRes);
|
||||
Object obj = response.getBody();
|
||||
byte[] arr;
|
||||
if (obj instanceof byte[]) {
|
||||
arr = (byte[]) obj;
|
||||
} else if (obj instanceof ByteBuffer) {
|
||||
arr = ((ByteBuffer) obj).array();
|
||||
} else {
|
||||
throw new Exception("Unsupported class: " + obj.getClass());
|
||||
}
|
||||
ServletOutputStream out = null;
|
||||
try {
|
||||
out = httpRes.getOutputStream();
|
||||
out.write(arr);
|
||||
} catch (Exception e) {
|
||||
httpRes.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
throw e;
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 17, 2012 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.spatial;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.collections.map.LRUMap;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.NoSuchAuthorityCodeException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CrsLookup {
|
||||
|
||||
private static final int N_OBJECTS = 10;
|
||||
|
||||
public static final String GOOGLE_CRS_WKT = "PROJCS[\"Google Mercator\","
|
||||
+ "GEOGCS[\"WGS 84\","
|
||||
+ "DATUM[\"World Geodetic System 1984\","
|
||||
+ "SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"
|
||||
+ "AUTHORITY[\"EPSG\",\"6326\"]],"
|
||||
+ "PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
|
||||
+ "UNIT[\"degree\", 0.017453292519943295],"
|
||||
+ "AXIS[\"Geodetic latitude\", NORTH],"
|
||||
+ "AXIS[\"Geodetic longitude\", EAST],"
|
||||
+ "AUTHORITY[\"EPSG\",\"4326\"]],"
|
||||
+ "PROJECTION[\"Mercator_1SP\"],"
|
||||
+ "PARAMETER[\"semi_minor\", 6378137.0],"
|
||||
+ "PARAMETER[\"latitude_of_origin\", 0.0],"
|
||||
+ "PARAMETER[\"central_meridian\", 0.0],"
|
||||
+ "PARAMETER[\"scale_factor\", 1.0],"
|
||||
+ "PARAMETER[\"false_easting\", 0.0],"
|
||||
+ "PARAMETER[\"false_northing\", 0.0]," + "UNIT[\"m\", 1.0],"
|
||||
+ "AXIS[\"Easting\", EAST]," + " AXIS[\"Northing\", NORTH],"
|
||||
+ "AUTHORITY[\"EPSG\",\"900913\"]]";
|
||||
|
||||
protected static final LRUMap cache = new LRUMap(N_OBJECTS);
|
||||
|
||||
protected static CoordinateReferenceSystem googleCrs;
|
||||
|
||||
protected static final Pattern OGC_CODE_PATTERN = Pattern
|
||||
.compile("^([a-zA-Z]+)([0-9]+)$");
|
||||
|
||||
public static CoordinateReferenceSystem lookup(String crs)
|
||||
throws NoSuchAuthorityCodeException, FactoryException {
|
||||
if (crs == null) {
|
||||
return null;
|
||||
}
|
||||
crs = normalize(crs);
|
||||
CoordinateReferenceSystem rval;
|
||||
synchronized (cache) {
|
||||
rval = (CoordinateReferenceSystem) cache.get(crs);
|
||||
if (rval == null) {
|
||||
rval = decodeCrs(crs);
|
||||
if (rval != null) {
|
||||
cache.put(crs, rval);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
protected static CoordinateReferenceSystem decodeCrs(String crs)
|
||||
throws NoSuchAuthorityCodeException, FactoryException {
|
||||
if (crs.equalsIgnoreCase("epsg:900913")
|
||||
|| crs.equalsIgnoreCase("epsg:3857")) {
|
||||
return getGoogleCrs();
|
||||
}
|
||||
return CRS.decode(crs, true);
|
||||
}
|
||||
|
||||
protected static CoordinateReferenceSystem getGoogleCrs()
|
||||
throws FactoryException {
|
||||
if (googleCrs == null) {
|
||||
googleCrs = CRS.parseWKT(GOOGLE_CRS_WKT);
|
||||
}
|
||||
return googleCrs;
|
||||
}
|
||||
|
||||
protected static String normalize(String crs) {
|
||||
String[] parts = crs.split(":");
|
||||
String rval;
|
||||
if (parts.length == 2) {
|
||||
// good form
|
||||
rval = crs;
|
||||
} else if (parts.length == 7) {
|
||||
// probably an OGC URN
|
||||
rval = constructCode(parts[4], parts[6]);
|
||||
} else if (parts.length == 6) {
|
||||
// OGC URN without version?
|
||||
rval = constructCode(parts[4], parts[5]);
|
||||
} else {
|
||||
// unkown form, try it anyway
|
||||
rval = crs;
|
||||
}
|
||||
return rval.toLowerCase();
|
||||
}
|
||||
|
||||
protected static String constructCode(String authority, String code) {
|
||||
if (!authority.equalsIgnoreCase("epsg")
|
||||
&& !authority.equalsIgnoreCase("crs")) {
|
||||
// geotools database only has epsg codes
|
||||
// try a generic crs authority
|
||||
authority = "crs";
|
||||
}
|
||||
return authority + ":" + code;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,194 +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.ogc.common.spatial;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.geometry.jts.ReferencedEnvelope;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.persist.IPersistable;
|
||||
import com.raytheon.uf.common.datastorage.IDataStore;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialEnabled;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.spatial.reprojection.DataReprojector;
|
||||
import com.raytheon.uf.common.spatial.reprojection.ReferencedDataRecord;
|
||||
import com.raytheon.uf.edex.database.plugin.PluginDao;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
|
||||
/**
|
||||
* Removing code only used by ogc services from {@link PluginDao} to here
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 26, 2013 1638 mschenke Code moved from PluginDao to clean up dependencies
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author unknown
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class RecordUtil {
|
||||
|
||||
/**
|
||||
* @param record
|
||||
* @param crs
|
||||
* target crs for projected data
|
||||
* @param envelope
|
||||
* bounding box in target crs
|
||||
* @return null if envelope is disjoint with data bounds
|
||||
* @throws Exception
|
||||
*/
|
||||
public static ReferencedDataRecord getProjected(PluginDao dao,
|
||||
PluginDataObject record, CoordinateReferenceSystem crs,
|
||||
Envelope envelope) throws Exception {
|
||||
ReferencedEnvelope targetEnv = new ReferencedEnvelope(
|
||||
envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(),
|
||||
envelope.getMaxY(), crs);
|
||||
return getProjected(dao, record, targetEnv);
|
||||
}
|
||||
|
||||
public static double getHDF5Value(PluginDao dao, PluginDataObject pdo,
|
||||
CoordinateReferenceSystem crs, Coordinate coord,
|
||||
double defaultReturn) throws Exception {
|
||||
// TODO a cache would probably be good here
|
||||
double rval = defaultReturn;
|
||||
if (pdo instanceof ISpatialEnabled) {
|
||||
IDataStore store = dao.getDataStore((IPersistable) pdo);
|
||||
ISpatialObject spat = getSpatialObject(pdo);
|
||||
DataReprojector reprojector = getDataReprojector(store);
|
||||
ReferencedEnvelope nativeEnv = getNativeEnvelope(spat);
|
||||
IDataRecord data = reprojector.getProjectedPoints(pdo.getDataURI(),
|
||||
spat, nativeEnv, crs, new Coordinate[] { coord });
|
||||
Double res = extractSingle(data);
|
||||
if (res != null) {
|
||||
rval = res;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param record
|
||||
* @param crs
|
||||
* target crs for projected data
|
||||
* @param envelope
|
||||
* bounding box in target crs
|
||||
* @return null if envelope is disjoint with data bounds
|
||||
* @throws Exception
|
||||
*/
|
||||
public static GridCoverage2D getProjectedCoverage(PluginDao dao,
|
||||
PluginDataObject record, CoordinateReferenceSystem crs,
|
||||
Envelope envelope) throws Exception {
|
||||
ReferencedEnvelope targetEnv = new ReferencedEnvelope(
|
||||
envelope.getMinX(), envelope.getMaxX(), envelope.getMinY(),
|
||||
envelope.getMaxY(), crs);
|
||||
return getProjectedCoverage(dao, record, targetEnv);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param record
|
||||
* @param targetEnvelope
|
||||
* bounding box in target crs
|
||||
* @return null if envelope is disjoint with data bounds
|
||||
* @throws Exception
|
||||
*/
|
||||
public static ReferencedDataRecord getProjected(PluginDao dao,
|
||||
PluginDataObject record, ReferencedEnvelope targetEnvelope)
|
||||
throws Exception {
|
||||
IDataStore store = dao.getDataStore((IPersistable) record);
|
||||
ISpatialObject spatial = getSpatialObject(record);
|
||||
DataReprojector reprojector = getDataReprojector(store);
|
||||
ReferencedEnvelope nativeEnvelope = getNativeEnvelope(spatial);
|
||||
return reprojector.getReprojected(record.getDataURI(), spatial,
|
||||
nativeEnvelope, targetEnvelope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param record
|
||||
* @param targetEnvelope
|
||||
* bounding box in target crs
|
||||
* @return null if envelope is disjoint with data bounds
|
||||
* @throws Exception
|
||||
*/
|
||||
public static GridCoverage2D getProjectedCoverage(PluginDao dao,
|
||||
PluginDataObject record, ReferencedEnvelope envelope)
|
||||
throws Exception {
|
||||
IDataStore store = dao.getDataStore((IPersistable) record);
|
||||
ISpatialObject spatial = getSpatialObject(record);
|
||||
DataReprojector reprojector = getDataReprojector(store);
|
||||
ReferencedEnvelope nativeEnvelope = getNativeEnvelope(spatial);
|
||||
return reprojector.getReprojectedCoverage(record.getDataURI(), spatial,
|
||||
nativeEnvelope, envelope);
|
||||
}
|
||||
|
||||
protected static DataReprojector getDataReprojector(IDataStore dataStore) {
|
||||
return new DataReprojector(dataStore);
|
||||
}
|
||||
|
||||
protected static ReferencedEnvelope getNativeEnvelope(ISpatialObject spatial)
|
||||
throws FactoryException {
|
||||
CoordinateReferenceSystem crs = spatial.getCrs();
|
||||
Geometry geom = spatial.getGeometry();
|
||||
return MapUtil.getBoundingEnvelope(crs, (Polygon) geom);
|
||||
}
|
||||
|
||||
public static Double extractSingle(IDataRecord record) {
|
||||
Double rval = null;
|
||||
if (record == null) {
|
||||
return rval;
|
||||
}
|
||||
if (record instanceof ByteDataRecord) {
|
||||
byte[] data = ((ByteDataRecord) record).getByteData();
|
||||
rval = (double) data[0];
|
||||
} else if (record instanceof FloatDataRecord) {
|
||||
float[] data = ((FloatDataRecord) record).getFloatData();
|
||||
rval = (double) data[0];
|
||||
} else if (record instanceof IntegerDataRecord) {
|
||||
int[] data = ((IntegerDataRecord) record).getIntData();
|
||||
rval = (double) data[0];
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
public static ISpatialObject getSpatialObject(PluginDataObject record)
|
||||
throws Exception {
|
||||
if (record instanceof ISpatialEnabled) {
|
||||
return ((ISpatialEnabled) record).getSpatialObject();
|
||||
} else {
|
||||
throw new Exception(record.getClass() + " is not spatially enabled");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,371 +0,0 @@
|
|||
/*
|
||||
* The following software products were developed by Raytheon:
|
||||
*
|
||||
* ADE (AWIPS Development Environment) software
|
||||
* CAVE (Common AWIPS Visualization Environment) software
|
||||
* EDEX (Environmental Data Exchange) software
|
||||
* uFrame™ (Universal Framework) software
|
||||
*
|
||||
* Copyright (c) 2010 Raytheon Co.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address:
|
||||
* 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 3, 2011 bclement Initial creation
|
||||
*
|
||||
*/
|
||||
package com.raytheon.uf.edex.ogc.common.time;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TimeZone;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcException;
|
||||
import com.raytheon.uf.edex.ogc.common.OgcException.Code;
|
||||
import com.raytheon.uf.edex.ogc.common.db.LayerTransformer;
|
||||
import com.raytheon.uf.edex.ogc.common.db.SimpleDimension;
|
||||
import com.raytheon.uf.edex.ogc.common.db.SimpleLayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ForecastTimeUtil {
|
||||
|
||||
protected static final String refKey = "REFTIME";
|
||||
|
||||
protected static final String fcstKey = "FORECAST_OFFSET";
|
||||
|
||||
protected Pattern fcstPattern = Pattern
|
||||
.compile("^([0-9]+)([sSmMhHdD]?).*$");
|
||||
|
||||
protected Log log = LogFactory.getLog(this.getClass());
|
||||
|
||||
/**
|
||||
* Gets a list of datatimes for specified layer. If dimensions has values
|
||||
* for {@link ForecastTimeUtil#refKey} or {@link ForecastTimeUtil#fcstKey}
|
||||
* then the list will be of size 1.
|
||||
*
|
||||
* @param layer
|
||||
* @param dimensions
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
public SortedSet<DataTime> getDataTimes(SimpleLayer layer,
|
||||
Map<String, String> dimensions) throws OgcException {
|
||||
return getDataTimes(layer, (String) null, dimensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of datatimes for specified layer. If dimensions has values
|
||||
* for {@link ForecastTimeUtil#refKey} or {@link ForecastTimeUtil#fcstKey}
|
||||
* then the list will be of size 1. If time is null, a default time will be
|
||||
* used.
|
||||
*
|
||||
* @param layer
|
||||
* @param time
|
||||
* @param dimensions
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
public SortedSet<DataTime> getDataTimes(SimpleLayer layer, String time,
|
||||
Map<String, String> dimensions) throws OgcException {
|
||||
Calendar validTime = getValidTime(layer, time);
|
||||
return getDataTimes(layer, validTime, dimensions);
|
||||
}
|
||||
|
||||
public SortedSet<DataTime> getDataTimes(SimpleLayer layer, Date time,
|
||||
Map<String, String> dimensions) throws OgcException {
|
||||
Calendar validTime;
|
||||
if (time == null) {
|
||||
validTime = getValidTime(layer, null);
|
||||
} else {
|
||||
validTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
validTime.setTime(time);
|
||||
}
|
||||
return getDataTimes(layer, validTime, dimensions);
|
||||
}
|
||||
|
||||
protected SortedSet<DataTime> getDataTimes(SimpleLayer layer,
|
||||
Calendar time,
|
||||
Map<String, String> dimensions) throws OgcException {
|
||||
String refStr = dimensions.get(refKey);
|
||||
String fcstStr = dimensions.get(fcstKey);
|
||||
SortedSet<DataTime> rval = new TreeSet<DataTime>();
|
||||
if (fcstStr != null && refStr != null) {
|
||||
rval.add(getDataTime(refStr, fcstStr, time));
|
||||
} else if (fcstStr != null) {
|
||||
rval.add(getDataTimeFcst(fcstStr, time));
|
||||
} else if (refStr != null) {
|
||||
rval.add(getDataTimeRef(refStr, time));
|
||||
} else {
|
||||
rval = getCandidates(layer, time);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the specified dimension object from the layer object.
|
||||
*
|
||||
* @param layer
|
||||
* @param dimension
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected SimpleDimension getDimension(SimpleLayer layer, String dimension)
|
||||
throws OgcException {
|
||||
SimpleDimension dim;
|
||||
try {
|
||||
dim = LayerTransformer.getDimension(layer, dimension);
|
||||
if (dim == null) {
|
||||
// UNLIKELY: must have been the dimension
|
||||
log.error("layer: " + layer + " missing dimension: "
|
||||
+ dimension);
|
||||
throw new OgcException(Code.InternalServerError);
|
||||
}
|
||||
if (dim.getValues().isEmpty()) {
|
||||
log.error("layer " + layer + " missing " + dimension);
|
||||
throw new OgcException(Code.LayerNotDefined);
|
||||
}
|
||||
return dim;
|
||||
} catch (Exception e) {
|
||||
log.error("Problem getting dim: " + dimension + " for layer: "
|
||||
+ layer, e);
|
||||
throw new OgcException(Code.InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the refTime/forecast time pairs from the layer that could combine to
|
||||
* the given valid time.
|
||||
*
|
||||
* @param layer
|
||||
* @param validTime
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected SortedSet<DataTime> getCandidates(SimpleLayer layer,
|
||||
Calendar validTime) throws OgcException {
|
||||
SimpleDimension refDim = getDimension(layer, refKey);
|
||||
SimpleDimension fcstDim = getDimension(layer, fcstKey);
|
||||
TreeSet<Double> fcsts = LayerTransformer.getDimValuesAsDouble(fcstDim);
|
||||
Set<String> refVals = refDim.getValues();
|
||||
ArrayList<Calendar> refs;
|
||||
try {
|
||||
refs = convert(refVals);
|
||||
} catch (Exception e) {
|
||||
log.error("invalid date in layer: " + layer, e);
|
||||
throw new OgcException(Code.InternalServerError);
|
||||
}
|
||||
SortedSet<DataTime> rval = new TreeSet<DataTime>();
|
||||
// try all combinations to find matches with valid time
|
||||
Calendar refPlusFcst = Calendar
|
||||
.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
for (Double dbl : fcsts) {
|
||||
int fcst = (int) Math.floor(dbl);
|
||||
for (Calendar ref : refs) {
|
||||
long diff = ref.getTimeInMillis() + (fcst * 1000);
|
||||
refPlusFcst.setTimeInMillis(diff);
|
||||
if (equals(refPlusFcst, validTime)) {
|
||||
rval.add(new DataTime(ref, fcst));
|
||||
}
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
protected boolean equals(Calendar one, Calendar two) {
|
||||
return one.getTimeInMillis() == two.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses time strings
|
||||
*
|
||||
* @param times
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected ArrayList<Calendar> convert(Set<String> times)
|
||||
throws OgcException {
|
||||
ArrayList<Calendar> refs = new ArrayList<Calendar>(times.size());
|
||||
for (String val : times) {
|
||||
refs.add(parseTimeString(val));
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
protected static Calendar parseTimeString(String time) throws OgcException {
|
||||
try {
|
||||
return DatatypeConverter.parseDateTime(time);
|
||||
} catch (Exception e) {
|
||||
throw new OgcException(Code.InvalidFormat, "Invalid Date Format");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates datatime using valid time and refTime
|
||||
*
|
||||
* @param refStr
|
||||
* @param validTime
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected DataTime getDataTimeRef(String refStr, Calendar validTime)
|
||||
throws OgcException {
|
||||
Calendar ref = parseTimeStr(refStr, refKey);
|
||||
long diff = validTime.getTimeInMillis() - ref.getTimeInMillis();
|
||||
return new DataTime(ref, (int) (diff / 1000));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses time string with error handling.
|
||||
*
|
||||
* @param time
|
||||
* @param name
|
||||
* used in error output
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected Calendar parseTimeStr(String time, String name)
|
||||
throws OgcException {
|
||||
Calendar rval;
|
||||
try {
|
||||
rval = parseTimeString(time);
|
||||
} catch (Exception e) {
|
||||
String msg = String.format("Invalid dimension %s: %s", name, time);
|
||||
throw new OgcException(Code.InvalidDimensionValue, msg);
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates datatime using forecast time and valid time
|
||||
*
|
||||
* @param fcstStr
|
||||
* @param validTime
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected DataTime getDataTimeFcst(String fcstStr, Calendar validTime)
|
||||
throws OgcException {
|
||||
int fcst = parseForcast(fcstStr);
|
||||
long refMillis = validTime.getTimeInMillis() - (fcst * 1000);
|
||||
Calendar refTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
refTime.setTimeInMillis(refMillis);
|
||||
return new DataTime(refTime, fcst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses forecast string using limited ISO standard for time duration. This
|
||||
* method handles integers with duration labels S|M|H|D (seconds, minutes,
|
||||
* hours and days). It does not handle combined duration specifiers.
|
||||
*
|
||||
* @param fcstStr
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected int parseForcast(String fcstStr) throws OgcException {
|
||||
// TODO handle all ISO standard durations
|
||||
Matcher m = fcstPattern.matcher(fcstStr);
|
||||
if (m.matches()) {
|
||||
int fcst = Integer.parseInt(m.group(1));
|
||||
String unit = m.group(2);
|
||||
if (unit != null && !unit.equalsIgnoreCase("s")) {
|
||||
if (unit.equalsIgnoreCase("m")) {
|
||||
fcst = fcst * 60;
|
||||
} else if (unit.equalsIgnoreCase("h")) {
|
||||
fcst = fcst * 60 * 60;
|
||||
} else if (unit.equalsIgnoreCase("d")) {
|
||||
fcst = fcst * 60 * 60 * 24;
|
||||
}
|
||||
}
|
||||
return fcst;
|
||||
} else {
|
||||
String msg = String.format("Invalid dimension %s: %s", fcstKey,
|
||||
fcstStr);
|
||||
throw new OgcException(Code.InvalidDimensionValue, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct datatime using refTime and forecast time.
|
||||
*
|
||||
* @param refStr
|
||||
* @param fcstStr
|
||||
* @param validTime
|
||||
* used to confirm result
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected DataTime getDataTime(String refStr, String fcstStr,
|
||||
Calendar validTime) throws OgcException {
|
||||
Calendar ref = parseTimeStr(refStr, refKey);
|
||||
int fcst = parseForcast(fcstStr);
|
||||
long diff = validTime.getTimeInMillis() - ref.getTimeInMillis();
|
||||
if (diff != (fcst * 1000)) {
|
||||
String msg = String.format("%s and time must differ by %s", refKey,
|
||||
fcstKey);
|
||||
throw new OgcException(Code.InvalidDimensionValue, msg);
|
||||
}
|
||||
return new DataTime(ref, fcst);
|
||||
}
|
||||
|
||||
/**
|
||||
* If time is not null, parses time. Else, latest time is extracted from
|
||||
* layer.
|
||||
*
|
||||
* @param layer
|
||||
* @param time
|
||||
* @return
|
||||
* @throws WmsException
|
||||
*/
|
||||
protected Calendar getValidTime(SimpleLayer layer, String time)
|
||||
throws OgcException {
|
||||
Calendar rval;
|
||||
if (time == null) {
|
||||
try {
|
||||
Date latestTime = LayerTransformer.getLatestTime(layer);
|
||||
if (latestTime == null) {
|
||||
throw new OgcException(Code.LayerNotDefined,
|
||||
"Unable to find layer: " + layer);
|
||||
}
|
||||
rval = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
rval.setTime(latestTime);
|
||||
} catch (Exception e) {
|
||||
log.error("Problem getting layer", e);
|
||||
throw new OgcException(Code.InternalServerError);
|
||||
}
|
||||
} else {
|
||||
rval = parseTimeStr(time, "time");
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.edex.plugin.grib.ogc</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,8 +0,0 @@
|
|||
#Thu Jun 07 13:59:55 CDT 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,32 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ogc
|
||||
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.grib.ogc
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Require-Bundle: org.springframework;bundle-version="2.5.6",
|
||||
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.time;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0",
|
||||
javax.persistence;bundle-version="1.0.0",
|
||||
org.apache.commons.lang;bundle-version="2.3.0",
|
||||
org.apache.commons.logging;bundle-version="1.1.1",
|
||||
com.raytheon.uf.edex.database;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
|
||||
org.hibernate;bundle-version="1.0.0",
|
||||
org.geotools;bundle-version="2.6.4",
|
||||
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.edex.wms;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.wcs;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.core;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.gridcoverage;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.spatial;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datadelivery.registry;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.datadelivery.harvester;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.dataplugin.grib;bundle-version="1.12.1174"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.edex.plugin.grib.ogc
|
|
@ -1,2 +0,0 @@
|
|||
com.raytheon.uf.edex.plugin.grib.ogc.GribDimension
|
||||
com.raytheon.uf.edex.plugin.grib.ogc.GribLayer
|
|
@ -1,5 +0,0 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
res/
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue