diff --git a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml index ff2dcb2510..2f9468f542 100644 --- a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml @@ -77,13 +77,6 @@ version="0.0.0" unpack="false"/> - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cots/net.opengis/.project b/cots/net.opengis/.project deleted file mode 100644 index b6e50c025b..0000000000 --- a/cots/net.opengis/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - net.opengis - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/cots/net.opengis/.settings/org.eclipse.jdt.core.prefs b/cots/net.opengis/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f4d0b5d267..0000000000 --- a/cots/net.opengis/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -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 diff --git a/cots/net.opengis/META-INF/MANIFEST.MF b/cots/net.opengis/META-INF/MANIFEST.MF deleted file mode 100644 index e8c25f14b1..0000000000 --- a/cots/net.opengis/META-INF/MANIFEST.MF +++ /dev/null @@ -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 diff --git a/cots/net.opengis/build.properties b/cots/net.opengis/build.properties deleted file mode 100644 index 325c31687d..0000000000 --- a/cots/net.opengis/build.properties +++ /dev/null @@ -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 diff --git a/cots/net.opengis/filter-v_1_0_0-schema-1.0.2.jar b/cots/net.opengis/filter-v_1_0_0-schema-1.0.2.jar deleted file mode 100644 index ea2d0755bd..0000000000 Binary files a/cots/net.opengis/filter-v_1_0_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/filter-v_1_1_0-schema-1.0.2.jar b/cots/net.opengis/filter-v_1_1_0-schema-1.0.2.jar deleted file mode 100644 index 3ad3689169..0000000000 Binary files a/cots/net.opengis/filter-v_1_1_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/gml-v_2_1_2-schema-1.0.2.jar b/cots/net.opengis/gml-v_2_1_2-schema-1.0.2.jar deleted file mode 100644 index f4d81ed7ba..0000000000 Binary files a/cots/net.opengis/gml-v_2_1_2-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/gml-v_3_1_1-schema-1.0.2.jar b/cots/net.opengis/gml-v_3_1_1-schema-1.0.2.jar deleted file mode 100644 index ba19a4ab83..0000000000 Binary files a/cots/net.opengis/gml-v_3_1_1-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/jaxb2-basics-runtime-0.6.0.jar b/cots/net.opengis/jaxb2-basics-runtime-0.6.0.jar deleted file mode 100644 index 129c920a23..0000000000 Binary files a/cots/net.opengis/jaxb2-basics-runtime-0.6.0.jar and /dev/null differ diff --git a/cots/net.opengis/kml-v_2_2_0-schema-1.0.3.jar b/cots/net.opengis/kml-v_2_2_0-schema-1.0.3.jar deleted file mode 100644 index 4d4452fd37..0000000000 Binary files a/cots/net.opengis/kml-v_2_2_0-schema-1.0.3.jar and /dev/null differ diff --git a/cots/net.opengis/net.opengis.ecl b/cots/net.opengis/net.opengis.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cots/net.opengis/ows-v_1_0_0-schema-1.0.2.jar b/cots/net.opengis/ows-v_1_0_0-schema-1.0.2.jar deleted file mode 100644 index 209386d829..0000000000 Binary files a/cots/net.opengis/ows-v_1_0_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/ows-v_1_1_0-schema-1.0.2.jar b/cots/net.opengis/ows-v_1_1_0-schema-1.0.2.jar deleted file mode 100644 index fe34dce62a..0000000000 Binary files a/cots/net.opengis/ows-v_1_1_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/se-v_1_1_0-schema-1.0.2.jar b/cots/net.opengis/se-v_1_1_0-schema-1.0.2.jar deleted file mode 100644 index 04f9a99d49..0000000000 Binary files a/cots/net.opengis/se-v_1_1_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/sld-v_1_0_0-schema-1.0.2.jar b/cots/net.opengis/sld-v_1_0_0-schema-1.0.2.jar deleted file mode 100644 index 96bfcc22e4..0000000000 Binary files a/cots/net.opengis/sld-v_1_0_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/sld-v_1_1_0-schema-1.0.2.jar b/cots/net.opengis/sld-v_1_1_0-schema-1.0.2.jar deleted file mode 100644 index 002563eca8..0000000000 Binary files a/cots/net.opengis/sld-v_1_1_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/wcs-v_1_1_2-schema-1.0.2.jar b/cots/net.opengis/wcs-v_1_1_2-schema-1.0.2.jar deleted file mode 100644 index 206af3c409..0000000000 Binary files a/cots/net.opengis/wcs-v_1_1_2-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/wfs-v_1_1_0-schema-1.0.2.jar b/cots/net.opengis/wfs-v_1_1_0-schema-1.0.2.jar deleted file mode 100644 index 2055675857..0000000000 Binary files a/cots/net.opengis/wfs-v_1_1_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/wms-v_1_3_0-schema-1.0.2.jar b/cots/net.opengis/wms-v_1_3_0-schema-1.0.2.jar deleted file mode 100644 index 4fc69149dd..0000000000 Binary files a/cots/net.opengis/wms-v_1_3_0-schema-1.0.2.jar and /dev/null differ diff --git a/cots/net.opengis/wmts-v_1_0_0-schema-1.0.3.1.jar b/cots/net.opengis/wmts-v_1_0_0-schema-1.0.3.1.jar deleted file mode 100644 index f4c049b9de..0000000000 Binary files a/cots/net.opengis/wmts-v_1_0_0-schema-1.0.3.1.jar and /dev/null differ diff --git a/cots/ogc.tools.gml/.classpath b/cots/ogc.tools.gml/.classpath deleted file mode 100644 index 452eab1820..0000000000 --- a/cots/ogc.tools.gml/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/cots/ogc.tools.gml/.project b/cots/ogc.tools.gml/.project deleted file mode 100644 index eadb43c2ff..0000000000 --- a/cots/ogc.tools.gml/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - ogc.tools.gml - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/cots/ogc.tools.gml/.settings/org.eclipse.jdt.core.prefs b/cots/ogc.tools.gml/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 39808a517b..0000000000 --- a/cots/ogc.tools.gml/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -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 diff --git a/cots/ogc.tools.gml/META-INF/MANIFEST.MF b/cots/ogc.tools.gml/META-INF/MANIFEST.MF deleted file mode 100644 index 8d7e4700a8..0000000000 --- a/cots/ogc.tools.gml/META-INF/MANIFEST.MF +++ /dev/null @@ -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 diff --git a/cots/ogc.tools.gml/build.properties b/cots/ogc.tools.gml/build.properties deleted file mode 100644 index 8c28283f04..0000000000 --- a/cots/ogc.tools.gml/build.properties +++ /dev/null @@ -1,3 +0,0 @@ -bin.includes = META-INF/,\ - .,\ - ogc-tools-gml-jts-1.0.2.jar diff --git a/cots/ogc.tools.gml/ogc-tools-gml-jts-1.0.2.jar b/cots/ogc.tools.gml/ogc-tools-gml-jts-1.0.2.jar deleted file mode 100644 index f3d63f7112..0000000000 Binary files a/cots/ogc.tools.gml/ogc-tools-gml-jts-1.0.2.jar and /dev/null differ diff --git a/cots/ogc.tools.gml/ogc.tools.gml.ecl b/cots/ogc.tools.gml/ogc.tools.gml.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.common.spatial/.classpath b/edexOsgi/com.raytheon.uf.common.spatial/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.common.spatial/.project b/edexOsgi/com.raytheon.uf.common.spatial/.project deleted file mode 100644 index f8fdc72bc1..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.common.spatial - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.common.spatial/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.spatial/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 295d77f55d..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -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 diff --git a/edexOsgi/com.raytheon.uf.common.spatial/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.spatial/META-INF/MANIFEST.MF deleted file mode 100644 index 5da49e577a..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/META-INF/MANIFEST.MF +++ /dev/null @@ -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" - diff --git a/edexOsgi/com.raytheon.uf.common.spatial/build.properties b/edexOsgi/com.raytheon.uf.common.spatial/build.properties deleted file mode 100644 index 34d2e4d2da..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/edexOsgi/com.raytheon.uf.common.spatial/com.raytheon.uf.common.spatial.ecl b/edexOsgi/com.raytheon.uf.common.spatial/com.raytheon.uf.common.spatial.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/AbstractDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/AbstractDataReprojector.java deleted file mode 100644 index 6d371973d6..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/AbstractDataReprojector.java +++ /dev/null @@ -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 { - - 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); - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ByteDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ByteDataReprojector.java deleted file mode 100644 index bb0f55e88c..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ByteDataReprojector.java +++ /dev/null @@ -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 { - - 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 }); - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/DataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/DataReprojector.java deleted file mode 100644 index ae208ad2a2..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/DataReprojector.java +++ /dev/null @@ -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 _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 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 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 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 ids = crs.getIdentifiers(); - String code; - if (ids == null || ids.isEmpty()) { - code = crs.getName().toString(); - } else { - Iterator 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/FloatDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/FloatDataReprojector.java deleted file mode 100644 index 4d1da89252..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/FloatDataReprojector.java +++ /dev/null @@ -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 { - - 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 }); - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/IntDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/IntDataReprojector.java deleted file mode 100644 index 384c15466c..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/IntDataReprojector.java +++ /dev/null @@ -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 { - - 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 }); - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/KeyLocker.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/KeyLocker.java deleted file mode 100644 index b47c48408f..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/KeyLocker.java +++ /dev/null @@ -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 locks = new HashMap(); - - 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); - } - } - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ReferencedDataRecord.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ReferencedDataRecord.java deleted file mode 100644 index fd38a68b2d..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ReferencedDataRecord.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ShortDataReprojector.java b/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ShortDataReprojector.java deleted file mode 100644 index 4c40a28930..0000000000 --- a/edexOsgi/com.raytheon.uf.common.spatial/src/com/raytheon/uf/common/spatial/reprojection/ShortDataReprojector.java +++ /dev/null @@ -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 { - - 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 }); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.common.core.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.common.core.feature/feature.xml index 485093c9eb..0a3af798e1 100644 --- a/edexOsgi/com.raytheon.uf.edex.common.core.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.common.core.feature/feature.xml @@ -112,13 +112,6 @@ version="0.0.0" unpack="false"/> - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/.project b/edexOsgi/com.raytheon.uf.edex.ogc.common/.project deleted file mode 100644 index ce62be234b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.ogc.common - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.ogc.common/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 03445bee4a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -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 diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF deleted file mode 100644 index a23d2ca4dd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/META-INF/MANIFEST.MF +++ /dev/null @@ -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 diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/build.properties b/edexOsgi/com.raytheon.uf.edex.ogc.common/build.properties deleted file mode 100644 index e016089273..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/build.properties +++ /dev/null @@ -1,8 +0,0 @@ -source.. = src/ -bin.includes = .project,\ - .classpath,\ - META-INF/,\ - build.properties,\ - .settings/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/com.raytheon.uf.edex.ogc.common.ecl b/edexOsgi/com.raytheon.uf.edex.ogc.common/com.raytheon.uf.edex.ogc.common.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/res/spring/ogc-common.xml b/edexOsgi/com.raytheon.uf.edex.ogc.common/res/spring/ogc-common.xml deleted file mode 100644 index 1cd58500ce..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/res/spring/ogc-common.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcBoundingBox.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcBoundingBox.java deleted file mode 100644 index e39621257d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcBoundingBox.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcDimension.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcDimension.java deleted file mode 100644 index 2302c233a6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcDimension.java +++ /dev/null @@ -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 values; - - protected String defaultVal; - - /** - * - */ - public OgcDimension() { - } - - public OgcDimension(String name, List values) { - this(name, "", values); - } - - public OgcDimension(String name, String units, List values) { - this(name, units, null, values); - } - - public OgcDimension(String name, String units, String unitSymbol, - List 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 getValues() { - return values; - } - - /** - * @param values - * the values to set - */ - public void setValues(List 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcException.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcException.java deleted file mode 100644 index acf73b3d7f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcException.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcGeoBoundingBox.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcGeoBoundingBox.java deleted file mode 100644 index b2298cafb2..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcGeoBoundingBox.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcLayer.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcLayer.java deleted file mode 100644 index a902793615..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcLayer.java +++ /dev/null @@ -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 children; - - protected String name; - - protected String title; - - protected List keywords; - - protected String abs; - - protected List styles; - - protected OgcGeoBoundingBox geoBoundingBox; - - protected List boundingBox; - - protected List crs; - - protected double minScaleDenom = Double.NaN; - - protected double maxScaleDenom = Double.NaN; - - protected boolean opaque; - - protected int sizeRecord = 0; - - protected List dimensions; - - protected static String keySeparator = "/"; - - public void addCRS(String crs) { - this.crs = addToList(this.crs, crs); - } - - protected List addToList(List l, T item) { - if (l == null) { - l = new ArrayList(); - } - 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 getDimensions() { - return dimensions; - } - - /** - * @param dimensions - * the dimentions to set - */ - public void setDimensions(List dimensions) { - this.dimensions = dimensions; - } - - public OgcLayer getParent() { - return parent; - } - - public void setParent(OgcLayer parent) { - this.parent = parent; - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public List getStyles() { - return styles; - } - - public void setStyles(List 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 getCrs() { - return crs; - } - - public void setCrs(List crs) { - this.crs = crs; - } - - /** - * @return the boundingBox - */ - public List getBoundingBox() { - return boundingBox; - } - - /** - * @param boundingBox - * the boundingBox to set - */ - public void setBoundingBox(List 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 getKeywords() { - return keywords; - } - - public void setKeywords(List 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcNamespace.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcNamespace.java deleted file mode 100644 index e9dd68f0cb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcNamespace.java +++ /dev/null @@ -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"; - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcOperationInfo.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcOperationInfo.java deleted file mode 100644 index 7bc69e82ac..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcOperationInfo.java +++ /dev/null @@ -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 { - - protected T type; - - protected String httpPostRes; - - protected String httpGetRes; - - protected List formats = new LinkedList(); - - protected List versions = new LinkedList(); - - protected List acceptversions = new LinkedList(); - - protected List services = new LinkedList(); - - protected List identifiers = new LinkedList(); - - protected List interpolationtypes = new LinkedList(); - - /** - * - */ - 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 getFormats() { - return formats; - } - - /** - * @param formats - * the formats to set - */ - public void setFormats(List formats) { - this.formats = formats; - } - - /** - * @return the versions - */ - public List getVersions() { - return versions; - } - - /** - * @param versions - * the versions to set - */ - public void setVersions(List versions) { - this.versions = versions; - } - - public List getAcceptversions() { - return acceptversions; - } - - public void setAcceptversions(List acceptversions) { - this.acceptversions = acceptversions; - } - - public List getServices() { - return services; - } - - public void setServices(List services) { - this.services = services; - } - - public List getIdentifiers() { - return identifiers; - } - - public void setIdentifiers(List identifiers) { - this.identifiers = identifiers; - } - - public List getInterpolationtypes() { - return interpolationtypes; - } - - public void setInterpolationtypes(List interpolationtypes) { - this.interpolationtypes = interpolationtypes; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcPrefix.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcPrefix.java deleted file mode 100644 index d47160e3fa..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcPrefix.java +++ /dev/null @@ -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"; -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcResponse.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcResponse.java deleted file mode 100644 index 09b15f4bf5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcResponse.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcServiceInfo.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcServiceInfo.java deleted file mode 100644 index b5adef3e12..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcServiceInfo.java +++ /dev/null @@ -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 { - protected String onlineResource; - - protected List> operations = new LinkedList>(); - - /** - * - */ - public OgcServiceInfo(String onlineResouce) { - this.onlineResource = onlineResouce; - } - - public void addOperationInfo(OgcOperationInfo 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> getOperations() { - return operations; - } - - /** - * @param operations - * the operations to set - */ - public void setOperations(List> operations) { - this.operations = operations; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcStyle.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcStyle.java deleted file mode 100644 index 6509ce1f98..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/OgcStyle.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/StyleLookup.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/StyleLookup.java deleted file mode 100644 index cc2a21c0e0..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/StyleLookup.java +++ /dev/null @@ -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 getStyles(); - - public void setLoader(ClassLoader loader); - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/ColorbarLabeling.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/ColorbarLabeling.java deleted file mode 100644 index 54592a5d63..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/ColorbarLabeling.java +++ /dev/null @@ -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; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/LevelRange.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/LevelRange.java deleted file mode 100644 index 95c57394ec..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/LevelRange.java +++ /dev/null @@ -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; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/MapRange.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/MapRange.java deleted file mode 100644 index 77b0a7cfe3..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/MapRange.java +++ /dev/null @@ -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; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/StyleRule.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/StyleRule.java deleted file mode 100644 index 54da933899..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/StyleRule.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/StyleRuleLibrary.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/StyleRuleLibrary.java deleted file mode 100644 index bfddc05b81..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/colormap/StyleRuleLibrary.java +++ /dev/null @@ -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 rules; - - private Log log = LogFactory.getLog(this.getClass()); - - private Map> _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 rules) { - this.rules = rules; - } - - public List getRules() { - return rules; - } - - protected Map> getRuleMap() { - if (_ruleMap == null && rules != null) { - _ruleMap = new HashMap>(); - for (StyleRule rule : rules) { - String cmap = rule.getColorMapName(); - List list = _ruleMap.get(cmap); - if (list == null) { - list = new ArrayList(); - _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 dimensions, - Map 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 dimensions, - Map 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 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 dimensions, Map 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 dimensions, Map 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()); - } - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/DefaultLayerCollector.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/DefaultLayerCollector.java deleted file mode 100644 index 32669ddf25..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/DefaultLayerCollector.java +++ /dev/null @@ -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 - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      initial creation, based on B Clements original
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public abstract class DefaultLayerCollector - extends LayerCollector { - - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(DefaultLayerCollector.class); - - protected Class recordClass; - - protected Class layerClass; - - public DefaultLayerCollector(LayerTransformer transformer, - Class layerClass, Class 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 coll) { - HashMap layermap = new HashMap(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 layermap, - Collection 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 recs = (List) 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); - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerCollector.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerCollector.java deleted file mode 100644 index ab5698f465..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerCollector.java +++ /dev/null @@ -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 - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      initial creation, based on B Clements original
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public abstract class LayerCollector { - - protected LayerTransformer transformer; - - protected L layer; - - protected HarvesterConfig config = null; - - protected OGCAgent agent = null; - - protected Map 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 void clearLayers(Class c) - throws DataAccessLayerException { - DaoConfig conf = DaoConfig.forClass(c); - CoreDao dao = new CoreDao(conf); - List res = dao.queryByCriteria(new DatabaseQuery(c)); - dao.deleteAll(res); - } - - public 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 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 times = old.getTimes(); - times.clear(); - Set 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 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 list = query(sess, layer); - if (list.isEmpty()) { - Set 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 void update(T old, T shiny) { - updateDates(old, shiny); - updateDims(old, shiny); - } - - public void updateDates(T old, T shiny) { - Set shinyTimes = shiny.getTimes(); - Set oldTimes = old.getTimes(); - if (shinyTimes != null && shinyTimes != null) { - for (Date time : shinyTimes) { - oldTimes.add(time); - } - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void updateDims(T old, T shiny) { - Set oldDims = old.getDimensions(); - Set shinyDims = shiny.getDimensions(); - if (oldDims != null) { - if (shinyDims != null) { - updateDimLists(oldDims, shinyDims); - } - } - } - - public HashMap getDimMap(Set dims) { - HashMap rval = new HashMap(dims.size()); - for (T sd : dims) { - rval.put(sd.getName(), sd); - } - return rval; - } - - public void updateDimLists(Set oldDims, - Set shinyDims) { - HashMap oldMap = getDimMap(oldDims); - HashMap 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 oldValues = oldDim.getValues(); - Set shinyValues = shinyDim.getValues(); - if (oldValues != null && shinyValues != null) { - for (String val : shinyValues) { - oldValues.add(val); - } - } - } - - @SuppressWarnings("unchecked") - public List query(Session sess, T layer) - throws DataAccessLayerException { - Class 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 List query(Session sess, String layerName) - throws DataAccessLayerException { - Class 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 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(); - for (Parameter parm : agent.getLayer(layer.getName()) - .getParameters()) { - // place in map - parameters.put(parm.getName(), parm); - storeParameter(parm); - } - } - } - } - - public Map 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerHolder.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerHolder.java deleted file mode 100644 index dd3354b20d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerHolder.java +++ /dev/null @@ -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 { - @XmlElement - protected L value; - - @SuppressWarnings("unchecked") - public static Class> getDefaultClass() { - return (Class>) new LayerHolder() - .getClass(); - } - - public L getValue() { - return value; - } - - public void setValue(L value) { - this.value = value; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerTransformer.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerTransformer.java deleted file mode 100644 index 449fd53d92..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/LayerTransformer.java +++ /dev/null @@ -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 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 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 params = Arrays.asList(new QueryParam(field, name)); - List 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 getDimValuesAsDouble(SimpleDimension dim) { - TreeSet rval = new TreeSet(); - 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 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 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 getTimes(SimpleLayer layer) { - return getTimes(layer, TimeFormat.LIST); - } - - /** - * @param layer - * @param tformat - * @return - */ - public static List getTimes(SimpleLayer layer, TimeFormat tformat) { - List 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 getTimesAsHourRanges(SimpleLayer layer) { - Set times = layer.getTimes(); - if (times == null || times.isEmpty()) { - return new ArrayList(0); - } - Set set = new TreeSet(); - set.addAll(times); - Iterator i = set.iterator(); - StringBuilder sb = new StringBuilder(); - List rval = new ArrayList(); - 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 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 getTimesAsList(SimpleLayer layer) { - Set times = layer.getTimes(); - if (times == null || times.isEmpty()) { - return new ArrayList(0); - } - TreeSet sorted = new TreeSet(times); - Iterator i = sorted.iterator(); - List rval = new ArrayList(sorted.size()); - while (i.hasNext()) { - rval.add(format(i.next())); - } - return rval; - } - - public TreeSet getAllTimes() { - TreeSet rval = new TreeSet(); - List layers = getLayers(); - for (SimpleLayer l : layers) { - rval.addAll(l.getTimes()); - } - return rval; - } - - @SuppressWarnings("unchecked") - public List getLayers() { - List rval; - rval = (List) query(layerClass); - return rval; - } - - public List getLayersAsOgc(TimeFormat tformat, StyleLookup lookup) { - return transform(getLayers(), tformat, lookup); - } - - public List getLayersAsOgc(StyleLookup lookup) { - return getLayersAsOgc(TimeFormat.LIST, lookup); - } - - /** - * @param layers - * @return - */ - protected List transform(List layers, - TimeFormat tformat, StyleLookup lookup) { - List rval = new ArrayList(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 - *

- * 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 dims) { - if (dims == null) { - return new OgcDimension[0]; - } - ArrayList rval = new ArrayList(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 values = new ArrayList(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 List query(Class c) { - return query(c, null); - } - - @SuppressWarnings("unchecked") - protected List query(Class c, List 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) dao.queryByCriteria(query); - } catch (Exception e) { - log.error("Unable to query entity: " + c, e); - return new ArrayList(0); - } - } - - protected > List unwrap( - List holders) { - List rval = new ArrayList(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 times = layer.getTimes(); - TreeSet sorted = new TreeSet(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 layerClass) { - this.layerClass = layerClass; - } - - /** - * @return the layerClass - */ - public Class getLayerClass() { - return layerClass; - } - - /** - * @return - */ - public TreeSet getLatestTimes() { - List layers = getLayers(); - TreeSet rval = new TreeSet(); - for (SimpleLayer l : layers) { - TreeSet times = new TreeSet(l.getTimes()); - rval.add(times.last()); - } - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SimpleDimension.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SimpleDimension.java deleted file mode 100644 index 4ad1a8c49d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SimpleDimension.java +++ /dev/null @@ -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 { - - @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 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 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; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SimpleLayer.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SimpleLayer.java deleted file mode 100644 index ab15680a55..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/SimpleLayer.java +++ /dev/null @@ -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 { - - @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 getDimensions(); - - /** - * @return live reference to times set, should not return null - */ - public abstract SortedSet 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/WCSLayerCollector.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/WCSLayerCollector.java deleted file mode 100644 index b4759b564c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/WCSLayerCollector.java +++ /dev/null @@ -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 - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      Modified from a class written by Brian Clements
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public abstract class WCSLayerCollector - extends LayerCollector implements IWCSMetaData { - - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(WCSLayerCollector.class); - - protected Class recordClass; - - protected Class layerClass; - - protected GriddedDataSet gds = null; - - protected GriddedDataSetMetaData gdsmd = null; - - protected Time time = null; - - - public WCSLayerCollector(LayerTransformer transformer, - Class layerClass, Class 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 coll) { - HashMap layermap = new HashMap(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 recs = (List) 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 levelList = LookupManager.getInstance() - .getLevels(collectionName).getLevelXml(); - levels.setLevel(levelList); - - } else if (type.getType().equals(LevelType.SEAB.getLevelType())) { - List 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; - } - - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/WFSLayerCollector.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/WFSLayerCollector.java deleted file mode 100644 index 0230a97f19..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/db/WFSLayerCollector.java +++ /dev/null @@ -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 - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      initial creation
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public abstract class WFSLayerCollector extends LayerCollector implements IWFSMetaData { - - 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 times = new ArrayList(); - // 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/FeatureFactory.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/FeatureFactory.java deleted file mode 100644 index a8e49eeb0c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/FeatureFactory.java +++ /dev/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 convert(PluginDataObject[] pdos); - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/JsonFeatureFormatter.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/JsonFeatureFormatter.java deleted file mode 100644 index e5d9cde5a4..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/JsonFeatureFormatter.java +++ /dev/null @@ -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> features) - throws Exception { - List> colls = new ArrayList>( - features.size()); - for (List 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); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/ShpFeatureFormatter.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/ShpFeatureFormatter.java deleted file mode 100644 index 458de0bcc9..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/ShpFeatureFormatter.java +++ /dev/null @@ -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> features) - throws Exception { - List> colls = new ArrayList>( - features.size()); - for (List 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 coll) - throws Exception { - SimpleFeatureType schema = coll.getSchema(); - ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory(); - File f = new File(dir, schema.getTypeName() + ".shp"); - Map params = new HashMap(); - 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 featureSource = newDataStore - .getFeatureSource(typeName); - if (featureSource instanceof FeatureStore) { - FeatureStore featureStore = (FeatureStore) 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/SimpleFeatureFormatter.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/SimpleFeatureFormatter.java deleted file mode 100644 index bc044581ae..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/feature/SimpleFeatureFormatter.java +++ /dev/null @@ -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> features) - throws Exception; - - public String getMimeType(); - - public boolean matchesFormat(String format); -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpEndpoint.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpEndpoint.java deleted file mode 100644 index 2514c8adeb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpEndpoint.java +++ /dev/null @@ -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 - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 
- * 
- * - * @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 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); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpHandler.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpHandler.java deleted file mode 100644 index 1df4fe2987..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpHandler.java +++ /dev/null @@ -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); -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpPool.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpPool.java deleted file mode 100644 index 70ba45658f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpPool.java +++ /dev/null @@ -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(); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpRequest.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpRequest.java deleted file mode 100644 index 729034601e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/http/OgcHttpRequest.java +++ /dev/null @@ -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 headers; - - protected InputStream inputStream; - - public OgcHttpRequest(HttpServletRequest request, - HttpServletResponse response, Map 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 getHeaders() { - return headers; - } - - public void setHeaders(Map headers) { - this.headers = headers; - } - - public InputStream getInputStream() { - return inputStream; - } - - public void setInputStream(InputStream inputStream) { - this.inputStream = inputStream; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/interfaces/IWCSMetaData.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/interfaces/IWCSMetaData.java deleted file mode 100644 index 233a6e8d4c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/interfaces/IWCSMetaData.java +++ /dev/null @@ -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 - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      Initial
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public interface IWCSMetaData { - - public void sendMetaData(Map layermap, - Collection coll); - -} - diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/interfaces/IWFSMetaData.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/interfaces/IWFSMetaData.java deleted file mode 100644 index 3cdb8ec911..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/interfaces/IWFSMetaData.java +++ /dev/null @@ -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 - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      Initial
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public interface IWFSMetaData { - - public void sendMetaData(L layer); - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/jaxb/OgcJaxbManager.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/jaxb/OgcJaxbManager.java deleted file mode 100644 index 1a0f38057b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/jaxb/OgcJaxbManager.java +++ /dev/null @@ -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 unmarshallers = new ConcurrentLinkedQueue(); - - protected Queue marshallers = new ConcurrentLinkedQueue(); - - protected int unmarshallersCreated = 0; - - protected int marshallersCreated = 0; - - protected Log log = LogFactory.getLog(this.getClass()); - - protected Map 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 getPrefixMap() { - return prefixMap; - } - - public void setPrefixMap(final Map 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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/output/OgcResponseOutput.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/output/OgcResponseOutput.java deleted file mode 100644 index b76c4bb48c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/output/OgcResponseOutput.java +++ /dev/null @@ -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(); - } - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/CrsLookup.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/CrsLookup.java deleted file mode 100644 index 98d2d27408..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/CrsLookup.java +++ /dev/null @@ -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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/RecordUtil.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/RecordUtil.java deleted file mode 100644 index 5bcfe79fa1..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/spatial/RecordUtil.java +++ /dev/null @@ -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 - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 26, 2013 1638       mschenke    Code moved from PluginDao to clean up dependencies
- * 
- * 
- * - * @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"); - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/time/ForecastTimeUtil.java b/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/time/ForecastTimeUtil.java deleted file mode 100644 index 4d63c18461..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.ogc.common/src/com/raytheon/uf/edex/ogc/common/time/ForecastTimeUtil.java +++ /dev/null @@ -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 getDataTimes(SimpleLayer layer, - Map 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 getDataTimes(SimpleLayer layer, String time, - Map dimensions) throws OgcException { - Calendar validTime = getValidTime(layer, time); - return getDataTimes(layer, validTime, dimensions); - } - - public SortedSet getDataTimes(SimpleLayer layer, Date time, - Map 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 getDataTimes(SimpleLayer layer, - Calendar time, - Map dimensions) throws OgcException { - String refStr = dimensions.get(refKey); - String fcstStr = dimensions.get(fcstKey); - SortedSet rval = new TreeSet(); - 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 getCandidates(SimpleLayer layer, - Calendar validTime) throws OgcException { - SimpleDimension refDim = getDimension(layer, refKey); - SimpleDimension fcstDim = getDimension(layer, fcstKey); - TreeSet fcsts = LayerTransformer.getDimValuesAsDouble(fcstDim); - Set refVals = refDim.getValues(); - ArrayList refs; - try { - refs = convert(refVals); - } catch (Exception e) { - log.error("invalid date in layer: " + layer, e); - throw new OgcException(Code.InternalServerError); - } - SortedSet rval = new TreeSet(); - // 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 convert(Set times) - throws OgcException { - ArrayList refs = new ArrayList(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; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.classpath b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.classpath deleted file mode 100644 index ad32c83a78..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.project b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.project deleted file mode 100644 index e0c6cc143e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.plugin.grib.ogc - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 2c609c7dad..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -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 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/META-INF/MANIFEST.MF deleted file mode 100644 index b0996d163c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/META-INF/MANIFEST.MF +++ /dev/null @@ -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 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index 9d22ff0cf3..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1,2 +0,0 @@ -com.raytheon.uf.edex.plugin.grib.ogc.GribDimension -com.raytheon.uf.edex.plugin.grib.ogc.GribLayer \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/build.properties b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/build.properties deleted file mode 100644 index 5791d48d5f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/com.raytheon.uf.edex.plugin.grib.ogc.ecl b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/com.raytheon.uf.edex.plugin.grib.ogc.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/component-deploy.xml b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/component-deploy.xml deleted file mode 100644 index a48bf50a64..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/component-deploy.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/res/spring/grib-dpa-ingest.xml b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/res/spring/grib-dpa-ingest.xml deleted file mode 100644 index ade7447b1b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/res/spring/grib-dpa-ingest.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - grib - - - - - - - - - grib - - - - - - - - - - - - - - - - - java.lang.Throwable - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/res/spring/grib-ogc.xml b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/res/spring/grib-ogc.xml deleted file mode 100644 index f34dd54a29..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/res/spring/grib-ogc.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribDimension.java b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribDimension.java deleted file mode 100644 index 4fcf700b3f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribDimension.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.raytheon.uf.edex.plugin.grib.ogc; - -import java.util.HashMap; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.persistence.ElementCollection; -import javax.persistence.Embeddable; -import javax.persistence.Entity; -import javax.persistence.FetchType; -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 org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.ogc.common.OgcException; -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; -import com.raytheon.uf.edex.ogc.common.time.ForecastTimeUtil; -import com.raytheon.uf.edex.plugin.grib.ogc.GribDimension; - -@Entity -@Embeddable -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) -@DynamicSerialize -public class GribDimension extends SimpleDimension { - - public static final String REFTIME_DIM = "REFTIME"; - - public static final String FORECAST_OFFSET_DIM = "FORECAST_OFFSET"; - - public static final String LEVEL1_DIM = "LEVEL1"; - - public static final String LEVEL2_DIM = "LEVEL2"; - - public static final String PERTURB_DIM = "PERTURBATION_NUM"; - - public static final String ENSEMBLE_DIM = "ENSEMBLE_TYPE"; - - public static final String VERSION_DIM = "VERSION"; - - private transient DataTime defaultTime = null; - - protected transient Log log = LogFactory.getLog(this.getClass()); - - @XmlElement - @DynamicSerializeElement - @ElementCollection(fetch = FetchType.EAGER) - protected Set values; - - public GribDimension() { - } - - public GribDimension(String name, String units) { - this.name = name; - this.units = units; - this.values = new TreeSet(); - } - - public void setValues(Set values) { - this.values = values; - } - - @Override - public Set getValues() { - return values; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.ogc.common.db.SimpleDimension#getDefaultValue() - */ - @Override - public String getDefaultValue(SimpleLayer layer) { - String rval = null; - if (GribDimension.REFTIME_DIM.equals(name)) { - DataTime time = getDefaultTime(layer); - rval = LayerTransformer.format(time.getRefTime()); - } else if (GribDimension.FORECAST_OFFSET_DIM.equals(name)) { - DataTime time = getDefaultTime(layer); - rval = time.getFcstTime() + "S"; - } else if (GribDimension.LEVEL1_DIM.equals(name)) { - rval = getDouble(true); - } else if (GribDimension.LEVEL2_DIM.equals(name)) { - rval = getDouble(true); - } else if (GribDimension.PERTURB_DIM.equals(name)) { - rval = getInt(true); - } else if (GribDimension.ENSEMBLE_DIM.equals(name)) { - rval = getInt(true); - } else if (GribDimension.VERSION_DIM.equals(name)) { - rval = getInt(true); - } - return rval; - } - - protected DataTime getDefaultTime(SimpleLayer layer) { - if (defaultTime == null){ - try { - SortedSet times = new ForecastTimeUtil() - .getDataTimes(layer, layer.getDefaultTime(), - new HashMap(0)); - defaultTime = times.last(); - } catch (OgcException e) { - log.error("Problem getting default times", e); - return new DataTime(layer.getDefaultTime()); - } - } - return defaultTime; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribLayer.java b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribLayer.java deleted file mode 100644 index c6090d33a5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribLayer.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.raytheon.uf.edex.plugin.grib.ogc; - -import java.util.Date; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.persistence.ElementCollection; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Table; -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 org.hibernate.annotations.Sort; -import org.hibernate.annotations.SortType; - -import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; -import com.raytheon.uf.edex.ogc.common.db.SimpleDimension; -import com.raytheon.uf.edex.ogc.common.db.SimpleLayer; -import com.raytheon.uf.edex.plugin.grib.ogc.GribDimension; - -@Entity -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) -@DynamicSerialize -@Table(name = "griblayers") -public class GribLayer extends SimpleLayer { - - @XmlElement - @DynamicSerializeElement - @Sort(type = SortType.NATURAL) - @ElementCollection(fetch = FetchType.EAGER) - protected SortedSet times; - - @XmlElement - @DynamicSerializeElement - @Embedded - @ElementCollection(fetch = FetchType.EAGER) - protected Set dimensions; - - public GribLayer() { - this(new TreeSet(), new TreeSet()); - } - - public GribLayer(TreeSet times, Set dimensions) { - this.times = times; - this.dimensions = dimensions; - } - - public void setTimes(TreeSet times) { - this.times = times; - } - - public void setDimensions(Set dimensions) { - this.dimensions = dimensions; - } - - @Override - public Set getDimensions() { - return dimensions; - } - - @Override - public SortedSet getTimes() { - return times; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribLayerCollector.java b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribLayerCollector.java deleted file mode 100644 index b6491c3a39..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribLayerCollector.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.raytheon.uf.edex.plugin.grib.ogc; - -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeSet; - -import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.geometry.MismatchedDimensionException; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.TransformException; - -import com.raytheon.uf.common.datadelivery.registry.Coverage; -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.grib.GribModel; -import com.raytheon.uf.common.dataplugin.grib.GribRecord; -import com.raytheon.uf.common.dataplugin.level.Level; -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.gridcoverage.GridCoverage; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.common.time.DataTime; -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; -import com.raytheon.uf.edex.ogc.common.db.WCSLayerCollector; -import com.vividsolutions.jts.geom.Envelope; - -/** - * - * Grib Layer Collector - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   754       dhladky      Modified from a class written by Brian Clements
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public class GribLayerCollector extends - WCSLayerCollector { - - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(GribLayerCollector.class); - - public GribLayerCollector(LayerTransformer transformer) { - super(transformer, GribLayer.class, GribRecord.class); - this.layer = newLayer(); - } - - @Override - protected void addToDims(GribLayer layer, GribRecord rec) { - DataTime dt = rec.getDataTime(); - GribModel modelInfo = rec.getModelInfo(); - Level level = modelInfo.getLevel(); - Set dims = layer.getDimensions(); - for (SimpleDimension d : dims) { - String name = d.getName(); - Set values = d.getValues(); - if (GribDimension.REFTIME_DIM.equals(name)) { - values.add(LayerTransformer.format(dt.getRefTime())); - } else if (GribDimension.FORECAST_OFFSET_DIM.equals(name)) { - values.add(dt.getFcstTime() + "S"); - } else if (GribDimension.LEVEL1_DIM.equals(name)) { - values.add(level.getLevelOneValueAsString()); - } else if (GribDimension.LEVEL2_DIM.equals(name)) { - values.add(level.getLevelTwoValueAsString()); - } else if (GribDimension.PERTURB_DIM.equals(name)) { - values.add(String.valueOf(modelInfo.getPerturbationNumber())); - } else if (GribDimension.ENSEMBLE_DIM.equals(name)) { - values.add(String.valueOf(modelInfo.getTypeEnsemble())); - } else if (GribDimension.VERSION_DIM.equals(name)) { - values.add(String.valueOf(rec.getGridVersion())); - } else { - statusHandler.warn("Unkown grib dimension: " + name); - } - } - } - - @Override - protected void addToTimes(GribLayer layer, GribRecord rec) { - Set times = layer.getTimes(); - times.add(rec.getDataTime().getValidTime().getTime()); - } - - @Override - protected boolean initializeLayer(GribLayer layer, GribRecord rec) { - GribModel model = rec.getModelInfo(); - GridCoverage cov = model.getLocation(); - if (cov == null) { - statusHandler.warn("Recieved record without coverage!"); - return false; - } - layer.setNx(cov.getNx()); - layer.setNy(cov.getNy()); - layer.setTargetCrsCode("CRS:84"); - try { - Envelope env = getProperBounds(cov); - layer.setTargetMinx(env.getMinX()); - layer.setTargetMiny(env.getMinY()); - layer.setTargetMaxx(env.getMaxX()); - layer.setTargetMaxy(env.getMaxY()); - layer.setCrs84Bounds(JTS.toGeometry(env)); - } catch (Exception e) { - statusHandler.error("Unable to get crs84 bounds", e); - return false; - } - layer.setTimes(new TreeSet()); - String levelUnit = rec.getModelInfo().getLevelUnit(); - TreeSet dims = new TreeSet(); - dims.add(new GribDimension(GribDimension.REFTIME_DIM, "ISO8601")); - dims.add(new GribDimension(GribDimension.FORECAST_OFFSET_DIM, "ISO8601")); - dims.add(new GribDimension(GribDimension.LEVEL1_DIM, levelUnit)); - dims.add(new GribDimension(GribDimension.LEVEL2_DIM, levelUnit)); - dims.add(new GribDimension(GribDimension.PERTURB_DIM, null)); - dims.add(new GribDimension(GribDimension.ENSEMBLE_DIM, null)); - dims.add(new GribDimension(GribDimension.VERSION_DIM, null)); - layer.setDimensions(dims); - return true; - } - - protected ReferencedEnvelope getProperBounds(GridCoverage cov) - throws FactoryException, MismatchedDimensionException, - TransformException { - // the polygon is not projected properly, must get native bounds and - // reproject into crs:84 - CoordinateReferenceSystem nativeCrs = cov.getCrs(); - Envelope env = JTS.transform(cov.getGeometry(), - MapUtil.getTransformFromLatLon(nativeCrs)) - .getEnvelopeInternal(); - ReferencedEnvelope nativeEnv = new ReferencedEnvelope(env.getMinX(), - env.getMaxX(), env.getMinY(), env.getMaxY(), nativeCrs); - return nativeEnv.transform(MapUtil.LATLON_PROJECTION, true); - } - - @Override - protected String getLayerName(GribRecord rec) { - GribModel modelInfo = rec.getModelInfo(); - String modelName = modelInfo.getModelName(); - String parameter = modelInfo.getParameterAbbreviation(); - String level = modelInfo.getLevel().getMasterLevel().getName(); - return modelName + "/" + parameter + "/" + level; - } - - @Override - public void sendMetaData(Map layermap, - Collection coll) { - - for (Entry entry : layermap.entrySet()) { - GribLayer layer = (GribLayer) entry.getValue(); - - // for (GribDimension) - - // GriddedDataSetMetaData gdsmd = new GriddedDataSetMetaData(); - // GriddedCoverage griddedCoverage = new GriddedCoverage(); - // GridCoverage gridCoverage = - layer.toString(); - - } - - for (PluginDataObject pdo : coll) { - GribRecord gr = (GribRecord) pdo; - gr.toString(); - } - - } - /** - * Get's the correct gridCoverage - * - * @return - * - * protected GridCoverage getGridCoverage() { - * - * GridCoverage gridCoverage = null; - * - * if (getProvider().getProjection().getName() - * .equals(LatLonGridCoverage.PROJECTION_TYPE)) { gridCoverage = new - * LatLonGridCoverage(); } else if - * (getProvider().getProjection().getName() - * .equals(LambertConformalGridCoverage.PROJECTION_TYPE)) { - * gridCoverage = new LambertConformalGridCoverage(); } else if - * (getProvider().getProjection().getName() - * .equals(MercatorGridCoverage.PROJECTION_TYPE)) { gridCoverage = - * new MercatorGridCoverage(); } else if - * (getProvider().getProjection().getName() - * .equals(PolarStereoGridCoverage.PROJECTION_TYPE)) { gridCoverage - * = new PolarStereoGridCoverage(); } - * - * return gridCoverage; - * - * } - */ -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribRecordFinder.java b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribRecordFinder.java deleted file mode 100644 index 989a7b7884..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribRecordFinder.java +++ /dev/null @@ -1,234 +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 21, 2012 bclement Initial creation -* -*/ -package com.raytheon.uf.edex.plugin.grib.ogc; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.regex.Matcher; - -import org.hibernate.Criteria; -import org.hibernate.SessionFactory; -import org.hibernate.classic.Session; -import org.hibernate.criterion.Disjunction; -import org.hibernate.criterion.Restrictions; - -import com.raytheon.uf.common.dataplugin.grib.GribRecord; -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.database.DataAccessLayerException; -import com.raytheon.uf.edex.database.plugin.PluginDao; -import com.raytheon.uf.edex.database.plugin.PluginFactory; -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; -import com.raytheon.uf.edex.ogc.common.time.ForecastTimeUtil; - -/** - * - * @author bclement - * @version 1.0 - */ -public class GribRecordFinder { - - protected static String level1Key = "level1"; - - protected static String level2Key = "level2"; - - protected static String pertKey = "perturbation_num"; - - protected static String eTypeKey = "ensemble_type"; - - protected static String versKey = "version"; - - public static class Level { - public Double value; - - public String units; - } - - public static List find(LayerTransformer transformer, - String key, String layerName, Date time, - Map dimensions) - throws OgcException { - SimpleLayer l = getLayer(transformer, layerName); - SortedSet times = new ForecastTimeUtil().getDataTimes(l, - time, dimensions); - return findInternal(l, transformer, key, layerName, times, dimensions); - } - - public static List find(LayerTransformer transformer, - String key, String layerName, String time, - Map dimensions) throws OgcException { - SimpleLayer l = getLayer(transformer, layerName); - SortedSet times = new ForecastTimeUtil().getDataTimes(l, - time, dimensions); - return findInternal(l, transformer, key, layerName, times, dimensions); - } - - protected static List findInternal(SimpleLayer l, - LayerTransformer transformer, String key, String layerName, - SortedSet times, Map dimensions) - throws OgcException { - String level1 = getLevel(dimensions, level1Key, l); - String level2 = getLevel(dimensions, level2Key, l); - String ensemble = getIntDim(dimensions, eTypeKey, l); - String pert = getIntDim(dimensions, pertKey, l); - String version = getIntDim(dimensions, versKey, l); - // TODO ensure consistency in which level gets returned - // TODO add support for more dimensions - return query(key, layerName, times, level1, level2, ensemble, pert, - version); - } - - public static SimpleLayer getLayer(LayerTransformer transformer, - String layerName) throws OgcException { - SimpleLayer rval; - try { - rval = transformer.find(layerName); - } catch (DataAccessLayerException e) { - throw new OgcException(Code.InternalServerError, e); - } - if (rval == null) { - throw new OgcException(Code.LayerNotDefined); - } - return rval; - } - - protected static String getIntDim(Map dimensions, - String key, SimpleLayer layer) throws OgcException { - String str = dimensions.get(key); - String rval; - if (str != null) { - try { - Integer i = Integer.parseInt(str); - rval = i.toString(); - } catch (Exception e) { - throw new OgcException(Code.InvalidDimensionValue, key - + " must be a bare integer"); - } - } else { - SimpleDimension dim = LayerTransformer.getDimension(layer, key); - rval = dim.getDefaultValue(layer); - } - return rval; - } - - /** - * @param dimensions - * @param key - * @param l - * @return null if level value not in dimensions and not in layer - */ - protected static String getLevel(Map dimensions, - String key, SimpleLayer layer) { - String dimKey = new String(key).toLowerCase(); - String level = dimensions.get(dimKey); - String rval; - if (level != null) { - Level l = parseLevel(level); - rval = l.value.toString(); - } else { - SimpleDimension dim = LayerTransformer.getDimension(layer, key); - rval = dim.getDefaultValue(layer); - } - return rval; - } - - @SuppressWarnings("unchecked") - protected static List query(String key, String layer, - SortedSet times, String level1, String level2, - String eType, String pert, String version) throws OgcException { - Session sess = null; - try { - PluginDao dao = PluginFactory.getInstance().getPluginDao(key); - SessionFactory sessFact = dao.getSessionFactory(); - sess = sessFact.openSession(); - Criteria criteria = sess.createCriteria(GribRecord.class); - criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); - Disjunction or = Restrictions.disjunction(); - for (DataTime dt : times) { - String uri = getDataUri(key, layer, dt, level1, level2, eType, - pert, - version); - or.add(Restrictions.like("dataURI", uri)); - } - criteria.add(or); - List res = (List) criteria.list(); - return res; - } catch (Exception e) { - throw new OgcException(Code.InternalServerError); - } finally { - if (sess != null) { - sess.close(); - } - } - } - - protected static String getDataUri(String key, String layer, DataTime dt, - String level1, String level2, String eType, String pert, - String version) { - // this is based how the layer name is built in the layers table - // FIXME this is hackish - StringBuilder sb = new StringBuilder("/").append(key); - sb.append('/').append(dt.toString()).append("%/"); - sb.append(layer).append('/').append(level1); - sb.append('/').append(level2).append('/'); - sb.append((eType == null ? "null" : eType)).append('/'); - sb.append((pert == null ? "null" : pert)).append('/'); - sb.append((version == null ? "null" : version)); - return sb.toString().replaceAll(" ", "_"); - } - - protected static Level parseLevel(String level) { - if (level == null) { - return null; - } - Level rval = new Level(); - Matcher m = LayerTransformer.frontDot.matcher(level); - if (m.matches()) { - rval.value = Double.parseDouble(m.group(1)); - rval.units = m.group(2); - } else { - m = LayerTransformer.backDot.matcher(level); - if (m.matches()) { - rval.value = Double.parseDouble(m.group(1)); - rval.units = m.group(2); - } else { - rval = null; - } - } - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribWcsSource.java b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribWcsSource.java deleted file mode 100644 index 22877fede7..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribWcsSource.java +++ /dev/null @@ -1,180 +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 30, 2011 jelkins Initial creation - * - */ -package com.raytheon.uf.edex.plugin.grib.ogc; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.PluginProperties; -import com.raytheon.uf.common.dataplugin.grib.GribRecord; -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.ogc.common.OgcException; -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; -import com.raytheon.uf.edex.plugin.grib.ogc.GribRecordFinder; -import com.raytheon.uf.edex.wcs.WcsException; -import com.raytheon.uf.edex.wcs.WcsException.Code; -import com.raytheon.uf.edex.wcs.reg.CoverageTransform; -import com.raytheon.uf.edex.wcs.reg.DefaultWcsSource; -import com.raytheon.uf.edex.wcs.reg.RangeAxis; -import com.raytheon.uf.edex.wcs.reg.RangeField; - - -/** - * TODO Add Description - * - * @author jelkins - * @version 1.0 - */ -public class GribWcsSource extends DefaultWcsSource { - - private CoverageTransform _cTransform; - - /** - * @param props - * @param layerTable - */ - public GribWcsSource(PluginProperties props, LayerTransformer transformer) { - super(props, transformer); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getCoverageTransform() - */ - @Override - protected CoverageTransform getCoverageTransform() { - if (_cTransform == null) { - _cTransform = new CoverageTransform(transformer.getKey()) { - - @Override - protected List getRangeFields(SimpleLayer layer) { - Set dims = layer.getDimensions(); - List rval = new ArrayList( - dims.size()); - for (SimpleDimension dim : dims) { - rval.add(convert(dim)); - } - return rval; - } - - protected RangeField convert(SimpleDimension dim) { - String name = dim.getName(); - Set fromVals = dim.getValues(); - String units = dim.getUnits(); - RangeField rf = new RangeField(name, null); - List axis = new ArrayList(1); - if ( units == null ){ - // use dim name as axis label - units = name; - } - axis.add(new RangeAxis(units, fromVals)); - rf.setAxis(axis); - return rf; - } - }; - } - return _cTransform; - } - - @Override - protected PluginDataObject getRecord(String identifier, DataTime time, - List rangeFields) throws WcsException { - List res; - try { - Map dimensions = parseRange(rangeFields); - Date d = (time == null ? null : time.getRefTime()); - res = GribRecordFinder.find(transformer, transformer.getKey(), - identifier, d, dimensions); - } catch (OgcException e) { - WcsException err = new WcsException(e); - if (err.getCode().equals(Code.InternalServerError)) { - log.error("Problem getting grib layer: " + identifier); - } - throw err; - } - if (res.isEmpty()) { - throw new WcsException(Code.LayerNotDefined, - "No layer matching all specified dimensions found"); - } - if (res.size() > 1) { - throw new WcsException(Code.InternalServerError, - "Too many matches for criteria"); - } - return res.get(0); - } - - /** - * @param rangeFields - * @return - */ - private Map parseRange(List fields) { - if (fields == null) { - return new HashMap(0); - } - Map rval = new HashMap(fields.size()); - for (RangeField rf : fields) { - String key = rf.getIdentifier().toLowerCase(); - if (rf.getAxis() == null) { - continue; - } - for (RangeAxis ra : rf.getAxis()) { - Set keys = ra.getKeys(); - if (keys != null && !keys.isEmpty()) { - // default to use the first value found - // TODO should throw and error if multiple range values are - // provided - rval.put(key, keys.iterator().next()); - break; - } - } - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.reg.DefaultWcsSource#getNullPadValue() - */ - @Override - protected Object getNullPadValue() { - return new Byte((byte) 0); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribWmsSource.java b/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribWmsSource.java deleted file mode 100644 index 446b7aae38..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.grib.ogc/src/com/raytheon/uf/edex/plugin/grib/ogc/GribWmsSource.java +++ /dev/null @@ -1,115 +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 16, 2011 jelkins Initial creation - * - */ -package com.raytheon.uf.edex.plugin.grib.ogc; - -import java.util.List; -import java.util.Map; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.PluginException; -import com.raytheon.uf.common.dataplugin.PluginProperties; -import com.raytheon.uf.common.dataplugin.grib.GribRecord; -import com.raytheon.uf.edex.ogc.common.OgcException; -import com.raytheon.uf.edex.ogc.common.db.LayerTransformer; -import com.raytheon.uf.edex.plugin.grib.ogc.GribRecordFinder; -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.WmsException.Code; -import com.raytheon.uf.edex.wms.reg.DefaultWmsSource; -import com.raytheon.uf.edex.wms.styling.ColormapStyleProvider; -import com.raytheon.uf.edex.wms.styling.CoverageStyleProvider; - -/** - * - * @author jelkins - * @version 1.0 - */ -public class GribWmsSource extends DefaultWmsSource { - - protected ColormapStyleProvider styler = new ColormapStyleProvider( - "grib_style_library.xml", "Grid/Default"); - - public GribWmsSource(PluginProperties props, LayerTransformer transformer) - throws PluginException { - super(props, props.getPluginName(), transformer); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.reg.DefaultWmsSource#getRecord(java.lang.String, - * java.lang.String, java.lang.String, java.util.Map) - */ - @Override - protected PluginDataObject getRecord(String layer, String time, - String elevation, Map dimensions, - Map levelUnits) throws WmsException { - LayerTransformer transformer; - List res; - try { - transformer = getTransformer(); - res = GribRecordFinder.find(transformer, key, layer, time, - dimensions); - } catch (OgcException e) { - WmsException err = new WmsException(e); - if (err.getCode().equals(Code.InternalServerError)) { - log.error("Problem getting grib layer: " + layer); - } - throw err; - } catch (PluginException e) { - log.error("Unable to get transformer for grib", e); - throw new WmsException(Code.InternalServerError); - } - if (res.isEmpty()) { - throw new WmsException(Code.LayerNotDefined, - "No layer matching all specified dimensions found"); - } - if (res.size() > 1) { - throw new WmsException(Code.InternalServerError, - "Too many matches for criteria"); - } - return res.get(0); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.reg.DefaultWmsSource#getStyleProvider(java.lang - * .String) - */ - @Override - protected CoverageStyleProvider getStyleProvider(String layer) - throws WmsException { - return styler; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.classpath b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.classpath deleted file mode 100644 index 121e527a93..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.project b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.project deleted file mode 100644 index 1560a20a60..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.plugin.obs.ogc - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index de867d125c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Aug 15 11:28:18 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 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/MANIFEST.MF deleted file mode 100644 index 617d959d22..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/MANIFEST.MF +++ /dev/null @@ -1,33 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Ogc -Bundle-SymbolicName: com.raytheon.uf.edex.plugin.obs.ogc -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: RAYTHEON -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.geotools;bundle-version="2.6.4", - javax.measure;bundle-version="1.0.0", - com.raytheon.edex.plugin.obs;bundle-version="1.12.1174", - com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", - com.raytheon.uf.common.dataplugin.obs;bundle-version="1.0.0", - com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", - com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0", - net.opengis;bundle-version="1.0.2", - com.raytheon.uf.common.pointdata;bundle-version="1.12.1174", - com.raytheon.uf.edex.wfs;bundle-version="1.0.0", - com.raytheon.uf.common.status;bundle-version="1.12.1174", - org.hibernate;bundle-version="1.0.0", - com.raytheon.uf.edex.database;bundle-version="1.0.0", - org.apache.commons.logging;bundle-version="1.1.1", - com.raytheon.uf.edex.core;bundle-version="1.12.1174", - com.raytheon.uf.edex.wms;bundle-version="1.0.0", - com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.raytheon.uf.common.serialization;bundle-version="1.12.1174", - javax.persistence;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" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Bundle-ActivationPolicy: lazy -Export-Package: com.raytheon.uf.edex.plugin.obs.ogc.metar, - com.raytheon.uf.edex.plugin.obs.ogc.metar.feature diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/schema/metar.xsd b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/schema/metar.xsd deleted file mode 100644 index cfc44e7b0e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/schema/metar.xsd +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject deleted file mode 100644 index b36ce77d32..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject +++ /dev/null @@ -1 +0,0 @@ -com.raytheon.uf.edex.plugin.obs.ogc.metar.MetarLayer \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/build.properties b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/build.properties deleted file mode 100644 index 5791d48d5f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/com.raytheon.uf.edex.plugin.obs.ogc.ecl b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/com.raytheon.uf.edex.plugin.obs.ogc.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/res/spring/obs-dpa-ingest.xml b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/res/spring/obs-dpa-ingest.xml deleted file mode 100644 index 04bbb47c14..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/res/spring/obs-dpa-ingest.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - obs - - - - - - - - - obs - - - - - - - - - - - - - java.lang.Throwable - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/res/spring/obs-ogc.xml b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/res/spring/obs-ogc.xml deleted file mode 100644 index e2c4ebca25..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/res/spring/obs-ogc.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarFeatureFactory.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarFeatureFactory.java deleted file mode 100644 index a72fda9465..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarFeatureFactory.java +++ /dev/null @@ -1,243 +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 3, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.plugin.obs.ogc.metar; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.measure.quantity.Pressure; -import javax.measure.unit.Unit; - -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; - -import com.raytheon.edex.plugin.obs.metar.MetarPointDataTransform; -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.obs.metar.MetarRecord; -import com.raytheon.uf.common.dataplugin.obs.metar.util.SkyCover; -import com.raytheon.uf.common.dataplugin.obs.metar.util.WeatherCondition; -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.util.CollectionUtil; -import com.raytheon.uf.edex.ogc.common.feature.FeatureFactory; -import com.vividsolutions.jts.geom.Point; - -/** - * - * @author bclement - * @version 1.0 - */ -public class MetarFeatureFactory implements FeatureFactory { - - private static final String TEMP_KEY = MetarPointDataTransform.TEMPERATURE; - - private static final String WX_KEY = MetarPointDataTransform.PRES_WEATHER; - - private static final String PRESS_KEY = MetarPointDataTransform.SEA_LEVEL_PRESS; - - private static final String DP_KEY = MetarPointDataTransform.DEWPOINT; - - private static final String HR_PRESS_KEY = MetarPointDataTransform.PRESS_CHANGE3_HOUR; - - private static final String VIZ_KEY = MetarPointDataTransform.VISIBILITY; - - private static final String SKY_COND_KEY = MetarPointDataTransform.SKY_COVER; - - private static final String GUST_KEY = MetarPointDataTransform.WIND_GUST; - - private static final String WSPD_KEY = MetarPointDataTransform.WIND_SPEED; - - private static final String WDIR_KEY = MetarPointDataTransform.WIND_DIR_STR; - - private static final String STATION_ID_KEY = MetarPointDataTransform.STATION_ID; - - private static final String SKYLAYERBASE_KEY = MetarPointDataTransform.SKY_LAYER_BASE; - - private static final String GEOM_KEY = "location"; - - private static final String TIME_KEY = "timeObs"; - - private static final String METAR_NS = "http://metar.edex.uf.raytheon.com"; - - private static SimpleFeatureType _metarType; - - private static String name = "metar"; - - private static Integer skyCondDefault = 53; - - private static final Map skyMap; - static { - Map temp = new HashMap(); - temp.put("BLNK", 32); - temp.put("SKC", 48); - temp.put("CLR", 48); - temp.put("FEW", 49); - temp.put("SCT", 64); - temp.put("BKN", 50); - temp.put("OVC", 56); - temp.put("OBS", 52); - temp.put("VV", 52); - skyMap = Collections.unmodifiableMap(temp); - } - - public static SimpleFeatureType getFeatureType() { - if (_metarType == null) { - SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); - builder.setCRS(MapUtil.LATLON_PROJECTION); - builder.setName(name); - builder.setNamespaceURI(METAR_NS); - builder.setDefaultGeometry(GEOM_KEY); - builder.add(TEMP_KEY, Integer.class); - builder.add(WX_KEY, String.class); - builder.add(DP_KEY, Integer.class); - builder.add(PRESS_KEY, Float.class); - builder.add(HR_PRESS_KEY, String.class); - builder.add(VIZ_KEY, Float.class); - builder.add(SKY_COND_KEY, Integer.class); - builder.add(GUST_KEY, Integer.class); - builder.add(WSPD_KEY, Integer.class); - builder.add(WDIR_KEY, String.class); - builder.add(STATION_ID_KEY, String.class); - builder.add(SKYLAYERBASE_KEY, Integer.class); - builder.add(GEOM_KEY, Point.class); - builder.add(TIME_KEY, Date.class); - _metarType = builder.buildFeatureType(); - } - return _metarType; - } - - /** - * Converts MetarRecords to SimpleFeatures - * - * @param pdos - * @return - */ - @Override - public List convert(PluginDataObject[] pdos) { - if (CollectionUtil.isNullOrEmpty(pdos)) { - return new ArrayList(0); - } - ArrayList rval = new ArrayList( - pdos.length); - for (PluginDataObject pdo : pdos) { - if (pdo instanceof MetarRecord) { - rval.add(getAsFeature((MetarRecord) pdo)); - } - } - return rval; - } - - /** - * @param pdo - * @return - */ - public static SimpleFeature getAsFeature(MetarRecord record) { - - SimpleFeatureBuilder builder = new SimpleFeatureBuilder( - getFeatureType()); - builder.set(TEMP_KEY, record.getTemperature()); - builder.set(DP_KEY, record.getDewPoint()); - builder.set(GEOM_KEY, record.getLocation().getLocation()); - builder.set(PRESS_KEY, record.getSeaLevelPress()); - builder.set(GUST_KEY, record.getWindGust()); - builder.set(WDIR_KEY, record.getWindDir()); - builder.set(STATION_ID_KEY, record.getLocation().getStationId()); - builder.set(SKYLAYERBASE_KEY, record.getSkyLayerBase()); - builder.set(WSPD_KEY, record.getWindSpeed()); - builder.set(VIZ_KEY, record.getVisibility()); - builder.set(SKY_COND_KEY, getSkyCond(record.getSkyCoverage())); - builder.set(HR_PRESS_KEY, get3HrPress(record.getPressChange3Hour())); - builder.set(WX_KEY, getWxCondition(record.getWeatherCondition())); - builder.set(TIME_KEY, record.getTimeObs().getTime()); - - return builder.buildFeature(record.getDataURI()); - } - - /** - * @param weatherCondition - * @return - */ - protected static String getWxCondition(List wxs) { - if (CollectionUtil.isNullOrEmpty(wxs)) { - return null; - } - StringBuilder rval = new StringBuilder(); - Iterator i = wxs.iterator(); - WeatherCondition wx = i.next(); - appendFromWc(rval, wx); - for (; i.hasNext(); wx = i.next()) { - rval.append(' '); - appendFromWc(rval, wx); - } - return rval.toString(); - } - - protected static void appendFromWc(StringBuilder sb, WeatherCondition wc) { - sb.append(wc.getIntensityProximity()); - sb.append(wc.getDescriptor()); - sb.append(wc.getPrecipitation()); - sb.append(wc.getObscuration()); - sb.append(wc.getOther()); - } - - /** - * @param pressChange3Hour - * @return - */ - protected static String get3HrPress(float press) { - Unit unit = MetarRecord.PRESSURE_UNIT; - return String.format("%f %s", press, unit.toString()); - } - - protected static Integer getSkyCond(Set cond) { - if (CollectionUtil.isNullOrEmpty(cond)) { - return skyCondDefault; - } - Integer rval = skyCondDefault; - for (SkyCover sc : cond) { - Integer i = skyMap.get(sc.getType()); - if (i != null) { - rval = i; - // FIXME we probably don't want to just take the first one - break; - } - } - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarLayer.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarLayer.java deleted file mode 100644 index 711e1784ca..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarLayer.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.raytheon.uf.edex.plugin.obs.ogc.metar; - -/** - * 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.Date; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Table; -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 org.hibernate.annotations.Sort; -import org.hibernate.annotations.SortType; - -import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; -import com.raytheon.uf.edex.ogc.common.db.SimpleDimension; -import com.raytheon.uf.edex.ogc.common.db.SimpleLayer; - -/** - * - * Make Metar Layers - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   753       dhladky     Initial Creation.
- * 
- * - * @author dhladky - * @version 1.0 - */ - -@Entity -@XmlRootElement -@XmlAccessorType(XmlAccessType.NONE) -@DynamicSerialize -@Table(name = "metarlayers") -public class MetarLayer extends SimpleLayer { - - @XmlElement - @DynamicSerializeElement - @Sort(type = SortType.NATURAL) - @ElementCollection(fetch = FetchType.EAGER) - protected SortedSet times; - - @Override - public Set getDimensions() { - return new TreeSet(); - } - - @Override - public SortedSet getTimes() { - return times; - } - - public void setTimes(TreeSet times) { - this.times = times; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarLayerCollector.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarLayerCollector.java deleted file mode 100644 index 68839e3565..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarLayerCollector.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.raytheon.uf.edex.plugin.obs.ogc.metar; - - -/** - * 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.Calendar; -import java.util.Date; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.geotools.geometry.jts.JTS; -import org.geotools.geometry.jts.ReferencedEnvelope; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.obs.metar.MetarRecord; -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.edex.database.DataAccessLayerException; -import com.raytheon.uf.edex.ogc.common.db.LayerTransformer; -import com.raytheon.uf.edex.ogc.common.db.WFSLayerCollector; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Envelope; -/** - * - * Metar Layer Collector - * - *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 08/09/2012   753       dhladky      Modified from a class written by Brian Clements
- * 
- * - * @author dhladky - * @version 1.0 - */ - -public class MetarLayerCollector extends WFSLayerCollector { - - private boolean truncate = true; - - private int roundCutoff = 45; - - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(MetarLayerCollector.class); - - public MetarLayerCollector(LayerTransformer transformer) { - super(transformer); - this.layer = newLayer(); - } - - /** - * Adds these PDO's as fodder for this layer - * - * @param pdos - */ - public void add(PluginDataObject... pdos) { - synchronized (layer) { - - SortedSet times = layer.getTimes(); - Envelope e = getCoverage().getEnvelope(); - - if (e != null) { - - for (PluginDataObject pdo : pdos) { - - if (pdo instanceof MetarRecord) { - - MetarRecord record = (MetarRecord) pdo; - - if (record != null) { - - Coordinate c = record.getLocation().getLocation() - .getCoordinate(); - - if (c != null) { - - if (e.contains(c)) { - - Calendar time = getTime(record); - times.add(time.getTime()); - statusHandler.info("Adding metar layer: " - + record.toString()); - } else { - statusHandler - .info("Metar layer discarded: outside of range: " - + record.getLatitude() - + " " - + record.getLongitude()); - } - } - } - } - } - } - } - } - - /** - * Adds the new times to the layer, transmit meta data - */ - public void buildLayerUpdate() { - - synchronized (layer) { - try { - if (!layer.getTimes().isEmpty()) { - updateLayer(layer); - sendMetaData(layer); - statusHandler.info("Updating "+layer.getName()+": times: "+layer.getTimes().size()); - layer.getTimes().clear(); - } - } catch (DataAccessLayerException e) { - statusHandler.error("problem updating "+layer.getName()+" layer. "+e); - } - } - } - - private Calendar getTime(MetarRecord record) { - Calendar timeObs = record.getTimeObs(); - if (truncate) { - return truncateToHour(timeObs); - } else { - return roundToHour(timeObs, roundCutoff); - } - } - - private Set getTimes(Set dates) { - Set rval = new TreeSet(); - for (Date d : dates) { - if (truncate) { - rval.add(truncateToHour(d)); - } else { - rval.add(roundToHour(d, roundCutoff)); - } - } - return rval; - } - - /** - * purges expired times from layer - * @param timesToKeep - */ - public void purgeExpired(Set timesToKeep) { - synchronized (layer) { - layer.times.clear(); - layer.times.retainAll(getTimes(timesToKeep)); - try { - replaceTimes(layer); - } catch (DataAccessLayerException e) { - statusHandler.error("problem purging expired metars. "+e); - } - } - } - - /** - * purge the layer - */ - public void purgeAll() { - synchronized (layer) { - layer.times.clear(); - try { - clearLayers(MetarLayer.class); - } catch (Exception e) { - statusHandler.error("problem purging metar layers. "+e); - } - } - } - - /** - * creates a new layer - */ - public MetarLayer newLayer() { - - layer = new MetarLayer(); - - synchronized (layer) { - layer.setName("metar"); - // create the main point data set - setDataSet(layer); - Coordinate lowerRight = getCoverage().getLowerRight(); - Coordinate upperLeft = getCoverage().getUpperLeft(); - ReferencedEnvelope env = new ReferencedEnvelope(upperLeft.x, - lowerRight.x, lowerRight.y, upperLeft.y, - MapUtil.LATLON_PROJECTION); - layer.setCrs84Bounds(JTS.toGeometry((Envelope) env)); - layer.setTargetCrsCode("CRS:84"); - layer.setTargetMaxx(env.getMaxX()); - layer.setTargetMaxy(env.getMaxY()); - layer.setTargetMinx(env.getMinX()); - layer.setTargetMiny(env.getMinY()); - layer.setTimes(new TreeSet()); - // install main dataset name on registry - storeDataSet(getDataSet()); - } - - return layer; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarTranslator.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarTranslator.java deleted file mode 100644 index aeca1b59ef..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarTranslator.java +++ /dev/null @@ -1,78 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 27, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.plugin.obs.ogc.metar; - -import java.util.ArrayList; - -import javax.xml.bind.JAXBElement; - -import net.opengis.gml.v_3_1_1.AbstractFeatureType; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.obs.metar.MetarRecord; -import com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.Metar; -import com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.ObjectFactory; -import com.raytheon.uf.edex.wfs.reg.WfsTranslator; - - -/** - * - * @author bclement - * @version 1.0 - */ -public class MetarTranslator implements WfsTranslator { - - public MetarTranslator() { - - } - - @Override - public ArrayList> translate( - PluginDataObject[] pdos) { - ArrayList> rval = new ArrayList>( - pdos.length); - for (PluginDataObject pdo : pdos) { - rval.add(translate(pdo)); - } - return rval; - } - - /** - * @param pdo - * @return - */ - public JAXBElement translate(PluginDataObject pdo) { - MetarRecord record = (MetarRecord) pdo; - Metar to = new Metar(record); - return new ObjectFactory().createMetar(to); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarWfsSource.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarWfsSource.java deleted file mode 100644 index 7ad49ba18f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarWfsSource.java +++ /dev/null @@ -1,161 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 27, 2011 bclement Initial creation - * - * - */ -package com.raytheon.uf.edex.plugin.obs.ogc.metar; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.raytheon.uf.common.dataplugin.PluginProperties; -import com.raytheon.uf.common.dataplugin.obs.metar.MetarRecord; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; -import com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.ObjectFactory; -import com.raytheon.uf.edex.wfs.WfsFeatureType; -import com.raytheon.uf.edex.wfs.reg.DefaultWfsSource; -import com.raytheon.uf.edex.wfs.request.QualifiedName; - -/** - * - * @author bclement - * @version 1.0 - */ -public class MetarWfsSource extends DefaultWfsSource { - - private static final String schemaloc = "META-INF/schema/metar.xsd"; - - private WfsFeatureType feature; - - private static String schemaXml = null; - - private static final String spatialKey = "location.location"; - - private static final String KEY_NAME = "metar"; - - private static final String METAR_NS = "http://metar.edex.uf.raytheon.com"; - - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(MetarWfsSource.class); - - private static final Map fieldMap = new HashMap(1); - - static { - fieldMap.put("obsLocation.location", spatialKey); - fieldMap.put("obsLocation.stationId", "location.stationId"); - fieldMap.put("obsLocation.elevation", "location.elevation"); - Collections.unmodifiableMap(fieldMap); - } - - public MetarWfsSource(PluginProperties props) { - super(props, KEY_NAME, new MetarTranslator(), new MetarFeatureFactory()); - feature = new WfsFeatureType(new QualifiedName(METAR_NS, key, key), - key, defaultCRS, fullBbox); - } - - @Override - public Map getFieldMap() { - return fieldMap; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wfs.reg.WfsSource#listFeatureTypes() - */ - @Override - public List listFeatureTypes() { - return Arrays.asList(feature); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#describeFeatureType(com.raytheon - * .uf.edex.wfs.request.QualifiedName) - */ - @Override - public String describeFeatureType(QualifiedName feature) { - // we only advertise one feature - String rval; - try { - if (schemaXml == null) { - ClassLoader loader = MetarWfsSource.class.getClassLoader(); - schemaXml = getResource(loader, schemaloc); - } - rval = schemaXml; - } catch (Exception e) { - statusHandler.error("Problem reading metar schema", e); - rval = "Internal Error"; // TODO better default - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#getFeatureSpatialField(com.raytheon - * .uf.edex.wfs.request.QualifiedName) - */ - @Override - public String getFeatureSpatialField(QualifiedName feature) { - // we only advertise one feature - return spatialKey; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#getFeatureEntity(com.raytheon. - * uf.edex.wfs.request.QualifiedName) - */ - @Override - public Class getFeatureEntity(QualifiedName feature) { - // we only advertise one feature - return MetarRecord.class; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wfs.reg.WfsSource#getJaxbClasses() - */ - @Override - public Class[] getJaxbClasses() { - return new Class[] { ObjectFactory.class }; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarWmsSource.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarWmsSource.java deleted file mode 100644 index 032f8749bb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/MetarWmsSource.java +++ /dev/null @@ -1,106 +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 3, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.plugin.obs.ogc.metar; - -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.common.dataplugin.PluginProperties; -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.edex.ogc.common.db.LayerTransformer; -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.reg.PointDataWmsSource; -import com.raytheon.uf.edex.wms.styling.FeatureStyleProvider; - - -/** - * - * @author bclement - * @version 1.0 - */ -public class MetarWmsSource extends PointDataWmsSource { - - private static final String geometryField = "location.location"; - - private static final FeatureStyleProvider styler = new FeatureStyleProvider( - "sld/metar/defaultMetar.sld"); - - /** - * @param props - * @param key - * @param layerTable - * @param styles - * @throws Exception - */ - public MetarWmsSource(PluginProperties props, LayerTransformer transformer) - throws Exception { - super(props, "metar", transformer, - new MetarFeatureFactory()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.reg.FeatureWmsSource#getGeometryField(java.lang - * .String) - */ - @Override - protected String getGeometryField(String layer) { - // metar has only one layer - return geometryField; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.reg.FeatureWmsSource#getCRS(java.lang.String) - */ - @Override - protected CoordinateReferenceSystem getCRS(String layer) { - - return MapUtil.LATLON_PROJECTION; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.reg.FeatureWmsSource#getStyleProvider(java.lang - * .String) - */ - @Override - protected FeatureStyleProvider getStyleProvider(String layer) - throws WmsException { - return styler; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/Metar.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/Metar.java deleted file mode 100644 index f1f97b76b6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/Metar.java +++ /dev/null @@ -1,1038 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.29 at 09:28:54 AM CST -// - -package com.raytheon.uf.edex.plugin.obs.ogc.metar.feature; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; - -import net.opengis.gml.v_3_1_1.AbstractFeatureType; - -import com.raytheon.uf.common.dataplugin.obs.metar.MetarRecord; -import com.raytheon.uf.common.dataplugin.obs.metar.util.SkyCover; -import com.raytheon.uf.common.dataplugin.obs.metar.util.WeatherCondition; -import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; - -/** - *

- * Java class for metar complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType name="metar">
- *   <complexContent>
- *     <extension base="{http://www.opengis.net/gml}AbstractFeatureType">
- *       <sequence>
- *         <element name="report" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="nominalTime" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="timeObs" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
- *         <element name="reportType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="correction" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="obsLocation" type="{http://metar.edex.uf.raytheon.com}obsLocation" minOccurs="0"/>
- *         <element name="autoStationType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="skyKey" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="skyCoverage" type="{http://metar.edex.uf.raytheon.com}skyCover" maxOccurs="unbounded" minOccurs="0"/>
- *         <element name="vertVisibility" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="skyLayerBase" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="visibility" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="weatherKey" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="weatherCondition" type="{http://metar.edex.uf.raytheon.com}weatherCondition" maxOccurs="unbounded" minOccurs="0"/>
- *         <element name="seaLevelPress" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="temperature" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="tempFromTenths" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="dewPoint" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="dewPointFromTenths" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="windDir" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="windSpeed" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="windGust" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="altimeterInPa" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="altimeter" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="minTemp24Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="maxTemp24Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="precip1Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="precip3Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="precip6Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="precip24Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="pressChangeChar" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="pressChange3Hour" type="{http://www.w3.org/2001/XMLSchema}float" minOccurs="0"/>
- *         <element name="refHour" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
- *       </sequence>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "metar", propOrder = { "report", "nominalTime", "timeObs", - "reportType", "correction", "obsLocation", "autoStationType", "skyKey", - "skyCoverage", "vertVisibility", "skyLayerBase", "visibility", - "weatherKey", "weatherCondition", "seaLevelPress", "temperature", - "tempFromTenths", "dewPoint", "dewPointFromTenths", "windDir", - "windSpeed", "windGust", "altimeterInPa", "altimeter", "minTemp24Hour", - "maxTemp24Hour", "precip1Hour", "precip3Hour", "precip6Hour", - "precip24Hour", "pressChangeChar", "pressChange3Hour", "refHour" }) -public class Metar extends AbstractFeatureType { - - protected String report; - - protected String nominalTime; - - @XmlSchemaType(name = "dateTime") - protected XMLGregorianCalendar timeObs; - - protected String reportType; - - protected String correction; - - protected ObsLocation obsLocation; - - protected String autoStationType; - - protected String skyKey; - - protected List skyCoverage; - - protected Integer vertVisibility; - - protected Integer skyLayerBase; - - protected Float visibility; - - protected String weatherKey; - - protected List weatherCondition; - - protected Float seaLevelPress; - - protected Integer temperature; - - protected Float tempFromTenths; - - protected Integer dewPoint; - - protected Float dewPointFromTenths; - - protected String windDir; - - protected Integer windSpeed; - - protected Integer windGust; - - protected Float altimeterInPa; - - protected Float altimeter; - - protected Float minTemp24Hour; - - protected Float maxTemp24Hour; - - protected Float precip1Hour; - - protected Float precip3Hour; - - protected Float precip6Hour; - - protected Float precip24Hour; - - protected String pressChangeChar; - - protected Float pressChange3Hour; - - @XmlSchemaType(name = "dateTime") - protected XMLGregorianCalendar refHour; - - private static final int intNullVal = -9999; - - private static final float floatNullVal = -9999; - - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(Metar.class); - - // public non-creative constructor - public Metar() { - - } - - /** - * copy constructor - * - * @param record - */ - public Metar(MetarRecord record) { - - this.setReport(record.getReport()); - this.setNominalTime(record.getNominalTime()); - this.setTimeObs(getCalendar(record.getTimeObs())); - this.setReportType(record.getReportType()); - this.setCorrection(record.getCorrection()); - this.setObsLocation(getObsLocation(record.getLocation())); - this.setAutoStationType(record.getAutoStationType()); - this.setSkyKey(record.getSkyKey()); - this.setSkyCover(record.getSkyCoverage()); - this.setVertVisibility(getInt(record.getVertVisibility(), intNullVal)); - this.setSkyLayerBase(getInt(record.getSkyLayerBase(), intNullVal)); - this.setVisibility(getFloat(record.getVisibility(), floatNullVal)); - this.setWeatherKey(record.getWeatherKey()); - this.setWeatherCondition(record.getWeatherCondition()); - this.setSeaLevelPress(getFloat(record.getSeaLevelPress(), floatNullVal)); - this.setTemperature(getInt(record.getTemperature(), intNullVal)); - this.setTempFromTenths(getFloat(record.getTempFromTenths(), - floatNullVal)); - this.setDewPoint(getInt(record.getDewPoint(), intNullVal)); - this.setDewPointFromTenths(getFloat(record.getDewPointFromTenths(), - floatNullVal)); - this.setWindDir(record.getWindDir()); - this.setWindSpeed(getInt(record.getWindSpeed(), intNullVal)); - this.setWindGust(getInt(record.getWindGust(), intNullVal)); - this.setAltimeterInPa(getFloat(record.getAltimeterInPa(), floatNullVal)); - this.setAltimeter(getFloat(record.getAltimeter(), floatNullVal)); - this.setMinTemp24Hour(getFloat(record.getMinTemp24Hour(), floatNullVal)); - this.setMaxTemp24Hour(getFloat(record.getMaxTemp24Hour(), floatNullVal)); - this.setPrecip1Hour(getFloat(record.getPrecip1Hour(), floatNullVal)); - this.setPrecip3Hour(getFloat(record.getPrecip3Hour(), floatNullVal)); - this.setPrecip6Hour(getFloat(record.getPrecip6Hour(), floatNullVal)); - this.setPrecip24Hour(getFloat(record.getPrecip24Hour(), floatNullVal)); - this.setPressChangeChar(record.getPressChangeChar()); - this.setPressChange3Hour(getFloat(record.getPressChange3Hour(), - floatNullVal)); - this.setRefHour(getCalendar(record.getRefHour())); - } - - /** - * Gets the value of the report property. - * - * @return possible object is {@link String } - * - */ - public String getReport() { - return report; - } - - /** - * Sets the value of the report property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setReport(String value) { - this.report = value; - } - - /** - * Gets the value of the nominalTime property. - * - * @return possible object is {@link String } - * - */ - public String getNominalTime() { - return nominalTime; - } - - /** - * Sets the value of the nominalTime property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setNominalTime(String value) { - this.nominalTime = value; - } - - /** - * Gets the value of the timeObs property. - * - * @return possible object is {@link XMLGregorianCalendar } - * - */ - public XMLGregorianCalendar getTimeObs() { - return timeObs; - } - - /** - * Sets the value of the timeObs property. - * - * @param value - * allowed object is {@link XMLGregorianCalendar } - * - */ - public void setTimeObs(XMLGregorianCalendar value) { - this.timeObs = value; - } - - /** - * Gets the value of the reportType property. - * - * @return possible object is {@link String } - * - */ - public String getReportType() { - return reportType; - } - - /** - * Sets the value of the reportType property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setReportType(String value) { - this.reportType = value; - } - - /** - * Gets the value of the correction property. - * - * @return possible object is {@link String } - * - */ - public String getCorrection() { - return correction; - } - - /** - * Sets the value of the correction property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setCorrection(String value) { - this.correction = value; - } - - /** - * Gets the value of the obsLocation property. - * - * @return possible object is {@link ObsLocation } - * - */ - public ObsLocation getObsLocation() { - return obsLocation; - } - - /** - * Sets the value of the obsLocation property. - * - * @param value - * allowed object is {@link ObsLocation } - * - */ - public void setObsLocation(ObsLocation value) { - this.obsLocation = value; - } - - /** - * Gets the value of the autoStationType property. - * - * @return possible object is {@link String } - * - */ - public String getAutoStationType() { - return autoStationType; - } - - /** - * Sets the value of the autoStationType property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setAutoStationType(String value) { - this.autoStationType = value; - } - - /** - * Gets the value of the skyKey property. - * - * @return possible object is {@link String } - * - */ - public String getSkyKey() { - return skyKey; - } - - /** - * Sets the value of the skyKey property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setSkyKey(String value) { - this.skyKey = value; - } - - /** - * Gets the value of the skyCoverage property. - * - *

- * This accessor method returns a reference to the live list, not a - * snapshot. Therefore any modification you make to the returned list will - * be present inside the JAXB object. This is why there is not a - * set method for the skyCoverage property. - * - *

- * For example, to add a new item, do as follows: - * - *

-     * getSkyCoverage().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list {@link SkyCover } - * - * - */ - public List getSkyCoverage() { - if (skyCoverage == null) { - skyCoverage = new ArrayList(); - } - return this.skyCoverage; - } - - /** - * Gets the value of the vertVisibility property. - * - * @return possible object is {@link Integer } - * - */ - public Integer getVertVisibility() { - return vertVisibility; - } - - /** - * Sets the value of the vertVisibility property. - * - * @param value - * allowed object is {@link Integer } - * - */ - public void setVertVisibility(Integer value) { - this.vertVisibility = value; - } - - /** - * Gets the value of the skyLayerBase property. - * - * @return possible object is {@link Integer } - * - */ - public Integer getSkyLayerBase() { - return skyLayerBase; - } - - /** - * Sets the value of the skyLayerBase property. - * - * @param value - * allowed object is {@link Integer } - * - */ - public void setSkyLayerBase(Integer value) { - this.skyLayerBase = value; - } - - /** - * Gets the value of the visibility property. - * - * @return possible object is {@link Float } - * - */ - public Float getVisibility() { - return visibility; - } - - /** - * Sets the value of the visibility property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setVisibility(Float value) { - this.visibility = value; - } - - /** - * Gets the value of the weatherKey property. - * - * @return possible object is {@link String } - * - */ - public String getWeatherKey() { - return weatherKey; - } - - /** - * Sets the value of the weatherKey property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setWeatherKey(String value) { - this.weatherKey = value; - } - - /** - * Gets the value of the weatherCondition property. - * - *

- * This accessor method returns a reference to the live list, not a - * snapshot. Therefore any modification you make to the returned list will - * be present inside the JAXB object. This is why there is not a - * set method for the weatherCondition property. - * - *

- * For example, to add a new item, do as follows: - * - *

-     * getWeatherCondition().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link WeatherCondition } - * - * - */ - public List getWeatherCondition() { - if (weatherCondition == null) { - weatherCondition = new ArrayList(); - } - return this.weatherCondition; - } - - /** - * Gets the value of the seaLevelPress property. - * - * @return possible object is {@link Float } - * - */ - public Float getSeaLevelPress() { - return seaLevelPress; - } - - /** - * Sets the value of the seaLevelPress property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setSeaLevelPress(Float value) { - this.seaLevelPress = value; - } - - /** - * Gets the value of the temperature property. - * - * @return possible object is {@link Integer } - * - */ - public Integer getTemperature() { - return temperature; - } - - /** - * Sets the value of the temperature property. - * - * @param value - * allowed object is {@link Integer } - * - */ - public void setTemperature(Integer value) { - this.temperature = value; - } - - /** - * Gets the value of the tempFromTenths property. - * - * @return possible object is {@link Float } - * - */ - public Float getTempFromTenths() { - return tempFromTenths; - } - - /** - * Sets the value of the tempFromTenths property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setTempFromTenths(Float value) { - this.tempFromTenths = value; - } - - /** - * Gets the value of the dewPoint property. - * - * @return possible object is {@link Integer } - * - */ - public Integer getDewPoint() { - return dewPoint; - } - - /** - * Sets the value of the dewPoint property. - * - * @param value - * allowed object is {@link Integer } - * - */ - public void setDewPoint(Integer value) { - this.dewPoint = value; - } - - /** - * Gets the value of the dewPointFromTenths property. - * - * @return possible object is {@link Float } - * - */ - public Float getDewPointFromTenths() { - return dewPointFromTenths; - } - - /** - * Sets the value of the dewPointFromTenths property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setDewPointFromTenths(Float value) { - this.dewPointFromTenths = value; - } - - /** - * Gets the value of the windDir property. - * - * @return possible object is {@link String } - * - */ - public String getWindDir() { - return windDir; - } - - /** - * Sets the value of the windDir property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setWindDir(String value) { - this.windDir = value; - } - - /** - * Gets the value of the windSpeed property. - * - * @return possible object is {@link Integer } - * - */ - public Integer getWindSpeed() { - return windSpeed; - } - - /** - * Sets the value of the windSpeed property. - * - * @param value - * allowed object is {@link Integer } - * - */ - public void setWindSpeed(Integer value) { - this.windSpeed = value; - } - - /** - * Gets the value of the windGust property. - * - * @return possible object is {@link Integer } - * - */ - public Integer getWindGust() { - return windGust; - } - - /** - * Sets the value of the windGust property. - * - * @param value - * allowed object is {@link Integer } - * - */ - public void setWindGust(Integer value) { - this.windGust = value; - } - - /** - * Gets the value of the altimeterInPa property. - * - * @return possible object is {@link Float } - * - */ - public Float getAltimeterInPa() { - return altimeterInPa; - } - - /** - * Sets the value of the altimeterInPa property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setAltimeterInPa(Float value) { - this.altimeterInPa = value; - } - - /** - * Gets the value of the altimeter property. - * - * @return possible object is {@link Float } - * - */ - public Float getAltimeter() { - return altimeter; - } - - /** - * Sets the value of the altimeter property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setAltimeter(Float value) { - this.altimeter = value; - } - - /** - * Gets the value of the minTemp24Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getMinTemp24Hour() { - return minTemp24Hour; - } - - /** - * Sets the value of the minTemp24Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setMinTemp24Hour(Float value) { - this.minTemp24Hour = value; - } - - /** - * Gets the value of the maxTemp24Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getMaxTemp24Hour() { - return maxTemp24Hour; - } - - /** - * Sets the value of the maxTemp24Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setMaxTemp24Hour(Float value) { - this.maxTemp24Hour = value; - } - - /** - * Gets the value of the precip1Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getPrecip1Hour() { - return precip1Hour; - } - - /** - * Sets the value of the precip1Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setPrecip1Hour(Float value) { - this.precip1Hour = value; - } - - /** - * Gets the value of the precip3Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getPrecip3Hour() { - return precip3Hour; - } - - /** - * Sets the value of the precip3Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setPrecip3Hour(Float value) { - this.precip3Hour = value; - } - - /** - * Gets the value of the precip6Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getPrecip6Hour() { - return precip6Hour; - } - - /** - * Sets the value of the precip6Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setPrecip6Hour(Float value) { - this.precip6Hour = value; - } - - /** - * Gets the value of the precip24Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getPrecip24Hour() { - return precip24Hour; - } - - /** - * Sets the value of the precip24Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setPrecip24Hour(Float value) { - this.precip24Hour = value; - } - - /** - * Gets the value of the pressChangeChar property. - * - * @return possible object is {@link String } - * - */ - public String getPressChangeChar() { - return pressChangeChar; - } - - /** - * Sets the value of the pressChangeChar property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setPressChangeChar(String value) { - this.pressChangeChar = value; - } - - /** - * Gets the value of the pressChange3Hour property. - * - * @return possible object is {@link Float } - * - */ - public Float getPressChange3Hour() { - return pressChange3Hour; - } - - /** - * Sets the value of the pressChange3Hour property. - * - * @param value - * allowed object is {@link Float } - * - */ - public void setPressChange3Hour(Float value) { - this.pressChange3Hour = value; - } - - /** - * Gets the value of the refHour property. - * - * @return possible object is {@link XMLGregorianCalendar } - * - */ - public XMLGregorianCalendar getRefHour() { - return refHour; - } - - /** - * Sets the value of the refHour property. - * - * @param value - * allowed object is {@link XMLGregorianCalendar } - * - */ - public void setRefHour(XMLGregorianCalendar value) { - this.refHour = value; - } - - /* - * (non-Javadoc) - * - * @see org.jvnet.jaxb2_commons.lang.CopyTo#createNewInstance() - */ - @Override - public Object createNewInstance() { - return new Metar(); - } - - /** - * @param weatherCondition - * @return - */ - private com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.WeatherCondition getWeatherConditionInternal( - WeatherCondition from) { - if (from == null) { - return null; - } - com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.WeatherCondition to = new com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.WeatherCondition( - from); - return to; - } - - /** - * @param skyCoverage - * @return - */ - private com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.SkyCover getSkyCoverInternal( - SkyCover from) { - if (from == null) { - return null; - } - com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.SkyCover to = new com.raytheon.uf.edex.plugin.obs.ogc.metar.feature.SkyCover( - from); - return to; - } - - /** - * @param obsLocation - * @return - */ - private ObsLocation getObsLocation(SurfaceObsLocation from) { - if (from == null) { - return null; - } - ObsLocation to = new ObsLocation(from); - return to; - } - - protected XMLGregorianCalendar getCalendar(Calendar cal) { - if (cal == null) { - return null; - } - GregorianCalendar gcal = new GregorianCalendar(cal.getTimeZone()); - gcal.setTimeInMillis(cal.getTimeInMillis()); - try { - return DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal); - } catch (DatatypeConfigurationException e) { - statusHandler - .error("Unable to convert calendar. " + e.getMessage()); - return null; - } - } - - private Integer getInt(int i, int nullVal) { - if (i == nullVal) { - return null; - } - return i; - } - - private Float getFloat(float f, float nullVal) { - if (f == nullVal) { - return null; - } - return f; - } - - /** - * @param skyCoverage - */ - private void setSkyCover( - Set from) { - if (from != null) { - List localSkyCover = getSkyCoverage(); - for (com.raytheon.uf.common.dataplugin.obs.metar.util.SkyCover sc : from) { - localSkyCover.add(getSkyCoverInternal(sc)); - } - } - } - - /** - * @param weatherCondition - */ - private void setWeatherCondition( - List from) { - if (from != null) { - List localWeatherCondition = getWeatherCondition(); - for (com.raytheon.uf.common.dataplugin.obs.metar.util.WeatherCondition wc : from) { - localWeatherCondition.add(getWeatherConditionInternal(wc)); - } - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/ObjectFactory.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/ObjectFactory.java deleted file mode 100644 index 5e5368f953..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/ObjectFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.29 at 09:28:54 AM CST -// - - -package com.raytheon.uf.edex.plugin.obs.ogc.metar.feature; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.raytheon.uf.edex.plugin.metar.feature package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -public class ObjectFactory { - - private final static QName _Metar_QNAME = new QName("http://metar.edex.uf.raytheon.com", "metar"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.raytheon.uf.edex.plugin.metar.feature - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link ObsLocation } - * - */ - public ObsLocation createObsLocation() { - return new ObsLocation(); - } - - /** - * Create an instance of {@link WeatherCondition } - * - */ - public WeatherCondition createWeatherCondition() { - return new WeatherCondition(); - } - - /** - * Create an instance of {@link Metar } - * - */ - public Metar createMetar() { - return new Metar(); - } - - /** - * Create an instance of {@link SkyCover } - * - */ - public SkyCover createSkyCover() { - return new SkyCover(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link Metar }{@code >}} - * - */ - @XmlElementDecl(namespace = "http://metar.edex.uf.raytheon.com", name = "metar", substitutionHeadNamespace = "http://www.opengis.net/gml", substitutionHeadName = "_Feature") - public JAXBElement createMetar(Metar value) { - return new JAXBElement(_Metar_QNAME, Metar.class, null, value); - } - - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/ObsLocation.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/ObsLocation.java deleted file mode 100644 index 979d186483..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/ObsLocation.java +++ /dev/null @@ -1,151 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.29 at 09:28:54 AM CST -// - - -package com.raytheon.uf.edex.plugin.obs.ogc.metar.feature; - -import java.util.Arrays; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation; - -import net.opengis.gml.v_3_1_1.DirectPositionType; -import net.opengis.gml.v_3_1_1.PointType; - - -/** - *

Java class for obsLocation complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="obsLocation">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="location" type="{http://www.opengis.net/gml}PointType"/>
- *       </sequence>
- *       <attribute name="stationId" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="elevation" type="{http://www.w3.org/2001/XMLSchema}int" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "obsLocation", propOrder = { - "location" -}) -public class ObsLocation { - - @XmlElement(required = true) - protected PointType location; - @XmlAttribute - protected String stationId; - @XmlAttribute - protected Integer elevation; - - /** - * public cons - */ - public ObsLocation() { - - } - - public ObsLocation(SurfaceObsLocation sol) { - - this.setStationId(sol.getStationId()); - this.setElevation(sol.getElevation()); - Double lat = sol.getLatitude(); - Double lon = sol.getLongitude(); - PointType point = new PointType(); - DirectPositionType pos = new DirectPositionType(); - pos.setValue(Arrays.asList(lon, lat)); - point.setPos(pos); - this.setLocation(point); - } - - /** - * Gets the value of the location property. - * - * @return - * possible object is - * {@link PointType } - * - */ - public PointType getLocation() { - return location; - } - - /** - * Sets the value of the location property. - * - * @param value - * allowed object is - * {@link PointType } - * - */ - public void setLocation(PointType value) { - this.location = value; - } - - /** - * Gets the value of the stationId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStationId() { - return stationId; - } - - /** - * Sets the value of the stationId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStationId(String value) { - this.stationId = value; - } - - /** - * Gets the value of the elevation property. - * - * @return - * possible object is - * {@link Integer } - * - */ - public Integer getElevation() { - return elevation; - } - - /** - * Sets the value of the elevation property. - * - * @param value - * allowed object is - * {@link Integer } - * - */ - public void setElevation(Integer value) { - this.elevation = value; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/SkyCover.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/SkyCover.java deleted file mode 100644 index 61cd151fae..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/SkyCover.java +++ /dev/null @@ -1,137 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.29 at 09:28:54 AM CST -// - - -package com.raytheon.uf.edex.plugin.obs.ogc.metar.feature; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for skyCover complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="skyCover">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="genus" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="height" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
- *         <element name="type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "skyCover", propOrder = { - "genus", - "height", - "type" -}) -public class SkyCover { - - protected String genus; - protected Integer height; - protected String type; - - // public constructor - public SkyCover() { - - } - - /** - * copy constructor - * @param skyCover - */ - public SkyCover(com.raytheon.uf.common.dataplugin.obs.metar.util.SkyCover skyCover) { - this.setGenus(skyCover.getGenus()); - this.setHeight(skyCover.getHeight()); - this.setType(skyCover.getType()); - } - - /** - * Gets the value of the genus property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getGenus() { - return genus; - } - - /** - * Sets the value of the genus property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setGenus(String value) { - this.genus = value; - } - - /** - * Gets the value of the height property. - * - * @return - * possible object is - * {@link Integer } - * - */ - public Integer getHeight() { - return height; - } - - /** - * Sets the value of the height property. - * - * @param value - * allowed object is - * {@link Integer } - * - */ - public void setHeight(Integer value) { - this.height = value; - } - - /** - * Gets the value of the type property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setType(String value) { - this.type = value; - } - - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/WeatherCondition.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/WeatherCondition.java deleted file mode 100644 index a268349bdb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/WeatherCondition.java +++ /dev/null @@ -1,193 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.29 at 09:28:54 AM CST -// - - -package com.raytheon.uf.edex.plugin.obs.ogc.metar.feature; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for weatherCondition complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="weatherCondition">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="other" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="obscuration" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="precipitation" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="descriptor" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *         <element name="intensityProximity" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "weatherCondition", propOrder = { - "other", - "obscuration", - "precipitation", - "descriptor", - "intensityProximity" -}) -public class WeatherCondition { - - private String other; - private String obscuration; - private String precipitation; - private String descriptor; - private String intensityProximity; - - /** - * public - */ - public WeatherCondition() { - - } - - public WeatherCondition(com.raytheon.uf.common.dataplugin.obs.metar.util.WeatherCondition wc) { - - this.setOther(wc.getOther()); - this.setObscuration(wc.getObscuration()); - this.setPrecipitation(wc.getPrecipitation()); - this.setDescriptor(wc.getDescriptor()); - this.setIntensityProximity(wc.getIntensityProximity()); - } - - - /** - * Gets the value of the other property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getOther() { - return other; - } - - /** - * Sets the value of the other property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setOther(String value) { - this.other = value; - } - - /** - * Gets the value of the obscuration property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getObscuration() { - return obscuration; - } - - /** - * Sets the value of the obscuration property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setObscuration(String value) { - this.obscuration = value; - } - - /** - * Gets the value of the precipitation property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPrecipitation() { - return precipitation; - } - - /** - * Sets the value of the precipitation property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPrecipitation(String value) { - this.precipitation = value; - } - - /** - * Gets the value of the descriptor property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDescriptor() { - return descriptor; - } - - /** - * Sets the value of the descriptor property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDescriptor(String value) { - this.descriptor = value; - } - - /** - * Gets the value of the intensityProximity property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIntensityProximity() { - return intensityProximity; - } - - /** - * Sets the value of the intensityProximity property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIntensityProximity(String value) { - this.intensityProximity = value; - } - - -} diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/package-info.java b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/package-info.java deleted file mode 100644 index fe79eacae1..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/src/com/raytheon/uf/edex/plugin/obs/ogc/metar/feature/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.29 at 09:28:54 AM CST -// - -@javax.xml.bind.annotation.XmlSchema(namespace = "http://metar.edex.uf.raytheon.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) - -package com.raytheon.uf.edex.plugin.obs.ogc.metar.feature; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/utility/edex_static/base/sld/metar/defaultMetar.sld b/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/utility/edex_static/base/sld/metar/defaultMetar.sld deleted file mode 100644 index 1e9e4ed39d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.plugin.obs.ogc/utility/edex_static/base/sld/metar/defaultMetar.sld +++ /dev/null @@ -1,326 +0,0 @@ - - - - - - - metar - - - default - default - A sample style that draws a point based on visibility/ceiling distance - - - - - rule5 - Vis < .5 miles or Sky layer base < 200 - - - - visibility - .5 - - - skyLayerBase - 200 - - - - - - - square - - #FF0000 - - - #000000 - 1 - - - 6 - - - - - - rule4 - Vis between .5 and 1 or Sky layer base between 200 and 300 - - - - visibility - - .5 - - - 1 - - - - skyLayerBase - - 200 - - - 300 - - - - - - - - square - - #FF8000 - - - #000000 - 1 - - - 6 - - - - - rule3 - Vis between 1 and 2.25 or Sky layer base between 300 and 700 - - - - visibility - - 1 - - - 2.25 - - - - skyLayerBase - - 300 - - - 700 - - - - - - - - square - - #FFFF00 - - - #000000 - 1 - - - 6 - - - - - - rule2 - Vis between 2.26 and 3.8 or Sky layer base between 700 and 1500 - - - - visibility - - 2.25 - - - 3.8 - - - - skyLayerBase - - 700 - - - 1500 - - - - - - - - square - - #00FF00 - - - #000000 - 1 - - - 6 - - - - - - - rule1 - Vis between 3.8 and 5 or Sky layer base between 1500 and 2500 - - - - visibility - - 3.8 - - - 5 - - - - skyLayerBase - - 1500 - - - 2500 - - - - - - - - square - - #FFFFFF - - - #000000 - 1 - - - 6 - - - - - - rule0 - Vis > 5 or Sky layer > 2500 - - - - - visibility - 5 - - - visibility - -9999 - - - - - skyLayerBase - 2500 - - - skyLayerBase - -9999 - - - - - - - - - square - - #00F5FF - - - #000000 - 1 - - - 6 - - - - - - - - - rulelabel - label - A label goes on the point - - - - - Arial - Bold - - Normal - - 10 - - - - - 0.5 - 0.5 - - - 5 - -15 - - - - - #000000 - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/.classpath b/edexOsgi/com.raytheon.uf.edex.wcs/.classpath deleted file mode 100644 index ad32c83a78..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/.project b/edexOsgi/com.raytheon.uf.edex.wcs/.project deleted file mode 100644 index 1c4fe9c1a5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.wcs - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.wcs/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index afcbd70733..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Thu Feb 16 10:57:42 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 diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.wcs/META-INF/MANIFEST.MF deleted file mode 100644 index de9936403c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/META-INF/MANIFEST.MF +++ /dev/null @@ -1,27 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Wcs -Bundle-SymbolicName: com.raytheon.uf.edex.wcs -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: RAYTHEON -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0", - net.opengis;bundle-version="1.0.2", - org.geotools;bundle-version="2.6.4", - com.raytheon.edex.common;bundle-version="1.12.1174", - org.apache.commons.logging;bundle-version="1.1.1", - ucar.nc2;bundle-version="1.0.0", - javax.servlet;bundle-version="2.5.0", - com.raytheon.uf.common.localization;bundle-version="1.12.1174", - javax.measure;bundle-version="1.0.0", - org.apache.commons.codec;bundle-version="1.4.0", - org.apache.commons.pool;bundle-version="1.3.0", - ogc.tools.gml;bundle-version="1.0.2", - org.apache.commons.lang;bundle-version="2.3.0", - org.apache.camel;bundle-version="1.0.0", - com.raytheon.uf.common.spatial;bundle-version="1.0.0" -Export-Package: com.raytheon.uf.edex.wcs, - com.raytheon.uf.edex.wcs.format, - com.raytheon.uf.edex.wcs.provider, - com.raytheon.uf.edex.wcs.reg, - com.raytheon.uf.edex.wcs.request diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/build.properties b/edexOsgi/com.raytheon.uf.edex.wcs/build.properties deleted file mode 100644 index 2660b7d6a5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -source.. = src/ -bin.includes = .project,\ - component-deploy.xml,\ - .classpath,\ - META-INF/,\ - build.properties,\ - .settings/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/com.raytheon.uf.edex.wcs.ecl b/edexOsgi/com.raytheon.uf.edex.wcs/com.raytheon.uf.edex.wcs.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/component-deploy.xml b/edexOsgi/com.raytheon.uf.edex.wcs/component-deploy.xml deleted file mode 100644 index fc7a6c9b85..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/component-deploy.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/res/spring/wcs-ogc-request.xml b/edexOsgi/com.raytheon.uf.edex.wcs/res/spring/wcs-ogc-request.xml deleted file mode 100644 index d254980ac7..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/res/spring/wcs-ogc-request.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsCoverageThriftReponse.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsCoverageThriftReponse.java deleted file mode 100644 index 82737cb35d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsCoverageThriftReponse.java +++ /dev/null @@ -1,116 +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 30, 2011 ekladstrup Initial creation -* -*/ -package com.raytheon.uf.edex.wcs; - -import com.raytheon.uf.common.datastorage.records.IDataRecord; -import com.raytheon.uf.common.serialization.ISerializableObject; -import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; -import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; - -/** - * TODO Add Description - * - * @author ekladstrup - * @version 1.0 - */ -@DynamicSerialize -public class WcsCoverageThriftReponse implements ISerializableObject { - - @DynamicSerializeElement - private IDataRecord dataRecord; - @DynamicSerializeElement - private String crsString; - @DynamicSerializeElement - private String timeString; - @DynamicSerializeElement - private String envelopeString; - - /** - * @return the dataRecord - */ - public IDataRecord getDataRecord() { - return dataRecord; - } - - /** - * @param dataRecord - * the dataRecord to set - */ - public void setDataRecord(IDataRecord dataRecord) { - this.dataRecord = dataRecord; - } - - /** - * @return the crsString - */ - public String getCrsString() { - return crsString; - } - - /** - * @param crsString - * the crsString to set - */ - public void setCrsString(String crsString) { - this.crsString = crsString; - } - - /** - * @return the timeString - */ - public String getTimeString() { - return timeString; - } - - /** - * @param timeString - * the timeString to set - */ - public void setTimeString(String timeString) { - this.timeString = timeString; - } - - /** - * @return the envelopeString - */ - public String getEnvelopeString() { - return envelopeString; - } - - /** - * @param envelopeString - * the envelopeString to set - */ - public void setEnvelopeString(String envelopeString) { - this.envelopeString = envelopeString; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsException.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsException.java deleted file mode 100644 index f885c10cf6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsException.java +++ /dev/null @@ -1,83 +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.wcs; - -import com.raytheon.uf.edex.ogc.common.OgcException; - -/** - * TODO - Class comment here - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 
- * 
- * - * @author - * @version 1 - */ - -public class WcsException extends Exception { - - public enum Code { - InvalidFormat, InvalidCRS, LayerNotDefined, StyleNotDefined, LayerNotQueryable, InvalidPoint, CurrentUpdateSequence, InvalidUpdateSequence, MissingDimensionValue, InvalidDimensionValue, OperationNotSupported, MissingParameterValue, InvalidParameterValue, NoApplicableCode, UnsupportedCombination, NotEnoughStorage, InvalidRequest, InternalServerError - } - - private static final long serialVersionUID = 8797482743733419169L; - - protected Code code; - - public WcsException(OgcException ogc) { - this(Code.valueOf(ogc.getCode().toString()), ogc.getMessage()); - } - - public WcsException(Code code) { - super(); - this.code = code; - } - - public WcsException(Code code, String message) { - super(message); - this.code = code; - } - - public WcsException(Code code, Throwable cause) { - super(cause); - this.code = code; - } - - public WcsException(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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsHttpFactory.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsHttpFactory.java deleted file mode 100644 index 5355a9066b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsHttpFactory.java +++ /dev/null @@ -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 - * - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * - * - */ -package com.raytheon.uf.edex.wcs; - -import org.apache.commons.pool.KeyedPoolableObjectFactory; - -import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider; - -/** - * @author bclement - * - */ -public class WcsHttpFactory implements KeyedPoolableObjectFactory { - - public WcsHttpFactory() { - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#activateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void activateObject(Object arg0, Object arg1) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#destroyObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void destroyObject(Object arg0, Object arg1) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#makeObject(java.lang - * .Object) - */ - @Override - public Object makeObject(Object arg0) throws Exception { - return new WcsHttpHandler(new OgcWcsProvider()); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#passivateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void passivateObject(Object arg0, Object arg1) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#validateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public boolean validateObject(Object arg0, Object arg1) { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsHttpHandler.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsHttpHandler.java deleted file mode 100644 index 373b41d62f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsHttpHandler.java +++ /dev/null @@ -1,459 +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.wcs; - -import java.io.InputStream; -import java.util.Calendar; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -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.OgcBoundingBox; -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler; -import com.raytheon.uf.edex.ogc.common.http.OgcHttpRequest; -import com.raytheon.uf.edex.ogc.common.output.OgcResponseOutput; -import com.raytheon.uf.edex.wcs.WcsException.Code; -import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType; -import com.raytheon.uf.edex.wcs.reg.RangeField; -import com.raytheon.uf.edex.wcs.reg.RangeParseException; -import com.raytheon.uf.edex.wcs.request.DefactoEnabler; -import com.raytheon.uf.edex.wcs.request.DescCoverageRequest; -import com.raytheon.uf.edex.wcs.request.GetCapRequest; -import com.raytheon.uf.edex.wcs.request.GetCoverageRequest; -import com.raytheon.uf.edex.wcs.request.GetDataRequest; -import com.raytheon.uf.edex.wcs.request.WcsRequest; -import com.raytheon.uf.edex.wcs.request.WcsRequest.Type; - -/** - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 
- * 
- * - * @author - * @version 1 - */ -public class WcsHttpHandler implements OgcHttpHandler { - - protected WcsProvider provider; - - public static final String REQUEST_HEADER = "request"; - - public static final String VERSION_HEADER = "version"; - - public static final String FORMAT_HEADER = "format"; - - public static final String UPDATESEQ_HEADER = "updatesequence"; - - public static final String BBOX_HEADER = "boundingbox"; - - public static final String MIME_HEADER = "Content-Type"; - - protected static final String CAP_PARAM = "getcapabilities"; - - protected static final String GET_PARAM = "getcoverage"; - - protected static final String DESC_PARAM = "describecoverage"; - - protected static final String GET_DATA_PARAM = "getdata"; - - protected static final String IDENTIFIERS = "identifiers"; - - protected static final String IDENTIFIER = "identifier"; - - protected static final String DOMAIN_SUBSET = "domainsubset"; - - protected static final String OUTPUT = "output"; - - protected static final String GROUP = "group"; - - protected static final String DATASET = "dataset"; - - protected static final String RANGE_SUBSET = "rangesubset"; - - protected static final String LAYER = "layer"; - - protected static final String TIME_SEQUENCE = "timesequence"; - - protected static final String STORE = "store"; - - protected static final String GRID_BASE_CRS = "gridbasecrs"; - - protected static final String GRID_TYPE = "gridtype"; - - protected static final String GRID_ORIGIN = "gridorigin"; - - protected static final String GRID_OFFSETS = "gridoffsets"; - - private Log log = LogFactory.getLog(this.getClass()); - - public WcsHttpHandler(WcsProvider provider) { - this.provider = provider; - } - - @Override - public void handle(OgcHttpRequest request) { - try { - handleInternal(request); - } catch (Exception e) { - log.error("Unable to handle request", e); - } - } - - protected void handleInternal(OgcHttpRequest ogcRequest) throws Exception { - HttpServletResponse response = ogcRequest.getResponse(); - HttpServletRequest httpRequest = ogcRequest.getRequest(); - Map headers = ogcRequest.getHeaders(); - OgcResponse rval = null; - - OgcServiceInfo serviceInfo = getServiceInfo(httpRequest); - WcsRequest request; - - if (ogcRequest.isPost()) { - InputStream is = httpRequest.getInputStream(); - request = provider.getRequest(is); - } else { - request = getRequestFromHeaders(headers); - } - - // Validate exception format parameter - rval = validateExceptionFormat(request); - if (rval != null) { - sendResponse(response, rval); - } - - switch (request.getType()) { - case DescribeCoverage: - rval = provider.describeCoverageType(serviceInfo, - (DescCoverageRequest) request); - break; - case GetCapabilities: - rval = provider.getCapabilities(serviceInfo, - (GetCapRequest) request); - break; - case GetCoverage: - // get coverage does it's own output - GetCoverageRequest gcr = (GetCoverageRequest) request; - if (DefactoEnabler.HEADER_VALUE.equals(headers - .get(DefactoEnabler.HEADER_KEY))) { - gcr.setDefacto(true); - } - provider.getCoverage(serviceInfo, gcr, response); - return; - case ERROR: - rval = (OgcResponse) request.getRequest(); - break; - } - - sendResponse(response, rval); - } - - /** - * @param request - * @return - */ - private OgcResponse validateExceptionFormat(WcsRequest request) { - if (!request.getExceptionFormat().equalsIgnoreCase( - OgcResponse.TEXT_HTML_MIME) - && !request.getExceptionFormat().equalsIgnoreCase( - OgcResponse.TEXT_XML_MIME)) { - return provider.getError( - new WcsException(Code.InvalidParameterValue, - "exceptions parameter invalid"), - OgcResponse.TEXT_XML_MIME); - } - return null; - } - - private OgcServiceInfo getServiceInfo(HttpServletRequest request) { - // FIXME get address from spring - int port = request.getServerPort(); - String base = "http://" + request.getServerName(); - if (port != 80) { - base += ":" + port; - } - base += request.getPathInfo(); - OgcServiceInfo rval = new OgcServiceInfo(base); - rval.addOperationInfo(getOp(base + "?request=" + CAP_PARAM, base, - WcsOpType.GetCapabilities)); - rval.addOperationInfo(getOp(base + "?request=describecoverage", base, - WcsOpType.DescribeCoverage)); - rval.addOperationInfo(getOp(base + "?request=getcoverage", base, - WcsOpType.GetCoverage)); - - return rval; - } - - protected OgcOperationInfo getOp(String get, String post, - WcsOpType type) { - OgcOperationInfo rval = new OgcOperationInfo(type); - // FIXME get version from provider - rval.setHttpGetRes(get); - rval.setHttpPostRes(post); - rval.addVersion("1.1.2"); - rval.addAcceptVersions("1.1.2"); - rval.addService("WCS"); - rval.addFormat("text/xml"); - return rval; - } - - protected String getString(Object obj) { - String rval = null; - if (obj != null) { - if (obj instanceof String) { - rval = (String) obj; - } - } - return rval; - } - - protected String[] getStringArr(Object obj) { - String[] rval = null; - if (obj != null) { - if (obj instanceof String[]) { - rval = (String[]) obj; - } else if (obj instanceof String) { - rval = ((String) obj).split(","); - } - } - return rval; - } - - protected Integer getInt(Object obj) { - Integer rval = null; - if (obj != null) { - if (obj instanceof Integer) { - rval = (Integer) obj; - } else if (obj instanceof String) { - try { - rval = Integer.parseInt((String) obj); - } catch (Exception e) { - // leave rval as null - } - } - } - return rval; - } - - protected Boolean getBool(Object obj) { - Boolean rval = null; - if (obj != null) { - if (obj instanceof Boolean) { - rval = (Boolean) obj; - } else if (obj instanceof String) { - try { - rval = Boolean.parseBoolean((String) obj); - } catch (Exception e) { - // leave rval as null - } - } - } - return rval; - } - - protected WcsRequest getRequestFromHeaders(Map headers) { - WcsRequest rval = null; - Object obj = headers.get(REQUEST_HEADER); - String exceptionFormat = OgcResponse.TEXT_XML_MIME; - if (obj instanceof String) { - exceptionFormat = getString(headers.get(EXCEP_FORMAT_HEADER)); - if (exceptionFormat == null || exceptionFormat.isEmpty()) { - exceptionFormat = OgcResponse.TEXT_XML_MIME; - } - String req = (String) obj; - if (req.equalsIgnoreCase(CAP_PARAM)) { - rval = new GetCapRequest(); - } else if (req.equalsIgnoreCase(DESC_PARAM)) { - rval = buildDescCoverageRequest(headers); - } else if (req.equalsIgnoreCase(GET_PARAM)) { - try { - rval = buildGetCoverageRequest(headers); - } catch (RangeParseException e) { - log.error(e); - rval = new WcsRequest(Type.ERROR); - String msg = "Invalid range parameter"; - WcsException ex = new WcsException( - Code.InvalidParameterValue, msg); - rval.setRequest(provider.getError(ex, exceptionFormat)); - } - } else if (req.equalsIgnoreCase(GET_DATA_PARAM)) { - rval = buildGetDataRequest(headers); - } - } - - if (rval == null) { - OgcResponse error = provider.getError(new WcsException( - Code.InvalidRequest, "Unable to decode request"), - exceptionFormat); - rval = new WcsRequest(Type.ERROR); - rval.setRequest(error); - } - - rval.setExceptionFormat(exceptionFormat); - - return rval; - } - - private WcsRequest buildGetDataRequest(Map headers) { - GetDataRequest rval = new GetDataRequest(); - - String groupName = getHeader(GROUP, headers); - if (groupName != null) { - rval.setGroup(groupName); - } - - String datasetName = getHeader(DATASET, headers); - if (datasetName != null) { - rval.setDataset(datasetName); - } - - return rval; - } - - private WcsRequest buildGetCoverageRequest(Map headers) - throws RangeParseException { - GetCoverageRequest rval = new GetCoverageRequest(); - - String identifier = getHeader(IDENTIFIER, headers); - rval.setIdentifier(identifier); - - String format = getHeader(FORMAT_HEADER, headers); - rval.setFormat(format); - - String timeSequence = getHeader(TIME_SEQUENCE, headers); - if (timeSequence != null) { - rval.setTimeSequence(parseTime(timeSequence)); - } - - String rangesubset = getHeader(RANGE_SUBSET, headers); - if (rangesubset != null) { - rval.setFields(RangeField.getRanges(rangesubset)); - } - - String bbox = getHeader(BBOX_HEADER, headers); - if (bbox != null) { - rval.setBbox(parseBbox(bbox)); - } - - return rval; - } - - protected DataTime parseTime(String timeStr) { - // TODO handle multi-times and periods in ISO 8601 - Calendar cal = DatatypeConverter.parseDateTime(timeStr); - return new DataTime(cal); - } - - private WcsRequest buildDescCoverageRequest(Map headers) { - DescCoverageRequest rval = new DescCoverageRequest(); - - String outputformat = getHeader(OUTPUT, headers); - if (outputformat != null) { - rval.setOutputformat(outputformat); - } - - String[] identifiers = getHeaderArr(IDENTIFIERS, headers); - if (identifiers != null) { - rval.setIdentifiers(identifiers); - } - - return rval; - } - - protected OgcBoundingBox parseBbox(String bbox) { - String[] parts = bbox.split(","); - OgcBoundingBox rval = null; - if (parts.length == 5) { - rval = new OgcBoundingBox(); - try { - rval.setMinx(Double.parseDouble(parts[0])); - rval.setMiny(Double.parseDouble(parts[1])); - rval.setMaxx(Double.parseDouble(parts[2])); - rval.setMaxy(Double.parseDouble(parts[3])); - rval.setCrs(parts[4]); - } catch (NumberFormatException e) { - // FIXME return error - } - }// else TODO handle non 2d WGS84 - return rval; - } - - protected String[] getHeaderArr(String name, Map headers) { - String[] rval; - String value = getHeader(name, headers); - if (value != null) { - rval = value.split(","); - } else { - rval = new String[0]; - } - return rval; - } - - protected String getHeader(String name, Map headers) { - Object obj = headers.get(name); - String rval = null; - if (obj != null && obj instanceof String) { - rval = (String) obj; - } - return rval; - } - - protected void sendResponse(HttpServletResponse httpRes, - OgcResponse response) throws Exception { - OgcResponseOutput.output(response, httpRes); - } - - protected String getLayerLevel(String rangesubset) { - String layerValue = "0"; - - if (rangesubset != null) { - int datasetIndex = rangesubset.indexOf(DATASET); - if (datasetIndex > -1) { - int layerIndex = rangesubset.indexOf(LAYER, datasetIndex); - if (layerIndex > -1) { - int layerStartIndex = rangesubset.indexOf("[", layerIndex); - if (layerStartIndex > -1) { - int layerEndIndex = rangesubset.indexOf("]", - layerStartIndex); - layerValue = rangesubset.substring(layerStartIndex + 1, - layerEndIndex); - } - } - } - } - - return layerValue; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsOperationInfo.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsOperationInfo.java deleted file mode 100644 index 3d853e2901..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsOperationInfo.java +++ /dev/null @@ -1,134 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs; - -import java.util.LinkedList; -import java.util.List; - -public class WcsOperationInfo { - - public enum Type { - GetCapabilities, GetCoverage, DescribeCoverage - } - - protected Type type; - - protected String httpPostRes; - - protected String httpGetRes; - - protected List formats = new LinkedList(); - - /** - * - */ - public WcsOperationInfo(Type type) { - this.type = type; - } - - public WcsOperationInfo(Type type, String httpPostRes, String httpGetRes) { - this(type); - this.httpGetRes = httpGetRes; - this.httpPostRes = httpPostRes; - } - - public void addFormat(String format) { - formats.add(format); - } - - 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 Type getType() { - return type; - } - - /** - * @param type - * the type to set - */ - public void setType(Type type) { - this.type = type; - } - - /** - * @return the formats - */ - public List getFormats() { - return formats; - } - - /** - * @param formats - * the formats to set - */ - public void setFormats(List formats) { - this.formats = formats; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsProvider.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsProvider.java deleted file mode 100644 index ab1e442e6f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsProvider.java +++ /dev/null @@ -1,66 +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.wcs; - -import java.io.InputStream; - -import javax.servlet.http.HttpServletResponse; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType; -import com.raytheon.uf.edex.wcs.request.DescCoverageRequest; -import com.raytheon.uf.edex.wcs.request.GetCapRequest; -import com.raytheon.uf.edex.wcs.request.GetCoverageRequest; -import com.raytheon.uf.edex.wcs.request.WcsRequest; - -/** - * TODO - Class comment here - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 
- * 
- * - * @author - * @version 1 - */ - -public interface WcsProvider { - - public OgcResponse getCapabilities(OgcServiceInfo serviceinfo, - GetCapRequest request); - - public OgcResponse describeCoverageType( - OgcServiceInfo serviceinfo, DescCoverageRequest request); - - public void getCoverage(OgcServiceInfo serviceinfo, - GetCoverageRequest request, HttpServletResponse response); - - public WcsRequest getRequest(InputStream in); - - public OgcResponse getError(WcsException e, String exceptionFormat); - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsServiceInfo.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsServiceInfo.java deleted file mode 100644 index fb0873408a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/WcsServiceInfo.java +++ /dev/null @@ -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 - * - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs; - -import java.util.LinkedList; -import java.util.List; - -public class WcsServiceInfo { - - protected String onlineResource; - - protected List operations = new LinkedList(); - - /** - * - */ - public WcsServiceInfo(String onlineResouce) { - this.onlineResource = onlineResouce; - } - - public void addOperationInfo(WcsOperationInfo 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 getOperations() { - return operations; - } - - /** - * @param operations - * the operations to set - */ - public void setOperations(List operations) { - this.operations = operations; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/DataRecordIOSP.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/DataRecordIOSP.java deleted file mode 100644 index e61204b3fb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/DataRecordIOSP.java +++ /dev/null @@ -1,242 +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 3, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.format; - -import java.io.IOException; -import java.nio.channels.WritableByteChannel; - -import ucar.ma2.Array; -import ucar.ma2.InvalidRangeException; -import ucar.ma2.Section; -import ucar.ma2.StructureDataIterator; -import ucar.nc2.NetcdfFile; -import ucar.nc2.ParsedSectionSpec; -import ucar.nc2.Structure; -import ucar.nc2.Variable; -import ucar.nc2.iosp.IOServiceProvider; -import ucar.nc2.util.CancelTask; -import ucar.unidata.io.RandomAccessFile; - -import com.raytheon.uf.common.datastorage.records.IDataRecord; - -/** - * - * @author bclement - * @version 1.0 - */ -public class DataRecordIOSP implements IOServiceProvider { - - protected IDataRecord dataRecord; - - public DataRecordIOSP(IDataRecord dataRecord) { - this.dataRecord = dataRecord; - } - - /* - * (non-Javadoc) - * - * @see - * ucar.nc2.iosp.IOServiceProvider#isValidFile(ucar.unidata.io.RandomAccessFile - * ) - */ - @Override - public boolean isValidFile(RandomAccessFile arg0) throws IOException { - System.out.println(); - return false; - } - - /* - * (non-Javadoc) - * - * @see - * ucar.nc2.iosp.IOServiceProvider#open(ucar.unidata.io.RandomAccessFile, - * ucar.nc2.NetcdfFile, ucar.nc2.util.CancelTask) - */ - @Override - public void open(RandomAccessFile arg0, NetcdfFile arg1, CancelTask arg2) - throws IOException { - System.out.println(); - - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#readData(ucar.nc2.Variable, - * ucar.ma2.Section) - */ - @Override - public Array readData(Variable arg0, Section arg1) throws IOException, - InvalidRangeException { - System.out.println(); - return null; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#close() - */ - @Override - public void close() throws IOException { - System.out.println(); - - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#getDetailInfo() - */ - @Override - public String getDetailInfo() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#getFileTypeDescription() - */ - @Override - public String getFileTypeDescription() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#getFileTypeId() - */ - @Override - public String getFileTypeId() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#getFileTypeVersion() - */ - @Override - public String getFileTypeVersion() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see - * ucar.nc2.iosp.IOServiceProvider#getStructureIterator(ucar.nc2.Structure, - * int) - */ - @Override - public StructureDataIterator getStructureIterator(Structure arg0, int arg1) - throws IOException { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see - * ucar.nc2.iosp.IOServiceProvider#readSection(ucar.nc2.ParsedSectionSpec) - */ - @Override - public Array readSection(ParsedSectionSpec arg0) throws IOException, - InvalidRangeException { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#readToByteChannel(ucar.nc2.Variable, - * ucar.ma2.Section, java.nio.channels.WritableByteChannel) - */ - @Override - public long readToByteChannel(Variable arg0, Section arg1, - WritableByteChannel arg2) throws IOException, InvalidRangeException { - // TODO Auto-generated method stub - return 0; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#sendIospMessage(java.lang.Object) - */ - @Override - public Object sendIospMessage(Object arg0) { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#sync() - */ - @Override - public boolean sync() throws IOException { - // TODO Auto-generated method stub - return false; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#syncExtend() - */ - @Override - public boolean syncExtend() throws IOException { - // TODO Auto-generated method stub - return false; - } - - /* - * (non-Javadoc) - * - * @see ucar.nc2.iosp.IOServiceProvider#toStringDebug(java.lang.Object) - */ - @Override - public String toStringDebug(Object arg0) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/NetCdfFormatter.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/NetCdfFormatter.java deleted file mode 100644 index f5ad4e34bf..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/NetCdfFormatter.java +++ /dev/null @@ -1,258 +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 3, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.format; - -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.measure.unit.NonSI; -import javax.measure.unit.Unit; - -import org.apache.commons.codec.binary.Base64; -import org.geotools.coverage.grid.GridGeometry2D; -import org.opengis.metadata.spatial.PixelOrientation; -import org.opengis.referencing.operation.MathTransform2D; - -import ucar.ma2.Array; -import ucar.ma2.DataType; -import ucar.nc2.Attribute; -import ucar.nc2.Dimension; -import ucar.nc2.NetcdfFile; -import ucar.nc2.NetcdfFileWriteable; -import ucar.nc2.Variable; -import ucar.nc2.iosp.IOServiceProvider; - -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.edex.wcs.reg.Coverage; - -/** - * - * @author bclement - * @version 1.0 - */ -public class NetCdfFormatter implements WcsDataFormatter { - - private static final String CF_VERSION = "CF-1.0"; - protected String id = "application/netcdf"; - - protected class DirectNetcdfFile extends NetcdfFile { - public DirectNetcdfFile(IOServiceProvider spi, String name) - throws IOException { - super(spi, null, name, null); - } - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.format.WcsDataFormatter#getIdentifier() - */ - @Override - public String getIdentifier() { - return id; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wcs.format.WcsDataFormatter#format(com.raytheon. - * uf.common.datastorage.records.IDataRecord, java.io.OutputStream, boolean) - */ - @Override - public void format(Coverage coverage, OutputStream out, boolean base64) - throws Exception { - - IDataRecord record = coverage.getDataRecord(); - - File tempFile = File.createTempFile("wcs", ".nc"); - NetcdfFileWriteable ncFile = NetcdfFileWriteable.createNew( - tempFile.getAbsolutePath(), false); - - List dimList = new ArrayList(); - List dimListForDataBecauseNetcdfIsOpposite = new ArrayList(); - long[] sizes = record.getSizes(); - // int[] shape = new int[sizes.length]; - for (int i = 0; i < sizes.length; i++) { - Dimension dim = ncFile.addDimension("dim" + i, (int) sizes[i]); - dimList.add(dim); - dimListForDataBecauseNetcdfIsOpposite.add(dim); - // shape[i] = (int) sizes[i]; - } - - Class javaDataType = null; - Object dataContent = null; - DataType ncDataType = null; - if (record instanceof ByteDataRecord) { - javaDataType = byte.class; - ncDataType = DataType.BYTE; - dataContent = ((ByteDataRecord) record).getByteData(); - } else if (record instanceof FloatDataRecord) { - javaDataType = float.class; - ncDataType = DataType.FLOAT; - dataContent = ((FloatDataRecord) record).getFloatData(); - } - - // reverse netcdf dimensions - Collections.reverse(dimListForDataBecauseNetcdfIsOpposite); - - - ncFile.addGlobalAttribute("Conventions", CF_VERSION); - Variable dataVariable = ncFile.addVariable("data", ncDataType, - dimListForDataBecauseNetcdfIsOpposite); - - // TODO - (netcdf) what if I'm not using lat/lon? - dataVariable.addAttribute(new Attribute("coordinates", - "Time Latitude Longitude lat lon")); - - - - // add dimention variables - - GridGeometry2D gridGeom = coverage.getGridGeometry(); - MathTransform2D gridToCrs = gridGeom.getGridToCRS2D(PixelOrientation.UPPER_LEFT); - - int dims = sizes.length; - - int minMax[][] = new int[dims][2]; - - for ( int dim = 0; dim < dims; ++dim ) { - minMax[dim][0] = gridGeom.getGridRange().getLow(dim); - minMax[dim][1] = gridGeom.getGridRange().getHigh(dim); - - List dimAsList = new ArrayList(1); - dimAsList.add(dimList.get(dim)); - Variable axisVariable = ncFile.addVariable("dim" + dim, - DataType.DOUBLE, dimAsList); - - // add attributes to the variable - - // units - Unit unit = coverage.getCrs().getCoordinateSystem().getAxis(dim).getUnit(); - String unitName = unit.toString(); - if (NonSI.DEGREE_ANGLE.toString().equals(unitName)) { - unitName = "degree_" - + coverage.getCrs().getCoordinateSystem().getAxis(dim) - .getDirection().name().toLowerCase(); - } - - Attribute axisUnit = new Attribute("units", unitName); - axisVariable.addAttribute(axisUnit); - // standard_name - // TODO - (netcdf) make spec - String name = coverage.getCrs().getCoordinateSystem().getAxis(dim) - .getName().toString().replaceAll(" ", "_").toLowerCase(); - Attribute axisName = new Attribute("standard_name", name); - axisVariable.addAttribute(axisName); - } - - // create file, then dump data into it - ncFile.create(); - - for (int dim = 0; dim < dims; ++dim) { - double axisValues[] = new double[minMax[dim][1] - minMax[dim][0] - + 1]; - for (int coord = minMax[dim][0]; coord <= minMax[dim][1]; ++coord) { - double[] point = new double[dims]; - for (int i = 0; i < dims; ++i) { - if (i == dim) { - point[i] = coord; - } else { - point[i] = minMax[i][0]; - } - } - double[] crsPoint = new double[dims]; - gridToCrs.transform(point, 0, crsPoint, 0, 1); - axisValues[coord] = crsPoint[dim]; - } - - - ncFile.write("dim" + dim, new int[] { 0, 0 }, - Array.factory(double.class, new int[] { minMax[dim][1] - - minMax[dim][0] + 1 }, axisValues)); - - - // ncFile.flush(); - } - - coverage.getCrs().getCoordinateSystem().getAxis(0).getUnit(); - - // reverse shape - int[] shape = new int[sizes.length]; - for (int i = 0; i < sizes.length; ++i) { - shape[i] = (int) sizes[sizes.length - (i + 1)]; - } - - ncFile.write("data", new int[] { 0, 0 }, - Array.factory(javaDataType, shape, dataContent)); - - ncFile.flush(); - ncFile.close(); - - - byte[] data = new byte[(int) tempFile.length()]; - DataInputStream dis = new DataInputStream(new FileInputStream(tempFile)); - dis.readFully(data); - dis.close(); - - if (base64) { - Base64 b64 = new Base64(); - data = b64.encode(data); - } - out.write(data); - out.flush(); - tempFile.delete(); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(String id) { - this.id = id; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/ThriftFormatter.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/ThriftFormatter.java deleted file mode 100644 index e003bfa1c0..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/ThriftFormatter.java +++ /dev/null @@ -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 - * - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * May 23, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.format; - -import java.io.OutputStream; - -import org.apache.commons.codec.binary.Base64; - -import com.raytheon.uf.common.serialization.SerializationUtil; -import com.raytheon.uf.edex.wcs.WcsCoverageThriftReponse; -import com.raytheon.uf.edex.wcs.reg.Coverage; - -/** - * - * @author bclement - * @version 1.0 - */ -public class ThriftFormatter implements WcsDataFormatter { - - protected String id = "application/x-thrift"; - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.format.WcsReturnFormat#getIdentifier() - */ - @Override - public String getIdentifier() { - return id; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wcs.format.WcsReturnFormat#format(com.raytheon.uf - * .common.datastorage.records.IDataRecord, java.io.OutputStream, boolean) - */ - @Override - public void format(Coverage coverage, OutputStream out, boolean base64) - throws Exception { - WcsCoverageThriftReponse thriftable = new WcsCoverageThriftReponse(); - thriftable.setDataRecord(coverage.getDataRecord()); - thriftable.setCrsString(coverage.getCrs().getName().toString()); - thriftable.setTimeString(coverage.getTime()); - thriftable.setEnvelopeString(coverage.getEnvelope().toString()); - - byte[] data = SerializationUtil.transformToThrift(thriftable); - if (base64) { - Base64 b64 = new Base64(); - data = b64.encode(data); - } - out.write(data); - out.flush(); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/WcsDataFormatter.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/WcsDataFormatter.java deleted file mode 100644 index 959f8d9bfe..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/format/WcsDataFormatter.java +++ /dev/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 - * ------------ ---------- ----------- -------------------------- - * May 23, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.format; - -import java.io.OutputStream; - -import com.raytheon.uf.edex.wcs.reg.Coverage; - -/** - * - * @author bclement - * @version 1.0 - */ -public interface WcsDataFormatter { - - public String getIdentifier(); - - public void format(Coverage coverage, OutputStream out, boolean base64) - throws Exception; -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/CapabilitiesBuilder.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/CapabilitiesBuilder.java deleted file mode 100644 index 31ff73ee2f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/CapabilitiesBuilder.java +++ /dev/null @@ -1,282 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.provider; - -import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getAsLangString; -import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getKeywords; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.xml.bind.JAXBElement; - -import net.opengis.ows.v_1_1_0.AddressType; -import net.opengis.ows.v_1_1_0.CodeType; -import net.opengis.ows.v_1_1_0.ContactType; -import net.opengis.ows.v_1_1_0.KeywordsType; -import net.opengis.ows.v_1_1_0.LanguageStringType; -import net.opengis.ows.v_1_1_0.OnlineResourceType; -import net.opengis.ows.v_1_1_0.ResponsiblePartySubsetType; -import net.opengis.ows.v_1_1_0.ServiceIdentification; -import net.opengis.ows.v_1_1_0.ServiceProvider; -import net.opengis.ows.v_1_1_0.WGS84BoundingBoxType; -import net.opengis.wcs.v_1_1_2.Capabilities; -import net.opengis.wcs.v_1_1_2.Contents; -import net.opengis.wcs.v_1_1_2.CoverageSummaryType; -import net.opengis.wcs.v_1_1_2.ObjectFactory; - -import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox; -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType; -import com.raytheon.uf.edex.wcs.reg.CoverageDescription; - -/** - * - * @author bclement - * @version 1.0 - */ -public class CapabilitiesBuilder { - - protected String version = "1.1.2"; - protected String OWS_NS = OgcNamespace.OWS110; - - protected String WCS_NS = OgcNamespace.WCS112; - - protected String updateSequence = "1"; - - protected String SERV_TYPE = "WCS"; - protected static final String wcsName = "WCS"; - protected String SERV_TITLE = "EDEX WCS"; - - protected static final String svcTitle = "EDEX Coverage Server"; - - protected OperationsDescriber opDesc = new OperationsDescriber(); - - protected ObjectFactory wcsFactory = new ObjectFactory(); - - protected List formats; - - protected net.opengis.ows.v_1_1_0.ObjectFactory owsFactory = new net.opengis.ows.v_1_1_0.ObjectFactory(); - - public CapabilitiesBuilder(List formats) { - this.formats = formats; - } - - public Capabilities getCapabilities(OgcServiceInfo serviceinfo, - List coverages) { - - Capabilities capabilities = new Capabilities(); - capabilities.setVersion(version); - // capabilities.setUpdateSequence(updateSequence); - // capabilities - // .setServiceIdentification(getServiceIdentification(serviceinfo)); - // capabilities.setServiceProvider(getServiceProvider(serviceinfo)); - capabilities.setOperationsMetadata(opDesc.getOpData(serviceinfo)); - capabilities.setContents(getContents(coverages)); - - return capabilities; - } - - protected Contents getContents(List coverages) { - Contents rval = new Contents(); - List cstList = new ArrayList(); - for (CoverageDescription coverage : coverages) { - cstList.add(getCoverageSummaryType(coverage)); - } - rval.setSupportedFormat(formats); - rval.setCoverageSummary(cstList); - return rval; - } - - protected List> getBboxes( - OgcGeoBoundingBox bbox) { - if (bbox == null) { - return new ArrayList>(0); - } - List> rval = new ArrayList>( - 1); - WGS84BoundingBoxType to = owsFactory.createWGS84BoundingBoxType(); - to.setLowerCorner(Arrays.asList(bbox.getMinx(), bbox.getMiny())); - to.setUpperCorner(Arrays.asList(bbox.getMaxx(), bbox.getMaxy())); - to.setDimensions(BigInteger.valueOf(2)); - rval.add(owsFactory.createWGS84BoundingBox(to)); - - return rval; - } - - protected CoverageSummaryType getCoverageSummaryType(CoverageDescription cov) { - CoverageSummaryType cst = new CoverageSummaryType(); - - cst.setTitle(getAsLangString(cov.getTitle())); - cst.setAbstract(getAsLangString(cov.getAbstractStr())); - if (cov.getKeywords() != null) { - cst.setKeywords(getKeywords(cov.getKeywords())); - } - - List> jaxbList = new ArrayList>(); - - jaxbList.addAll(getBboxes(cov.getCrs84Bbox())); - - if (cov.getCrs() != null && cov.getCrs().size() > 0) { - for (String crs : cov.getCrs()) { - jaxbList.add(owsFactory.createSupportedCRS(crs)); - } - } - if (cov.getIdentifier() != null) { - jaxbList.add(wcsFactory.createIdentifier(cov.getIdentifier())); - } - cst.setContent(jaxbList); - return cst; - } - - // the following methods are for optional metadata that aren't currently - // used - - protected ResponsiblePartySubsetType getResponsibleParty() { - ResponsiblePartySubsetType rval = new ResponsiblePartySubsetType(); - rval.setIndividualName("Individual Name"); - rval.setPositionName("TBD"); - - CodeType ct = new CodeType(); - ct.setCodeSpace("role"); - ct.setValue("TBD"); - rval.setRole(ct); - - // Contact Information - ContactType contact = new ContactType(); - AddressType address = new AddressType(); - address.setAdministrativeArea("TBD"); - - List addressPointList = new ArrayList(); - addressPointList.add("TBD"); - address.setDeliveryPoint(addressPointList); - - address.setCity("TBD"); - address.setCountry("TBD"); - - List emailList = new ArrayList(); - emailList.add("TBD"); - address.setElectronicMailAddress(emailList); - address.setPostalCode("TBD"); - - contact.setAddress(address); - contact.setContactInstructions("TBD"); - - rval.setContactInfo(contact); - - return rval; - } - - protected OnlineResourceType getOLR(OgcServiceInfo serviceinfo) { - OnlineResourceType rval = new OnlineResourceType(); - - if (serviceinfo != null && serviceinfo.getOnlineResource() != null) { - rval.setHref(serviceinfo.getOnlineResource()); - } - rval.setActuate("TBD"); - rval.setArcrole("TBD"); - rval.setRole("TBD"); - rval.setShow("TBD"); - rval.setTitle("TBD"); - rval.setType("TBD"); - return rval; - } - - protected ServiceIdentification getServiceIdentification( - OgcServiceInfo serviceinfo) { - ServiceIdentification rval = new ServiceIdentification(); - - // Abstract - List lstList = new ArrayList(); - LanguageStringType lst = new LanguageStringType(); - lst.setLang(WcsJaxbUtils.DEFAULT_LANGUAGE); - lst.setValue("TBD"); - rval.setAbstract(lstList); - - // Constraints - List constraints = new ArrayList(); - constraints.add("NONE"); - rval.setAccessConstraints(constraints); - - // Fees - rval.setFees("fees"); - - // Key Words - List keyWordTypeList = new ArrayList(); - KeywordsType kt = new KeywordsType(); - lstList = new ArrayList(); - lst = new LanguageStringType(); - lst.setLang(WcsJaxbUtils.DEFAULT_LANGUAGE); - lst.setValue("keyword"); - lstList.add(lst); - kt.setKeyword(lstList); - keyWordTypeList.add(kt); - rval.setKeywords(keyWordTypeList); - - // Profile - List profileList = new ArrayList(); - profileList.add("TBD"); - profileList.add("TBD"); - rval.setProfile(profileList); - - // Service Type - CodeType codeType = new CodeType(); - codeType.setCodeSpace("codetype"); - rval.setServiceType(codeType); - - // Service Type Version - List serviceTypeVersion = new ArrayList(); - serviceTypeVersion.add("servicetypeversion"); - rval.setServiceTypeVersion(serviceTypeVersion); - - // Title - lstList = new ArrayList(); - lst = new LanguageStringType(); - lst.setLang(WcsJaxbUtils.DEFAULT_LANGUAGE); - lst.setValue(SERV_TITLE); - lstList.add(lst); - rval.setTitle(lstList); - - return rval; - } - - protected ServiceProvider getServiceProvider( - OgcServiceInfo serviceInfo) { - ServiceProvider rval = new ServiceProvider(); - rval.setProviderName(wcsName); - rval.setServiceContact(getResponsibleParty()); - rval.setProviderSite(getOLR(serviceInfo)); - return rval; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/DescCoverageBuilder.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/DescCoverageBuilder.java deleted file mode 100644 index e8f2423827..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/DescCoverageBuilder.java +++ /dev/null @@ -1,381 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.provider; - -import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getAsLangString; -import static com.raytheon.uf.edex.wcs.provider.WcsJaxbUtils.getKeywords; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import javax.xml.bind.JAXBElement; - -import net.opengis.gml.v_3_1_1.PolygonType; -import net.opengis.gml.v_3_1_1.TimePositionType; -import net.opengis.ows.v_1_1_0.AllowedValues; -import net.opengis.ows.v_1_1_0.AnyValue; -import net.opengis.ows.v_1_1_0.BoundingBoxType; -import net.opengis.ows.v_1_1_0.CodeType; -import net.opengis.ows.v_1_1_0.DomainMetadataType; -import net.opengis.ows.v_1_1_0.ObjectFactory; -import net.opengis.ows.v_1_1_0.UnNamedDomainType; -import net.opengis.ows.v_1_1_0.ValueType; -import net.opengis.wcs.v_1_1_2.AvailableKeys; -import net.opengis.wcs.v_1_1_2.AxisType; -import net.opengis.wcs.v_1_1_2.CoverageDescriptionType; -import net.opengis.wcs.v_1_1_2.CoverageDomainType; -import net.opengis.wcs.v_1_1_2.FieldType; -import net.opengis.wcs.v_1_1_2.GridCrsType; -import net.opengis.wcs.v_1_1_2.InterpolationMethodType; -import net.opengis.wcs.v_1_1_2.InterpolationMethods; -import net.opengis.wcs.v_1_1_2.RangeType; -import net.opengis.wcs.v_1_1_2.SpatialDomainType; -import net.opengis.wcs.v_1_1_2.TimePeriodType; -import net.opengis.wcs.v_1_1_2.TimeSequenceType; - -import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311CoordinateConverter; -import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311LinearRingConverter; -import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311PolygonConverter; -import org.jvnet.ogc.gml.v_3_1_1.jts.JTSToGML311SRSReferenceGroupConverter; - -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.common.time.TimeRange; -import com.raytheon.uf.edex.ogc.common.OgcBoundingBox; -import com.raytheon.uf.edex.ogc.common.db.LayerTransformer; -import com.raytheon.uf.edex.wcs.reg.CoverageDescription; -import com.raytheon.uf.edex.wcs.reg.RangeAxis; -import com.raytheon.uf.edex.wcs.reg.RangeField; -import com.raytheon.uf.edex.wcs.reg.RangeField.InterpolationType; -import com.raytheon.uf.edex.wcs.reg.RangeFieldDefinition; -import com.vividsolutions.jts.geom.Polygon; - -/** - * - * @author bclement - * @version 1.0 - */ -public class DescCoverageBuilder { - - protected ObjectFactory owsFactory = new ObjectFactory(); - - protected org.jvnet.ogc.gml.v_3_1_1.ObjectFactory gmlFactory = new org.jvnet.ogc.gml.v_3_1_1.ObjectFactory(); - - protected List formats; - - protected JTSToGML311PolygonConverter polyConverter; - - /** - * @param formats - */ - public DescCoverageBuilder(List formats) { - super(); - this.formats = formats; - JTSToGML311SRSReferenceGroupConverter srsConv = new JTSToGML311SRSReferenceGroupConverter(); - JTSToGML311CoordinateConverter coordConv = new JTSToGML311CoordinateConverter( - gmlFactory, srsConv); - JTSToGML311LinearRingConverter ringConv = new JTSToGML311LinearRingConverter( - gmlFactory, srsConv, coordConv); - polyConverter = new JTSToGML311PolygonConverter(gmlFactory, srsConv, - ringConv); - } - - protected List> getBboxes(List bboxes) { - if (bboxes == null) { - return null; - } - List> rval = new ArrayList>(bboxes.size()); - for (OgcBoundingBox from : bboxes) { - BoundingBoxType to = owsFactory.createBoundingBoxType(); - to.setLowerCorner(Arrays.asList(from.getMinx(), from.getMiny())); - to.setUpperCorner(Arrays.asList(from.getMaxx(), from.getMaxy())); - to.setDimensions(BigInteger.valueOf(2)); - rval.add(owsFactory.createBoundingBox(to)); - } - return rval; - } - - protected PolygonType transform(Polygon p) { - if (p == null) { - return null; - } - return polyConverter.createGeometryType(p); - } - - protected List getPolys(Polygon... poly) { - if (poly == null) { - return null; - } - List rval = new ArrayList(poly.length); - for (Polygon p : poly) { - rval.add(transform(p)); - } - return rval; - } - - protected SpatialDomainType getSpatialDomain(CoverageDescription desc) { - SpatialDomainType rval = new SpatialDomainType(); - List> bboxes = getBboxes(desc.getBboxes()); - if (bboxes != null) { - rval.setBoundingBox(bboxes); - } - rval.setPolygon(getPolys(desc.getPolygon())); - rval.setGridCRS(getGridCrs(desc)); - return rval; - } - - /** - * @param dimentions - * @param gridBaseCrs - * @return - */ - protected GridCrsType getGridCrs(CoverageDescription desc) { - GridCrsType rval = new GridCrsType(); - rval.setGridBaseCRS(desc.getGridBaseCrs()); - rval.setGridType(desc.getGridType()); - List gridOrigin = desc.getGridOrigin(); - if (gridOrigin != null) { - rval.setGridOrigin(gridOrigin); - } - List gridOffsets = desc.getGridOffsets(); - if (gridOffsets != null) { - rval.setGridOffsets(gridOffsets); - } - rval.setGridCS(desc.getGridCs()); - - return rval; - } - - protected TimePositionType transform(Date time) { - TimePositionType rval = new TimePositionType(); - String timeStr = LayerTransformer.format(time); - rval.setValue(Arrays.asList(timeStr)); - return rval; - } - - protected TimeSequenceType getTimeSequence(List times) { - if (times == null) { - return null; - } - TimeSequenceType timeSequence = new TimeSequenceType(); - List rval = new ArrayList(times.size()); - for (DataTime time : times) { - if (time.getUtilityFlags().contains(DataTime.FLAG.PERIOD_USED)) { - TimePeriodType tp = new TimePeriodType(); - TimeRange vp = time.getValidPeriod(); - tp.setBeginPosition(transform(vp.getStart())); - tp.setEndPosition(transform(vp.getEnd())); - rval.add(tp); - } else { - rval.add(transform(time.getRefTime())); - } - } - timeSequence.setTimePositionOrTimePeriod(rval); - return timeSequence; - } - - protected CoverageDomainType getDomain(CoverageDescription desc) { - CoverageDomainType coverageDomain = new CoverageDomainType(); - coverageDomain.setSpatialDomain(getSpatialDomain(desc)); - coverageDomain.setTemporalDomain(getTimeSequence(desc.getTimes())); - return coverageDomain; - } - - public CoverageDescriptionType getCoverageDescriptionType( - CoverageDescription description) { - CoverageDescriptionType cdt = new CoverageDescriptionType(); - cdt.setIdentifier(description.getIdentifier()); - cdt.setTitle(getAsLangString(description.getTitle())); - cdt.setAbstract(getAsLangString(description.getAbstractStr())); - if (description.getKeywords() != null) { - cdt.setKeywords(getKeywords(description.getKeywords())); - } - cdt.setSupportedCRS(description.getCrs()); - cdt.setSupportedFormat(formats); - cdt.setDomain(getDomain(description)); - cdt.setRange(getRange(description.getRangeFields())); - return cdt; - } - - protected ValueType getAsValue(Object obj) { - if (obj == null) { - return null; - } - ValueType rval = new ValueType(); - rval.setValue(obj.toString()); - return rval; - } - - protected DomainMetadataType getUnits(String units) { - if (units == null) { - return null; - } - DomainMetadataType uom = new DomainMetadataType(); - uom.setValue(units); - return uom; - } - - protected AllowedValues getAllowedValues(RangeFieldDefinition def) { - AllowedValues values = new AllowedValues(); - net.opengis.ows.v_1_1_0.RangeType range = new net.opengis.ows.v_1_1_0.RangeType(); - range.setMaximumValue(getAsValue(def.getMaxValue())); - range.setMinimumValue(getAsValue(def.getMinValue())); - values.setValueOrRange(Arrays.asList((Object) range)); - return values; - } - - protected UnNamedDomainType getUnamed(RangeFieldDefinition def) { - UnNamedDomainType rval = new UnNamedDomainType(); - if (def == null) { - rval.setAnyValue(new AnyValue()); - } else { - rval.setAllowedValues(getAllowedValues(def)); - rval.setUOM(getUnits(def.getUnits())); - } - return rval; - } - - protected FieldType transform(RangeField from) { - if (from == null) { - return null; - } - FieldType rval = new FieldType(); - rval.setIdentifier(from.getIdentifier()); - rval.setDefinition(getUnamed(from.getDefinition())); - rval.setInterpolationMethods(getInterps(from.getDefaultInterpolation(), - from.getAdditionalInterpolations())); - if (from.getAxis() != null) { - rval.setAxis(getAxis(from.getAxis())); - } - if (from.getNullValue() != null) { - rval.setNullValue(getNullValues(from.getNullValue())); - } - return rval; - } - - /** - * @param nullValue - * @return - */ - protected List getNullValues(String... nullValue) { - if (nullValue == null) { - return null; - } - List rval = new ArrayList(nullValue.length); - for (String val : nullValue) { - CodeType code = new CodeType(); - code.setValue(val); - rval.add(code); - } - return rval; - } - - protected AvailableKeys getKeys(Set keys) { - if (keys == null) { - return null; - } - AvailableKeys rval = new AvailableKeys(); - rval.setKey(new ArrayList(keys)); - return rval; - } - - /** - * @param axis - * @return - */ - private List getAxis(List axis) { - if (axis == null) { - return null; - } - List rval = new ArrayList(axis.size()); - for (RangeAxis ra : axis) { - AxisType at = new AxisType(); - at.setIdentifier(ra.getIdentifier()); - at.setAvailableKeys(getKeys(ra.getKeys())); - rval.add(at); - } - return rval; - } - - protected List transform( - List from) { - if (from == null) { - return null; - } - List rval = new ArrayList( - from.size()); - for (InterpolationType type : from) { - InterpolationMethodType method = new InterpolationMethodType(); - method.setValue(type.toString()); - rval.add(method); - } - return rval; - } - - /** - * @param defaultInterpolation - * @param additionalInterpolations - * @return - */ - protected InterpolationMethods getInterps(InterpolationType defaultInt, - List additional) { - InterpolationMethods rval = new InterpolationMethods(); - if (defaultInt == null) { - defaultInt = InterpolationType.none; - } - rval.setDefault(defaultInt.toString()); - if (additional != null) { - rval.setInterpolationMethod(transform(additional)); - } - return rval; - } - - /** - * @param rangeFields - * @return - */ - protected RangeType getRange(List rangeFields) { - if (rangeFields == null) { - return null; - } - List rval = new ArrayList(rangeFields.size()); - for (RangeField rf : rangeFields) { - rval.add(transform(rf)); - } - RangeType rt = new RangeType(); - rt.setField(rval); - return rt; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/OgcWcsProvider.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/OgcWcsProvider.java deleted file mode 100644 index 36c2e3f0d9..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/OgcWcsProvider.java +++ /dev/null @@ -1,628 +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 - * ------------ ---------- ----------- -------------------------- - * - * - */ - -package com.raytheon.uf.edex.wcs.provider; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import javax.servlet.http.HttpServletResponse; -import javax.xml.bind.DatatypeConverter; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; - -import net.opengis.gml.v_3_1_1.TimePositionType; -import net.opengis.ows.v_1_1_0.AbstractReferenceBaseType; -import net.opengis.ows.v_1_1_0.BoundingBoxType; -import net.opengis.ows.v_1_1_0.CodeType; -import net.opengis.ows.v_1_1_0.ExceptionReport; -import net.opengis.ows.v_1_1_0.ExceptionType; -import net.opengis.ows.v_1_1_0.GetCapabilitiesType; -import net.opengis.ows.v_1_1_0.ReferenceGroupType; -import net.opengis.ows.v_1_1_0.ReferenceType; -import net.opengis.wcs.v_1_1_2.AxisSubset; -import net.opengis.wcs.v_1_1_2.Capabilities; -import net.opengis.wcs.v_1_1_2.CoverageDescriptionType; -import net.opengis.wcs.v_1_1_2.CoverageDescriptions; -import net.opengis.wcs.v_1_1_2.CoveragesType; -import net.opengis.wcs.v_1_1_2.DescribeCoverage; -import net.opengis.wcs.v_1_1_2.DomainSubsetType; -import net.opengis.wcs.v_1_1_2.GetCoverage; -import net.opengis.wcs.v_1_1_2.GridCrsType; -import net.opengis.wcs.v_1_1_2.ObjectFactory; -import net.opengis.wcs.v_1_1_2.OutputType; -import net.opengis.wcs.v_1_1_2.RangeSubsetType; -import net.opengis.wcs.v_1_1_2.RangeSubsetType.FieldSubset; -import net.opengis.wcs.v_1_1_2.TimePeriodType; -import net.opengis.wcs.v_1_1_2.TimeSequenceType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.springframework.context.ApplicationContext; - -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.common.time.TimeRange; -import com.raytheon.uf.edex.core.EDEXUtil; -import com.raytheon.uf.edex.ogc.common.OgcBoundingBox; -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcPrefix; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcResponse.ErrorType; -import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager; -import com.raytheon.uf.edex.ogc.common.spatial.CrsLookup; -import com.raytheon.uf.edex.wcs.WcsException; -import com.raytheon.uf.edex.wcs.WcsException.Code; -import com.raytheon.uf.edex.wcs.WcsProvider; -import com.raytheon.uf.edex.wcs.format.WcsDataFormatter; -import com.raytheon.uf.edex.wcs.reg.Coverage; -import com.raytheon.uf.edex.wcs.reg.CoverageDescription; -import com.raytheon.uf.edex.wcs.reg.RangeAxis; -import com.raytheon.uf.edex.wcs.reg.RangeField; -import com.raytheon.uf.edex.wcs.reg.RangeField.InterpolationType; -import com.raytheon.uf.edex.wcs.reg.WcsSource; -import com.raytheon.uf.edex.wcs.reg.WcsSourceAccessor; -import com.raytheon.uf.edex.wcs.request.DescCoverageRequest; -import com.raytheon.uf.edex.wcs.request.GetCapRequest; -import com.raytheon.uf.edex.wcs.request.GetCoverageRequest; -import com.raytheon.uf.edex.wcs.request.WcsRequest; -import com.raytheon.uf.edex.wcs.request.WcsRequest.Type; -import com.vividsolutions.jts.geom.Envelope; - -/** - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 
- * 
- * - * @author cwmitche - * @version 1 - */ -public class OgcWcsProvider implements WcsProvider { - - public enum WcsOpType { - GetCapabilities, GetCoverage, DescribeCoverage - } - - protected static final String version = "1.1.2"; - - protected static final String svcTitle = "EDEX Coverage Server"; - - protected OgcJaxbManager jaxbManager; - - protected String COVERAGE_ID = "cid:Coverage-"; - - protected Log log = LogFactory.getLog(this.getClass()); - - protected DescCoverageBuilder descCoverage; - - protected CapabilitiesBuilder capbuilder; - - protected WcsSourceAccessor reg = new WcsSourceAccessor(); - - protected boolean base64 = true; - - protected net.opengis.ows.v_1_1_0.ObjectFactory owsFactory = new net.opengis.ows.v_1_1_0.ObjectFactory(); - - protected ObjectFactory wcsFactory = new ObjectFactory(); - - protected static final Map NS_MAP = new ConcurrentHashMap(); - - protected static final Map formatMap = new HashMap(); - - static { - NS_MAP.put(OgcNamespace.EDEX, OgcPrefix.EDEX); - NS_MAP.put(OgcNamespace.GML, OgcPrefix.GML); - NS_MAP.put(OgcNamespace.OGC, OgcPrefix.OGC); - NS_MAP.put(OgcNamespace.OWS110, OgcPrefix.OWS); - NS_MAP.put(OgcNamespace.WFS, OgcPrefix.WFS); - NS_MAP.put(OgcNamespace.XSI, OgcPrefix.XSI); - NS_MAP.put(OgcNamespace.WCS112, OgcPrefix.WCS); - NS_MAP.put(OgcNamespace.XLINK, OgcPrefix.XLINK); - } - - public OgcWcsProvider() throws JAXBException { - this.jaxbManager = new OgcJaxbManager(new Class[] { - ObjectFactory.class, - net.opengis.ows.v_1_1_0.ObjectFactory.class, - net.opengis.gml.v_3_1_1.ObjectFactory.class, - net.opengis.wms.v_1_3_0.ObjectFactory.class }); - jaxbManager.setPrefixMap(NS_MAP); - ApplicationContext ctx = EDEXUtil.getSpringContext(); - String[] beans = ctx.getBeanNamesForType(WcsDataFormatter.class); - for (String bean : beans) { - WcsDataFormatter df = (WcsDataFormatter) ctx.getBean(bean); - formatMap.put(df.getIdentifier(), df); - } - List formats = new ArrayList(formatMap.keySet()); - this.descCoverage = new DescCoverageBuilder(formats); - this.capbuilder = new CapabilitiesBuilder(formats); - } - - @Override - public OgcResponse describeCoverageType( - OgcServiceInfo serviceinfo, DescCoverageRequest request) { - CoverageDescriptions rval = new CoverageDescriptions(); - String[] ids = request.getIdentifiers(); - List descs = null; - if (ids == null) { - return getError(new WcsException(Code.MissingParameterValue), - request.getExceptionFormat()); - } - descs = new ArrayList(ids.length); - for (String id : ids) { - try { - descs.add(descCov(id)); - } catch (WcsException e) { - return getError(e, request.getExceptionFormat()); - } - } - rval.setCoverageDescription(descs); - return marshalResponse(rval); - } - - protected CoverageDescriptionType descCov(String id) throws WcsException { - WcsSource source = reg.getSource(id); - if (source == null) { - throw new WcsException(Code.LayerNotDefined); - } - CoverageDescription cd = source.describeCoverage(id); - return descCoverage.getCoverageDescriptionType(cd); - } - - @Override - public OgcResponse getCapabilities(OgcServiceInfo serviceinfo, - GetCapRequest request) { - Capabilities capabilities = capbuilder.getCapabilities(serviceinfo, - reg.getCoverages()); - return marshalResponse(capabilities); - } - - @Override - public void getCoverage(OgcServiceInfo serviceinfo, - GetCoverageRequest request, HttpServletResponse httpResp) { - try { - String format = request.getFormat(); - WcsDataFormatter formatter = formatMap.get(format); - if (formatter == null) { - throw new WcsException(Code.InvalidFormat); - } - String id = request.getIdentifier(); - WcsSource source = reg.getSource(id); - if (source == null) { - throw new WcsException(Code.LayerNotDefined); - } - OgcBoundingBox bbox = request.getBbox(); - CoordinateReferenceSystem crs = getCrs(bbox); - Envelope env = getEnvelope(bbox); - Coverage coverage = source.getCoverage(id, - request.getTimeSequence(), crs, env, request.getFields()); - CoveragesType coveragesType = getCoverageOgcResponse(serviceinfo, - id); - - try { - OutputStream out = httpResp.getOutputStream(); - if (request.isDefacto()) { - httpResp.setContentType(formatter.getIdentifier()); - formatter.format(coverage, out, false); - out.flush(); - out.close(); - return; - } - long timestamp = System.currentTimeMillis(); - String part = "_Part_" + timestamp; - httpResp.setContentType("multipart/related;boundary=" + part); - - PrintStream stream = new PrintStream(out); - String cid = getCoverageId(id); - - stream.println("--" + part); - stream.println("Content-Type: text/xml"); - stream.println("Content-ID: "); - stream.println(); - stream.println(jaxbManager.marshal(wcsFactory - .createCoverages(coveragesType))); - stream.println("--" + part); - stream.println("Content-Type: " + formatter.getIdentifier()); - if (base64) { - stream.println("Content-Transfer-Encoding: base64"); - } - stream.println("Content-ID: <" + cid + ">"); - stream.println(); - stream.flush(); - formatter.format(coverage, out, base64); - out.flush(); - out.close(); - } catch (Exception e) { - log.error("Problem formatting coverage", e); - throw new WcsException(Code.InternalServerError); - } - } catch (WcsException e) { - sendTextResponse(httpResp, - getError(e, request.getExceptionFormat())); - } - } - - protected void sendTextResponse(HttpServletResponse httpRes, - OgcResponse response) { - String mimetype = response.getMimetype(); - httpRes.setContentType(mimetype); - try { - PrintWriter writer = httpRes.getWriter(); - writer.write(response.getBody().toString()); - writer.close(); - } catch (IOException e) { - log.error("Problem sending response", e); - } - } - - /** - * @param bbox - * @return - * @throws WcsException - */ - protected Envelope getEnvelope(OgcBoundingBox bbox) throws WcsException { - if (bbox == null) { - throw new WcsException(Code.MissingParameterValue, - "Missing bounding box"); - } - return new Envelope(bbox.getMinx(), bbox.getMaxx(), bbox.getMiny(), - bbox.getMaxy()); - } - - /** - * @param bbox - * @return - * @throws WcsException - */ - protected CoordinateReferenceSystem getCrs(OgcBoundingBox bbox) - throws WcsException { - if (bbox != null) { - try { - return CrsLookup.lookup(bbox.getCrs()); - } catch (Exception e) { - log.error("Unable to decode crs: " + bbox.getCrs(), e); - } - } - throw new WcsException(Code.MissingParameterValue, - "Missing bounding box."); - } - - protected String getCoverageId(String identifier) { - return COVERAGE_ID + identifier; - } - - protected CoveragesType getCoverageOgcResponse( - OgcServiceInfo serviceinfo, String identifier) { - - CoveragesType coverages = new CoveragesType(); - List coverageList = new ArrayList(); - ReferenceGroupType rgt = new ReferenceGroupType(); - - // Abstract - // rgt.setAbstract(WcsJaxbUtils.getAsLangString("Abstract for " - // + request.getIdentifier())); - // Title - // rgt.setTitle(WcsJaxbUtils.getAsLangString(request.getIdentifier())); - - // Identifier - CodeType ident = new CodeType(); - ident.setValue(identifier); - rgt.setIdentifier(ident); - - // Data reference - String cid = getCoverageId(identifier); - ReferenceType rt = new ReferenceType(); - rt.setHref(cid); - - List> refTypeList = new ArrayList>(); - refTypeList.add(owsFactory.createReference(rt)); - rgt.setAbstractReferenceBase(refTypeList); - coverageList.add(rgt); - coverages.setCoverage(coverageList); - - return coverages; - - } - - @Override - public OgcResponse getError(WcsException e, String exceptionFormat) { - - net.opengis.ows.v_1_1_0.ExceptionType et = new ExceptionType(); - et.setExceptionCode(e.getCode().toString()); - et.setExceptionText(getAsList(e.getMessage())); - net.opengis.ows.v_1_1_0.ExceptionReport report = new ExceptionReport(); - report.setException(getAsList(et)); - String rval = ""; - String mimeType = OgcResponse.TEXT_XML_MIME; - if (exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_XML_MIME)) { - try { - rval = jaxbManager.marshal(report); - mimeType = OgcResponse.TEXT_XML_MIME; - } catch (JAXBException e1) { - log.error("Unable to marshal WCS response", e1); - rval = ""; - rval += ""; - rval += "" + e.getMessage() - + ""; - rval += ""; - mimeType = OgcResponse.TEXT_XML_MIME; - } - } else if (exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_HTML_MIME)) { - rval = ""; - rval += "
An error occurred performing the request:
"; - rval += "
Error Code: " + e.getCode().toString(); - rval += "
Message: " + e.getMessage() + ""; - mimeType = OgcResponse.TEXT_HTML_MIME; - } - - OgcResponse resp = new OgcResponse(rval, mimeType, TYPE.TEXT); - switch (e.getCode()) { - case InternalServerError: - resp.setError(ErrorType.INT_ERR); - break; - case OperationNotSupported: - resp.setError(ErrorType.NOT_IMPLEMENTED); - break; - default: - resp.setError(ErrorType.BAD_REQ); - } - return resp; - } - - protected net.opengis.wms.v_1_3_0.Exception getExceptionInfo() { - net.opengis.wms.v_1_3_0.Exception rval = new net.opengis.wms.v_1_3_0.Exception(); - rval.setFormat(getAsList("XML")); - return rval; - } - - @Override - public WcsRequest getRequest(InputStream in) { - Object obj; - WcsRequest rval; - try { - String xml = getXml(in); - obj = jaxbManager.unmarshal(xml); - rval = getType(obj); - } catch (Throwable e) { - log.error("Unable to decode request", e); - rval = new WcsRequest(Type.ERROR); - } - if (rval.getType().equals(Type.ERROR)) { - OgcResponse error = getError(new WcsException(Code.InvalidRequest, - "Unable to decode request"), OgcResponse.TEXT_XML_MIME); - rval.setRequest(error); - } - return rval; - } - - public List getAsList(T... args) { - List rval = new LinkedList(); - for (T t : args) { - rval.add(t); - } - return rval; - } - - protected WcsRequest getType(Object obj) { - WcsRequest rval; - if (obj instanceof GetCapabilitiesType) { - rval = new GetCapRequest(); - } else if (obj instanceof GetCoverage) { - rval = unwrap((GetCoverage) obj); - } else if (obj instanceof DescribeCoverage) { - DescribeCoverage req = (DescribeCoverage) obj; - List ids = req.getIdentifier(); - DescCoverageRequest dcr = new DescCoverageRequest(); - dcr.setIdentifiers(ids.toArray(new String[ids.size()])); - rval = dcr; - } else { - rval = new WcsRequest(Type.ERROR); - } - return rval; - } - - /** - * @param obj - * @return - */ - protected WcsRequest unwrap(GetCoverage req) { - GetCoverageRequest rval = new GetCoverageRequest(); - DomainSubsetType ds = req.getDomainSubset(); - rval.setTimeSequence(getTime(ds.getTemporalSubset())); - BoundingBoxType bbox = (BoundingBoxType) ds.getBoundingBox().getValue(); - rval.setBbox(transform(bbox)); - rval.setIdentifier(req.getIdentifier().getValue()); - OutputType output = req.getOutput(); - rval.setFormat(output.getFormat()); - GridCrsType gridCRS = output.getGridCRS(); - if (gridCRS != null) { - rval.setGridBaseCrs(gridCRS.getGridBaseCRS()); - rval.setGridOffsets(gridCRS.getGridOffsets()); - rval.setGridOrigin(gridCRS.getGridOrigin()); - rval.setGridType(gridCRS.getGridType()); - } - rval.setFields(transform(req.getRangeSubset())); - return rval; - } - - protected List transform(RangeSubsetType subset) { - if (subset == null) { - return null; - } - List fields = subset.getFieldSubset(); - if (fields == null || fields.isEmpty()) { - return null; - } - List rval = new ArrayList(fields.size()); - for (FieldSubset fs : fields) { - rval.add(transform(fs)); - } - return rval; - } - - protected RangeField transform(FieldSubset fs) { - String id = fs.getIdentifier().getValue(); - - RangeField rval = new RangeField(id, null); - String interp = fs.getInterpolationType(); - if (interp != null) { - rval.setDefaultInterpolation(InterpolationType.valueOf(interp)); - } - rval.setAxis(transform(fs.getAxisSubset())); - return rval; - } - - /** - * @param axisSubset - * @return - */ - protected List transform(List axisSubset) { - if (axisSubset == null || axisSubset.isEmpty()) { - return null; - } - List rval = new ArrayList(axisSubset.size()); - for (AxisSubset as : axisSubset) { - Set keys = new HashSet(as.getKey()); - rval.add(new RangeAxis(as.getIdentifier(), keys)); - } - return rval; - } - - protected OgcBoundingBox transform(BoundingBoxType bbox) { - OgcBoundingBox rval = new OgcBoundingBox(); - rval.setCrs(bbox.getCrs()); - List lower = bbox.getLowerCorner(); - List upper = bbox.getUpperCorner(); - rval.setMaxx(upper.get(0)); - rval.setMaxy(upper.get(1)); - rval.setMinx(lower.get(0)); - rval.setMiny(lower.get(1)); - return rval; - } - - protected DataTime getTime(TimeSequenceType tst) { - if (tst == null) { - return null; - } - List times = tst.getTimePositionOrTimePeriod(); - if (times == null || times.isEmpty()) { - return null; - } - if (times.size() != 1) { - log.warn("multiple times not supported in request, taking first"); - } - Object timeObj = times.get(0); - return parseTime(timeObj); - } - - protected DataTime parseTime(Object timeObj) { - if (timeObj instanceof TimePositionType) { - TimePositionType pos = (TimePositionType) timeObj; - return new DataTime(getTime(pos)); - } else { - TimePeriodType period = (TimePeriodType) timeObj; - Date start = getTime(period.getBeginPosition()); - Date end = getTime(period.getEndPosition()); - TimeRange range = new TimeRange(start, end); - DataTime rval = new DataTime(start); - rval.setValidPeriod(range); - return rval; - } - } - - protected Date getTime(TimePositionType pos) { - List values = pos.getValue(); - if (values == null || values.isEmpty()) { - log.error("unable to parse time"); - return null; - } - return DatatypeConverter.parseDateTime(values.get(0)).getTime(); - } - - protected String getXml(InputStream in) throws IOException { - - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - String rval = ""; - String line = ""; - while ((line = reader.readLine()) != null) { - rval += line + "\n"; - } - return rval; - } - - protected OgcResponse marshalResponse(Object jaxbobject) { - OgcResponse rval; - try { - String xml = jaxbManager.marshal(jaxbobject); - rval = new OgcResponse(xml, "text/xml", TYPE.TEXT); - } catch (JAXBException e) { - log.error("Unable to marshal WCS response", e); - // TODO: real error code - rval = getError(new WcsException(Code.OperationNotSupported), - OgcResponse.TEXT_XML_MIME); - } - return rval; - } - - public boolean isBase64() { - return base64; - } - - public void setBase64(boolean base64) { - this.base64 = base64; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/OperationsDescriber.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/OperationsDescriber.java deleted file mode 100644 index 68d9c26e7f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/OperationsDescriber.java +++ /dev/null @@ -1,186 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.provider; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import javax.xml.bind.JAXBElement; - -import net.opengis.ows.v_1_1_0.AllowedValues; -import net.opengis.ows.v_1_1_0.DCP; -import net.opengis.ows.v_1_1_0.DomainType; -import net.opengis.ows.v_1_1_0.HTTP; -import net.opengis.ows.v_1_1_0.ObjectFactory; -import net.opengis.ows.v_1_1_0.Operation; -import net.opengis.ows.v_1_1_0.OperationsMetadata; -import net.opengis.ows.v_1_1_0.RequestMethodType; - -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wcs.provider.OgcWcsProvider.WcsOpType; - -/** - * - * @author bclement - * @version 1.0 - */ -public class OperationsDescriber { - - protected ObjectFactory owsFactory = new ObjectFactory(); - - public OperationsMetadata getOpData(OgcServiceInfo serviceinfo) { - OperationsMetadata rval = new OperationsMetadata(); - List operations = new LinkedList(); - for (OgcOperationInfo op : serviceinfo.getOperations()) { - Operation to = new Operation(); - to.setName(op.getType().toString()); - to.setDCP(getDcpList(op)); - to.setParameter(getOpParams(op)); - operations.add(to); - } - rval.setOperation(operations); - rval.setParameter(getParams(serviceinfo)); - return rval; - } - - protected List getParams(OgcServiceInfo serviceinfo) { - List rval = new LinkedList(); - // TODO: this info should be passed in from somewhere - DomainType parameter = new DomainType(); - parameter.setName("srsName"); - List value = new LinkedList(); - value.add("EPSG:4326"); - rval.add(parameter); - return rval; - } - - protected List getDcpList(OgcOperationInfo op) { - List rval = new LinkedList(); - DCP dcp = new DCP(); - HTTP http = new HTTP(); - List> value = new LinkedList>(); - if (op.hasHttpGet()) { - RequestMethodType req = getRequestType(op.getHttpGetRes()); - value.add(owsFactory.createHTTPPost(req)); - } - if (op.hasHttpPost()) { - RequestMethodType req = getRequestType(op.getHttpPostRes()); - value.add(owsFactory.createHTTPPost(req)); - } - http.setGetOrPost(value); - dcp.setHTTP(http); - rval.add(dcp); - return rval; - } - - protected RequestMethodType getRequestType(String value) { - RequestMethodType rval = owsFactory.createRequestMethodType(); - rval.setHref(value); - return rval; - } - - private List getOpParams(OgcOperationInfo op) { - - List opParamList = new ArrayList(); - - switch (op.getType()) { - case GetCapabilities: - opParamList = Arrays.asList( - getAsDomainType("AcceptVersions", op.getVersions()), - getAsDomainType("AcceptFormats", op.getFormats()), - getAsDomainType("service", op.getServices())); - break; - case DescribeCoverage: - opParamList = Arrays.asList( - getAsDomainType("AcceptVersions", op.getVersions()), - getAsDomainType("AcceptFormats", op.getFormats()), - getAsDomainType("service", op.getServices()));// , - // getAsDomainType("Identifier", getLayerIdentifierList())); - break; - case GetCoverage: - opParamList = Arrays - .asList(getAsDomainType("AcceptVersions", op.getVersions()), - getAsDomainType("AcceptFormats", op.getFormats()), - getAsDomainType("service", op.getServices()), - // getAsDomainType("Identifier", - // getLayerIdentifierList()), - getAsDomainType("InterpolationType", - getInterpolationType()), - getAsDomainType("format", getFormat())); - break; - default: - - } - - return opParamList; - } - - protected List getInterpolationType() { - List interpolationType = new ArrayList(); - - interpolationType.add("nearest"); - interpolationType.add("linear"); - - return interpolationType; - } - - protected List getFormat() { - List format = new ArrayList(); - - format.add("IDataRecord"); - // format.add("image/tiff"); - // format.add("image/jpeg"); - // format.add("image/netcdf"); - - return format; - } - - protected DomainType getAsDomainType(String name, Collection values) { - DomainType rval = new DomainType(); - rval.setName(name); - - AllowedValues avs = new AllowedValues(); - - List toVals = new LinkedList(); - for (String val : values) { - toVals.add(val); - } - - avs.setValueOrRange(toVals); - rval.setAllowedValues(avs); - - return rval; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/WcsJaxbUtils.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/WcsJaxbUtils.java deleted file mode 100644 index 2300c0b4df..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/provider/WcsJaxbUtils.java +++ /dev/null @@ -1,73 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.provider; - -import java.util.ArrayList; -import java.util.List; - -import net.opengis.ows.v_1_1_0.KeywordsType; -import net.opengis.ows.v_1_1_0.LanguageStringType; - -/** - * - * @author bclement - * @version 1.0 - */ -public class WcsJaxbUtils { - - protected static final String DEFAULT_LANGUAGE = "english"; - - public static List getAsLangString(String... strs) { - if (strs == null) { - return null; - } - List rval = new ArrayList( - strs.length); - for (String str : strs) { - LanguageStringType lst = new LanguageStringType(); - lst.setLang(DEFAULT_LANGUAGE); - lst.setValue(str); - } - return rval; - } - - public static List getKeywords(List strs) { - if (strs == null) { - return null; - } - List rval = new ArrayList(strs.size()); - for (String str : strs) { - KeywordsType kwt = new KeywordsType(); - kwt.setKeyword(getAsLangString(str)); - } - return rval; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/Coverage.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/Coverage.java deleted file mode 100644 index 4f0fc81d71..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/Coverage.java +++ /dev/null @@ -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 - * ------------ ---------- ----------- -------------------------- - * May 5, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import org.geotools.coverage.grid.GridGeometry2D; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.common.datastorage.records.IDataRecord; -import com.vividsolutions.jts.geom.Envelope; - -/** - * - * @author bclement - * @version 1.0 - */ -public class Coverage { - - protected IDataRecord dataRecord; - private CoordinateReferenceSystem crs; - private Envelope envelope; - private String time; - private GridGeometry2D gridGeometry; - - /** - * @return the crs - */ - public CoordinateReferenceSystem getCrs() { - return crs; - } - - /** - * @return the envelope - */ - public Envelope getEnvelope() { - return envelope; - } - - /** - * @return the dataRecord - */ - public IDataRecord getDataRecord() { - return dataRecord; - } - - /** - * @param dataRecord - * the dataRecord to set - */ - public void setDataRecord(IDataRecord dataRecord) { - this.dataRecord = dataRecord; - } - - /** - * @param envelope - */ - public void setEnvelope(Envelope env) { - this.envelope = env; - } - - /** - * @param crs - */ - public void setCrs(CoordinateReferenceSystem crs) { - this.crs = crs; - } - - /** - * @param timeString - */ - public void setTime(String timeString) { - this.time = timeString; - } - - /** - * @return the time - */ - public String getTime() { - return time; - } - - /** - * @param gridGeometry the gridGeometry to set - */ - public void setGridGeometry(GridGeometry2D gridGeometry) { - this.gridGeometry = gridGeometry; - } - - /** - * @return the gridGeometry - */ - public GridGeometry2D getGridGeometry() { - return gridGeometry; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/CoverageDescription.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/CoverageDescription.java deleted file mode 100644 index 46d23f91b5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/CoverageDescription.java +++ /dev/null @@ -1,197 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import java.util.List; - -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.ogc.common.OgcBoundingBox; -import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox; -import com.vividsolutions.jts.geom.Polygon; - -/** - * - * @author bclement - * @version 1.0 - */ -public class CoverageDescription { - - protected String identifier; - - protected String title; - - protected String abstractStr; - - protected List crs; - - protected List keywords; - - protected List times; - - protected List bboxes; - - protected List rangeFields; - - protected OgcGeoBoundingBox crs84Bbox; - - protected Polygon polygon; - - protected List gridOffsets; - - protected String gridBaseCrs; - - protected String gridType; - - protected String gridCs; - - protected List gridOrigin; - - public OgcGeoBoundingBox getCrs84Bbox() { - return crs84Bbox; - } - - public void setCrs84Bbox(OgcGeoBoundingBox crs84Bbox) { - this.crs84Bbox = crs84Bbox; - } - - public List getGridOrigin() { - return gridOrigin; - } - - public void setGridOrigin(List gridOrigin) { - this.gridOrigin = gridOrigin; - } - - public String getGridType() { - return gridType; - } - - public void setGridType(String gridType) { - this.gridType = gridType; - } - - public String getGridCs() { - return gridCs; - } - - public void setGridCs(String gridCs) { - this.gridCs = gridCs; - } - - public String getGridBaseCrs() { - return gridBaseCrs; - } - - public void setGridBaseCrs(String gridBaseCrs) { - this.gridBaseCrs = gridBaseCrs; - } - - public List getGridOffsets() { - return gridOffsets; - } - - public void setGridOffsets(List offsets) { - this.gridOffsets = offsets; - } - - public Polygon getPolygon() { - return polygon; - } - - public void setPolygon(Polygon polygon) { - this.polygon = polygon; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAbstractStr() { - return abstractStr; - } - - public void setAbstractStr(String abstractStr) { - this.abstractStr = abstractStr; - } - - public List getCrs() { - return crs; - } - - public void setCrs(List crs) { - this.crs = crs; - } - - public List getKeywords() { - return keywords; - } - - public void setKeywords(List keywords) { - this.keywords = keywords; - } - - public List getTimes() { - return times; - } - - public void setTimes(List times) { - this.times = times; - } - - public List getBboxes() { - return bboxes; - } - - public void setBboxes(List bboxes) { - this.bboxes = bboxes; - } - - public List getRangeFields() { - return rangeFields; - } - - public void setRangeFields(List rangeFields) { - this.rangeFields = rangeFields; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/CoverageTransform.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/CoverageTransform.java deleted file mode 100644 index 7d63c2f716..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/CoverageTransform.java +++ /dev/null @@ -1,170 +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 10, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; -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.OgcGeoBoundingBox; -import com.raytheon.uf.edex.ogc.common.db.LayerTransformer; -import com.raytheon.uf.edex.ogc.common.db.SimpleLayer; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.LinearRing; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class CoverageTransform { - - protected Log log = LogFactory.getLog(this.getClass()); - - protected String key; - - public CoverageTransform(String key) { - this.key = key; - } - - public List transform( - List layers, boolean summaryOnly) { - if (layers == null) { - return null; - } - List rval = new ArrayList( - layers.size()); - for (SimpleLayer layer : layers) { - rval.add(transform(layer, summaryOnly)); - } - return rval; - } - - public CoverageDescription transform(SimpleLayer layer, boolean summaryOnly) { - CoverageDescription rval = new CoverageDescription(); - rval.setIdentifier(layer.getName()); - OgcGeoBoundingBox bbox = LayerTransformer.getGeoBoundingBox(layer); - if (bbox != null) { - rval.setCrs84Bbox(bbox); - } else { - log.warn("Unable to get geographic information for layer: " - + layer.getName()); - } - if (!summaryOnly) { - describe(rval, layer); - } - return rval; - } - - - /** - * @param rval - * @param layer - */ - protected void describe(CoverageDescription rval, SimpleLayer layer) { - rval.setGridOffsets(Arrays.asList((double) layer.getNx(), - (double) layer.getNy())); - String targetCrs = translateCrs(layer.getTargetCrsCode()); - rval.setGridBaseCrs(targetCrs); - rval.setCrs(Arrays.asList(targetCrs)); - double minx = layer.getTargetMinx(); - double miny = layer.getTargetMiny(); - double maxx = layer.getTargetMaxx(); - double maxy = layer.getTargetMaxy(); - GeometryFactory geomFact = new GeometryFactory(); - Coordinate[] coords = new Coordinate[5]; - coords[0] = new Coordinate(minx, miny); - coords[1] = new Coordinate(minx, maxy); - coords[2] = new Coordinate(maxx, maxy); - coords[3] = new Coordinate(maxx, miny); - coords[4] = new Coordinate(minx, miny); - LinearRing ring = geomFact.createLinearRing(coords); - rval.setTimes(getTimes(layer.getTimes())); - rval.setRangeFields(getRangeFields(layer)); - rval.setPolygon(geomFact.createPolygon(ring, new LinearRing[0])); - rval.setGridType("urn:ogc:def:method:WCS:1.1:grid2dIn2dMethod"); - rval.setGridOrigin(Arrays.asList(minx, maxy)); - int nx = layer.getNx(); - int ny = layer.getNy(); - rval.setGridOffsets(Arrays.asList(getDn(nx, minx, maxx), 0.0, 0.0, - -getDn(ny, miny, maxy))); - rval.setGridCs("urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS"); - } - - protected double getDn(int nn, double n1, double n2) { - return Math.abs(n1 - n2) / (double) nn; - } - - public static String translateCrs(String crs) { - if ( crs == null){ - return null; - } - if (crs.equalsIgnoreCase("crs:84")) { - return "urn:ogc:def:crs:OGC::CRS84"; - } - String[] split = crs.split(":"); - List parts = new ArrayList(split.length + 1); - parts.add("urn:ogc:def:crs"); - if (split.length == 2) { - parts.add(split[0]); - parts.add(""); - parts.add(split[1]); - } else { - parts.addAll(Arrays.asList(split)); - } - return StringUtils.join(parts, ":"); - } - - /** - * @param layer - * @return - */ - protected abstract List getRangeFields(SimpleLayer layer); - - protected List getTimes(Set times) { - if (times == null) { - return null; - } - List rval = new ArrayList(times.size()); - for (Date d : times) { - rval.add(new DataTime(d)); - } - return rval; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/DefaultWcsSource.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/DefaultWcsSource.java deleted file mode 100644 index 28b61e746f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/DefaultWcsSource.java +++ /dev/null @@ -1,823 +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 30, 2011 jelkins Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import java.lang.Thread.State; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.geotools.coverage.grid.GeneralGridEnvelope; -import org.geotools.coverage.grid.GridGeometry2D; -import org.geotools.geometry.DirectPosition2D; -import org.geotools.geometry.GeneralEnvelope; -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.crs.CoordinateReferenceSystem; -import org.opengis.referencing.operation.MathTransform; -import org.opengis.referencing.operation.MathTransform2D; -import org.opengis.referencing.operation.TransformException; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.PluginException; -import com.raytheon.uf.common.dataplugin.PluginProperties; -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.LongDataRecord; -import com.raytheon.uf.common.datastorage.records.ShortDataRecord; -import com.raytheon.uf.common.datastorage.records.StringDataRecord; -import com.raytheon.uf.common.spatial.reprojection.ReferencedDataRecord; -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.database.DataAccessLayerException; -import com.raytheon.uf.edex.database.plugin.PluginDao; -import com.raytheon.uf.edex.database.plugin.PluginFactory; -import com.raytheon.uf.edex.ogc.common.db.LayerTransformer; -import com.raytheon.uf.edex.ogc.common.db.SimpleLayer; -import com.raytheon.uf.edex.ogc.common.spatial.RecordUtil; -import com.raytheon.uf.edex.wcs.WcsException; -import com.raytheon.uf.edex.wcs.WcsException.Code; -import com.vividsolutions.jts.geom.Envelope; - -/** - * Default WcsSource - * - * @author jelkins - * @version 1.0 - */ -public abstract class DefaultWcsSource implements WcsSource { - - protected LayerTransformer transformer; - private PluginDao _dao; - protected PluginProperties props; - protected Log log = LogFactory.getLog(this.getClass()); - protected Set idCache = new HashSet(); - protected Thread idUpdateThread; - - abstract protected CoverageTransform getCoverageTransform(); - - /** - * - */ - public DefaultWcsSource(PluginProperties props, LayerTransformer transformer) { - this.props = props; - this.transformer = transformer; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.reg.WcsSource#listCoverages() - */ - @Override - public List listCoverages() { - return getCoverageList(false); - } - - /** - * @param wait - * @return - */ - protected List getCoverageList(boolean wait) { - List coverageList = null; - try { - coverageList = getCoverageTransform().transform( - transformer.getLayers(), true); - } catch (Exception e) { - log.error("Unable to get plugin dao", e); - return new ArrayList(0); - - } - updateIdCache(coverageList, wait); - return coverageList; - } - - protected PluginDao getDao() throws PluginException { - if (_dao == null) { - _dao = PluginFactory.getInstance().getPluginDao( - props.getPluginName()); - } - return _dao; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wcs.reg.WcsSource#describeCoverage(java.lang.String) - */ - @Override - public CoverageDescription describeCoverage(String identifier) - throws WcsException { - CoverageDescription rval; - try { - SimpleLayer layer = transformer.find(identifier); - if (layer == null) { - throw new WcsException(Code.LayerNotDefined); - } - rval = getCoverageTransform().transform(layer, false); - } catch (DataAccessLayerException e) { - log.error("Problem accessing layers", e); - throw new WcsException(Code.InternalServerError, e); - } catch (Exception e) { - log.error("Unable to get plugin dao", e); - throw new WcsException(Code.InternalServerError); - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.reg.WcsSource#getCoverage(java.lang.String, - * com.raytheon.uf.common.time.DataTime, - * org.opengis.referencing.crs.CoordinateReferenceSystem, - * com.vividsolutions.jts.geom.Envelope) - */ - @Override - public Coverage getCoverage(String identifier, DataTime time, - CoordinateReferenceSystem crs, Envelope bbox, - List rangeFields) throws WcsException { - PluginDataObject record = getRecord(identifier, time, rangeFields); - time = record.getDataTime(); - ReferencedDataRecord dataRecord = getDataRecord(record, crs, bbox); - if (dataRecord == null) { - return null; - } - Coverage c = new Coverage(); - c.setDataRecord(dataRecord.getRecord()); - c.setEnvelope(dataRecord.getEnvelope()); - c.setCrs(crs); - String timeString = LayerTransformer.format(time.getRefTime()); - c.setTime(timeString); - GridGeometry2D gridGeom = getGridGeometry(dataRecord.getRecord(), - dataRecord.getEnvelope()); - c.setGridGeometry(gridGeom); - return c; - } - - /** - * @param identifier - * @return - */ - protected Date getDefaultTime(String identifier) throws WcsException { - try { - SimpleLayer layer = transformer.find(identifier); - return layer.getDefaultTime(); - } catch (DataAccessLayerException e) { - log.error("Problem accessing layers", e); - throw new WcsException(Code.InternalServerError, e); - } catch (Exception e) { - log.error("Unable to get plugin dao", e); - throw new WcsException(Code.InternalServerError); - } - } - - /** - * @param record - * @param crs - * @param bbox - * @return - * @throws WcsException - */ - protected ReferencedDataRecord getDataRecord(PluginDataObject record, - CoordinateReferenceSystem crs, Envelope bbox) throws WcsException { - try { - // get the projected slice from the DAO - ReferencedDataRecord projectedRecord = RecordUtil.getProjected( - getDao(), record, crs, bbox); - - ReferencedDataRecord rval; - if (projectedRecord != null) { - rval = projectedRecord; - } else { - rval = null; - } - - // check if we need to pad ( possibly have no data and need to - // create all "null" response - if (projectedRecord == null) { - // Need all "null" response - Object padValue = getNullPadValue(); - // Make an empty record with the proper data type - IDataRecord emptyRecord = makeEmptyRecord(padValue, "Data-" - + crs.getName().toString(), record.getDataURI()); - // make an envelope for the empty record ( covers no area ) - ReferencedEnvelope emptyEnvelope = new ReferencedEnvelope(0, 0, - 0, 0, crs); - - projectedRecord = new ReferencedDataRecord(emptyRecord, - emptyEnvelope); - - GridGeometry2D dataGridGeom = getGridGeometry(emptyRecord, - emptyEnvelope); - - // send through padder to get all nulls - ReferencedDataRecord resultingRecord = padData(projectedRecord, - dataGridGeom, bbox); - rval = resultingRecord; - - } else if (projectedRecord.getEnvelope().equals(bbox) - || projectedRecord.getEnvelope().contains(bbox)) { - // All is well - } else { - // need to resize (grow only) and pad with nulls - GridGeometry2D dataGridGeom = getGridGeometry( - projectedRecord.getRecord(), - projectedRecord.getEnvelope()); - ReferencedDataRecord resultingRecord = padData(projectedRecord, - dataGridGeom, bbox); - rval = resultingRecord; - - } - - return rval; - } catch (Exception e) { - log.error("Unable to get reprojected data for record: " + record, e); - throw new WcsException(Code.InternalServerError); - } - } - - /** - * @param padValue - * @return - */ - private IDataRecord makeEmptyRecord(Object padValue, String name, - String group) throws WcsException { - - if (padValue instanceof byte[] || padValue instanceof Byte) { - byte[] data = new byte[] {}; - ByteDataRecord record = new ByteDataRecord(name, group, data, 2, - new long[] { 0, 0 }); - return record; - } else if (padValue instanceof float[] || padValue instanceof Float) { - float[] data = new float[] {}; - FloatDataRecord record = new FloatDataRecord(name, group, data, 2, - new long[] { 0, 0 }); - return record; - } else if (padValue instanceof short[] || padValue instanceof Short) { - short[] data = new short[] {}; - ShortDataRecord record = new ShortDataRecord(name, group, data, 2, - new long[] { 0, 0 }); - return record; - } else if (padValue instanceof int[] || padValue instanceof Integer) { - int[] data = new int[] {}; - IntegerDataRecord record = new IntegerDataRecord(name, group, data, - 2, new long[] { 0, 0 }); - return record; - } else if (padValue instanceof long[] || padValue instanceof Long) { - long[] data = new long[] {}; - LongDataRecord record = new LongDataRecord(name, group, data, 2, - new long[] { 0, 0 }); - return record; - } else if (padValue instanceof String[] || padValue instanceof String) { - String[] data = new String[] {}; - StringDataRecord record = new StringDataRecord(name, group, data, - 2, new long[] { 0, 0 }); - return record; - } else { - log.error("bad type when making record, " - + padValue.getClass().toString(), new Exception()); - throw new WcsException(Code.InternalServerError); - } - } - - /** - * @param projectedRecord - * @return - */ - private ReferencedDataRecord padData( - ReferencedDataRecord projectedRecord, GridGeometry2D gridGeom, - Envelope targetEnv) throws WcsException { - if (projectedRecord.getEnvelope().contains(targetEnv)) { - // no need to pad - return projectedRecord; - } else if (projectedRecord.getEnvelope().intersects(targetEnv)) { - // there is some padding - try { - int[][] dataRange = getContainingGridPoints( - gridGeom.getCRSToGrid2D(PixelOrientation.UPPER_LEFT), - projectedRecord.getEnvelope()); - int[][] targetRange = getContainingGridPoints( - gridGeom.getCRSToGrid2D(PixelOrientation.UPPER_LEFT), - targetEnv); - - int[][] padRange = calculatePadRange(dataRange, targetRange); - - int[] dataSize = new int[2]; - - dataSize[0] = (int) projectedRecord.getRecord().getSizes()[0]; - dataSize[1] = (int) projectedRecord.getRecord().getSizes()[1]; - - IDataRecord paddedDataRecord = padDataInternal( - projectedRecord.getRecord(), dataSize, padRange); - - // make an adjusted grid geometry to account for padding - // shift old grid corners by minimum pad - GridGeometry2D adjustedGridGeom = getGridGeometry( - padRange[0][0], dataSize[0] + padRange[0][0] - 1, - padRange[0][1], dataSize[1] + padRange[0][1] - 1, - projectedRecord.getEnvelope()); - - ReferencedEnvelope finalEnvelope = makeReferencedEnvelope( - adjustedGridGeom, paddedDataRecord); - - ReferencedDataRecord record = new ReferencedDataRecord( - paddedDataRecord, finalEnvelope); - - return record; - - } catch (TransformException e) { - log.error("Transform Exception while padding partial record", e); - throw new WcsException(Code.InternalServerError); - } - - } else { - // need 100% nulls - try { - int[][] targetRange = getContainingGridPoints( - gridGeom.getCRSToGrid2D(), targetEnv); - int[] targetDims = new int[] { - Math.abs(targetRange[0][0]) - + Math.abs(targetRange[1][0]), - Math.abs(targetRange[0][1]) - + Math.abs(targetRange[1][1]) }; - int targetSize = targetDims[0] * targetDims[1]; - - IDataRecord record = projectedRecord.getRecord(); - Object sourceData = record.getDataObject(); - - Object targetArray = makeArrayTypeFromRecord(record, targetSize); - - fillArray(targetArray, getNullPadValueFromType(sourceData)); - - IDataRecord paddedDataRecord = makeDataRecordOfSameType(record, - targetArray, 2, new long[] { targetDims[0], - targetDims[1] }); - - ReferencedEnvelope finalEnvelope = makeReferencedEnvelope( - gridGeom, paddedDataRecord); - - ReferencedDataRecord referencedRecord = new ReferencedDataRecord( - paddedDataRecord, finalEnvelope); - - return referencedRecord; - - } catch (TransformException e) { - log.error("Transform Exception while making all null pads", e); - throw new WcsException(Code.InternalServerError); - } - } - } - - /** - * makes a geospatial referenced envelope - * - * @param gridGeom - * @param paddedDataRecord - * @return - */ - protected ReferencedEnvelope makeReferencedEnvelope( - GridGeometry2D gridGeom, IDataRecord dataRecord) - throws WcsException, TransformException { - MathTransform transform = gridGeom - .getGridToCRS(PixelOrientation.UPPER_LEFT); - - DirectPosition srcUpperLeft = new DirectPosition2D(0, 0); - DirectPosition srcLowerRight = new DirectPosition2D( - dataRecord.getSizes()[0], dataRecord.getSizes()[1]); - - try { - DirectPosition destUpperLeft = transform.transform(srcUpperLeft, - null); - DirectPosition destLowerRight = transform.transform(srcLowerRight, - null); - - ReferencedEnvelope rval = new ReferencedEnvelope( - destUpperLeft.getOrdinate(0), - destLowerRight.getOrdinate(0), - destLowerRight.getOrdinate(1), - destUpperLeft.getOrdinate(1), - gridGeom.getCoordinateReferenceSystem()); - - return rval; - } catch (MismatchedDimensionException e) { - log.error( - "error while transforming grid coordinates to referenced envelope", - e); - throw new WcsException(Code.InternalServerError); - } - } - - /** - * @param record - * @param dataSize - * @param padRange - * @return - * @throws WcsBadTypeException - */ - private IDataRecord padDataInternal(IDataRecord record, int[] dataSize, - int[][] padRange) throws WcsException { - - int[] newSize = new int[] { - dataSize[0] + padRange[0][0] + padRange[1][0], - dataSize[1] + padRange[0][1] + padRange[1][1] }; - int newTotalSize = newSize[0] * newSize[1]; - - int dataArraySize = dataSize[0] * dataSize[1]; - - Object sourceData = record.getDataObject(); - - Object targetArray = makeArrayTypeFromRecord(record, newTotalSize); - - fillArray(targetArray, getNullPadValueFromType(sourceData)); - - for (int srcIndex = 0; srcIndex < dataArraySize; ++srcIndex) { - - // get row and column index from data - int srcRow = srcIndex / dataSize[0]; - int srcColumn = srcIndex % dataSize[0]; - - // calculate new row and column - // add min y pad to source row to get destination row - int destRow = padRange[0][1] + srcRow; - // add min x pad to source column for destination column - int destColumn = padRange[0][0] + srcColumn; - - int targetIndex = (destRow * newSize[0]) + destColumn; - - copyValue(sourceData, srcIndex, targetArray, targetIndex); - } - - IDataRecord rval = makeDataRecordOfSameType(record, targetArray, 2, - new long[] { newSize[0], newSize[1] }); - - return rval; - } - - private IDataRecord makeDataRecordOfSameType(IDataRecord record, - Object newDataArray, int dims, long[] sizes) - throws WcsException { - IDataRecord rval = null; - - if (record instanceof ByteDataRecord) { - rval = new ByteDataRecord(record.getName(), record.getGroup(), - (byte[]) newDataArray, dims, sizes); - } else if (record instanceof FloatDataRecord) { - rval = new FloatDataRecord(record.getName(), record.getGroup(), - (float[]) newDataArray, dims, sizes); - } else if (record instanceof IntegerDataRecord) { - rval = new IntegerDataRecord(record.getName(), record.getGroup(), - (int[]) newDataArray, dims, sizes); - } else if (record instanceof LongDataRecord) { - rval = new LongDataRecord(record.getName(), record.getGroup(), - (long[]) newDataArray, dims, sizes); - } else if (record instanceof ShortDataRecord) { - rval = new ShortDataRecord(record.getName(), record.getGroup(), - (short[]) newDataArray, dims, sizes); - } else if (record instanceof StringDataRecord) { - rval = new StringDataRecord(record.getName(), record.getGroup(), - (String[]) newDataArray, dims, sizes); - } else { - log.error("Unknown IDataRecord type. type: " - + record.getClass().toString(), new Exception()); - throw new WcsException(Code.InternalServerError); - } - - return rval; - } - - private Object makeArrayTypeFromRecord(IDataRecord record, int size) - throws WcsException { - Object targetArray = null; - - - if (record instanceof ByteDataRecord) { - targetArray = new byte[size]; - } else if (record instanceof FloatDataRecord) { - targetArray = new float[size]; - } else if (record instanceof IntegerDataRecord) { - targetArray = new int[size]; - } else if (record instanceof LongDataRecord) { - targetArray = new long[size]; - } else if (record instanceof ShortDataRecord) { - targetArray = new short[size]; - } else if (record instanceof StringDataRecord) { - targetArray = new String[size]; - } else { - log.error("Unknown IDataRecord type when making array. type: " - + record.getClass().toString(), new Exception()); - throw new WcsException(Code.InternalServerError); - } - - return targetArray; - } - - /** - * @param sourceData - * @param srcIndex - * @param targetArray - * @param targetIndex - */ - private void copyValue(Object sourceData, int srcIndex, Object targetArray, - int targetIndex) throws WcsException { - - if (sourceData instanceof byte[] && targetArray instanceof byte[]) { - ((byte[]) targetArray)[targetIndex] = ((byte[]) sourceData)[srcIndex]; - } else if (sourceData instanceof float[] - && targetArray instanceof float[]) { - ((float[]) targetArray)[targetIndex] = ((float[]) sourceData)[srcIndex]; - } else if (sourceData instanceof short[] - && targetArray instanceof short[]) { - ((short[]) targetArray)[targetIndex] = ((short[]) sourceData)[srcIndex]; - } else if (sourceData instanceof int[] && targetArray instanceof int[]) { - ((int[]) targetArray)[targetIndex] = ((int[]) sourceData)[srcIndex]; - } else if (sourceData instanceof long[] - && targetArray instanceof long[]) { - ((long[]) targetArray)[targetIndex] = ((long[]) sourceData)[srcIndex]; - } else if (sourceData instanceof String[] - && targetArray instanceof String[]) { - ((String[]) targetArray)[targetIndex] = ((String[]) sourceData)[srcIndex]; - } else { - log.error("bad type when making record, " - + sourceData.getClass().toString() + " and " - + targetArray.getClass().toString(), new Exception( - "bad type when making record")); - throw new WcsException(Code.InternalServerError); - } - - } - - /** - * @param targetArray - * @param nullPadValue - */ - private void fillArray(Object targetArray, Object nullPadValue) - throws WcsException { - - if (targetArray instanceof byte[]) { - Arrays.fill((byte[]) targetArray, ((Byte) nullPadValue).byteValue()); - } else if (targetArray instanceof float[]) { - Arrays.fill((float[]) targetArray, - ((Float) nullPadValue).floatValue()); - } else if (targetArray instanceof short[]) { - Arrays.fill((short[]) targetArray, - ((Short) nullPadValue).shortValue()); - } else if (targetArray instanceof int[]) { - Arrays.fill((int[]) targetArray, - ((Integer) nullPadValue).intValue()); - } else if (targetArray instanceof long[]) { - Arrays.fill((long[]) targetArray, ((Long) nullPadValue).longValue()); - } else if (targetArray instanceof String[]) { - Arrays.fill((String[]) targetArray, (String) nullPadValue); - } else { - log.error("Unknown array type when trying to fill array. type: " - + targetArray.getClass().toString(), new Exception()); - throw new WcsException(Code.InternalServerError); - } - - } - - protected abstract Object getNullPadValue(); - - /** - * @param targetArray - * @return - */ - protected Object getNullPadValueFromType(Object typeOrArray) - throws WcsException { - - if (typeOrArray instanceof byte[]) { - return new Byte((byte) 0); - } else if (typeOrArray instanceof float[]) { - return new Float(0.0f); - } else if (typeOrArray instanceof short[]) { - return new Short((short) 0); - } else if (typeOrArray instanceof int[]) { - return new Integer(0); - } else if (typeOrArray instanceof long[]) { - return new Long(0L); - } else if (typeOrArray instanceof String[]) { - return new String(); - } else { - log.error("Unknown type when getting default fill value. type: " - + typeOrArray.getClass().toString(), new Exception()); - throw new WcsException(Code.InternalServerError); - } - } - - /** - * @param dataRange - * @param targetRange - * @return - */ - private int[][] calculatePadRange(int[][] dataRange, int[][] targetRange) { - // for minimum we expect dataRange to be less than or equal to - // targetRange, if the difference is negative we need to pad - int minxDiff = targetRange[0][0] - dataRange[0][0]; - int minyDiff = targetRange[0][1] - dataRange[0][1]; - // for maximum we expect dataRange to be greater than or equal to - // targetRange, if the difference is positive we need to pad - // swap min/max order because grid and crs count y differently - int maxxDiff = targetRange[1][0] - dataRange[1][0]; - int maxyDiff = targetRange[1][1] - dataRange[1][1]; - - // only pad, do not trim. so we need to check if the dataRange was - // bigger - if (minxDiff > 0) { - minxDiff = 0; - } - if (minyDiff > 0) { - minyDiff = 0; - } - - if (maxxDiff < 0) { - maxxDiff = 0; - } - if (maxyDiff < 0) { - maxyDiff = 0; - } - - return new int[][] { { Math.abs(minxDiff), Math.abs(minyDiff) }, - { Math.abs(maxxDiff), Math.abs(maxyDiff) } }; - } - - protected int[][] getContainingGridPoints(MathTransform2D crsToGrid, - Envelope env) throws 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); - - // make sure to "grow" in the proper direction - - // x axis "direction" is the same in geo and grid - double minx = lowerGrid.getOrdinate(0); - double maxx = upperGrid.getOrdinate(0); - - // y axis "direction" is swapped between geo and grid - double maxy = lowerGrid.getOrdinate(1); - double miny = upperGrid.getOrdinate(1); - - minx = Math.floor(minx); - maxx = Math.ceil(maxx); - - miny = Math.floor(miny); - maxy = Math.ceil(maxy); - - return new int[][] { { (int) minx, (int) miny }, - { (int) maxx, (int) maxy } }; - } - - protected GridGeometry2D getGridGeometry(IDataRecord record, - ReferencedEnvelope env) { - return getGridGeometry(0, (int) record.getSizes()[0] - 1, 0, - (int) record.getSizes()[1] - 1, env); - } - - protected GridGeometry2D getGridGeometry(int gridXmin, int gridXmax, - int gridYmin, int gridYmax, ReferencedEnvelope env) { - GeneralEnvelope genEnvelope = convertEnvelopeToGeneralEnvelope(env); - genEnvelope.setCoordinateReferenceSystem(env - .getCoordinateReferenceSystem()); - GridGeometry2D gridGeom = new GridGeometry2D(new GeneralGridEnvelope( - new int[] { gridXmin, gridYmin }, new int[] { gridXmax, - gridYmax }, true), genEnvelope); - - return gridGeom; - } - - /** - * @param identifier - * @param time - * @return - * @throws WcsException - */ - protected PluginDataObject getRecord(String identifier, DataTime time, - List rangeFields) throws WcsException { - if (time == null) { - time = new DataTime(getDefaultTime(identifier)); - } - String uri = buildUri(identifier, time); - PluginDataObject rval; - try { - PluginDao dao = getDao(); - rval = dao.getMetadata(uri); - } catch (PluginException e) { - log.error("Unable to query metdata", e); - throw new WcsException(Code.InternalServerError); - } - if (rval == null) { - throw new WcsException(Code.LayerNotDefined); - } - return rval; - } - - protected String buildUri(String identifier, DataTime time) { - return ("/" + getKey() + '/' + time + '/' + identifier).replaceAll(" ", - "_"); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wcs.reg.WcsSource#getKey() - */ - @Override - public String getKey() { - return props.getPluginName(); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wcs.reg.WcsSource#hasCoverageDescription(java.lang - * .String) - */ - @Override - public boolean hasCoverageDescription(String identifier) { - if (idCache.isEmpty()) { - getCoverageList(true); - } - return idCache.contains(identifier); - } - - /** - * @param coverageList - * list of coverages to add to the Cache - * @param wait - * set to true to wait for the updateThread to complete - */ - protected void updateIdCache(final List coverageList, - boolean wait) { - - if (idUpdateThread == null - || idUpdateThread.getState().equals(State.TERMINATED)) { - idUpdateThread = new Thread() { - public void run() { - for (CoverageDescription cd : coverageList) { - idCache.add(cd.getIdentifier()); - } - }; - }; - } - if (!idUpdateThread.isAlive()) { - idUpdateThread.start(); - if (wait) { - try { - idUpdateThread.join(); - } catch (InterruptedException e) { - log.warn("cache update interrupted", e); - } - } - } - } - - protected GeneralEnvelope convertEnvelopeToGeneralEnvelope( - Envelope env) { - GeneralEnvelope rval = new GeneralEnvelope(2); - rval.setRange(0, env.getMinX(), env.getMaxX()); - rval.setRange(1, env.getMinY(), env.getMaxY()); - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeAxis.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeAxis.java deleted file mode 100644 index 7911cd5dac..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeAxis.java +++ /dev/null @@ -1,162 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang.StringUtils; - -/** - * - * @author bclement - * @version 1.0 - */ -public class RangeAxis { - - protected String identifier; - - protected Set keys; - - protected static Pattern axisPattern = Pattern - .compile("^([^\\[]+)\\[([^\\]]+)]$"); - - /** - * @param description - * @param identifier - * @param keys - */ - public RangeAxis(String identifier, Set keys) { - super(); - this.identifier = identifier; - this.keys = keys; - } - - /** - * @param axisSubset - * string that conforms to the following grammar
- * AxisSubsets = AxisSubset *( “,” AxisSubset )
- * AxisSubset = AxisId “[” Keys “]”
- * Keys = Key *( “,” Key ) - * @return null if axisSubset is null - * @throws RangeParseException - * if axisSubsets doesn't follow the above grammar - */ - public static List getAxisList(String axisSubsets) - throws RangeParseException { - if (axisSubsets == null || axisSubsets.isEmpty()) { - throw new RangeParseException( - "axis subsets cannot be null or empty"); - } - List parts = axisSplit(axisSubsets); - List rval = new ArrayList(parts.size()); - for (String s : parts) { - rval.add(getAxis(s)); - } - return rval; - } - - /** - * @param axisSubset - * string that conforms to the following grammar
- * AxisSubset = AxisId “[” Keys “]”
- * Keys = Key *( “,” Key ) - * @return - * @throws RangeParseException - * if axisSubset doesn't follow the above grammar - */ - public static RangeAxis getAxis(String axisSubset) - throws RangeParseException { - if (axisSubset == null) { - throw new RangeParseException("axis subset cannot be null"); - } - Matcher m = axisPattern.matcher(axisSubset); - if (m.matches()) { - Set keys = new HashSet(); - keys.addAll(Arrays.asList(m.group(2).split(","))); - return new RangeAxis(m.group(1), keys); - } - throw new RangeParseException("Invalid axis subset: " + axisSubset); - } - - /** - * @param axisStr - * @return - */ - protected static List axisSplit(String axisStr) { - int start = 0; - int end = 0; - int mark = -1; - List rval = new ArrayList(); - do { - mark = axisStr.indexOf(',', end); - if (mark > 0 && axisStr.charAt(mark - 1) == ']') { - rval.add(axisStr.substring(start, mark)); - start = mark + 1; - } - end = mark + 1; - } while (mark > 0); - rval.add(axisStr.substring(start)); - return rval; - } - - @Override - public String toString() { - String rval = String.valueOf(identifier); - if (keys != null && !keys.isEmpty()) { - String keyStr = StringUtils.join(keys, ','); - rval = rval + '[' + keyStr + ']'; - } - return rval; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public Set getKeys() { - return keys; - } - - public void setKeys(Set keys) { - this.keys = keys; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeField.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeField.java deleted file mode 100644 index 2ea5bcea1d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeField.java +++ /dev/null @@ -1,223 +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 9, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang.StringUtils; - -/** - * - * @author bclement - * @version 1.0 - */ -public class RangeField { - - protected static Pattern fieldPattern = Pattern - .compile("^([^\\[:]+)(:([^\\[]+))?(\\[(.*)\\])?$"); - - public enum InterpolationType { - nearest, linear, cubic, quadratic, none - }; - - protected String identifier; - - protected RangeFieldDefinition definition; - - protected InterpolationType defaultInterpolation = InterpolationType.none; - - protected List additionalInterpolations; - - protected List axis; - - protected String nullValue; - - /** - * @param identifier - * @param description - * @param definition - */ - public RangeField(String identifier, RangeFieldDefinition definition) { - super(); - this.identifier = identifier; - this.definition = definition; - } - - /** - * @param rangeSubset - * string that conforms to the following grammar
- * RangeSubset = FieldSubset *( “;” FieldSubset )
- * FieldSubset = FieldId [ “:” Interpolation ] [ “[” AxisSubsets - * “]” ]
- * AxisSubsets = AxisSubset *( “,” AxisSubset )
- * AxisSubset = AxisId “[” Keys “]”
- * Keys = Key *( “,” Key ) - * @return - * @throws RangeParseException - * if argument doesn't match above grammar or interpolation type - * isn't recognized - */ - public static List getRanges(String rangeSubset) - throws RangeParseException { - if (rangeSubset == null || rangeSubset.isEmpty()) { - throw new RangeParseException( - "range subset cannot be null or empty"); - } - String[] parts = rangeSubset.split(";"); - ArrayList rval = new ArrayList(parts.length); - for (String s : parts) { - rval.add(getField(s)); - } - return rval; - } - - /** - * @param fieldSubset - * string that conforms to the following grammar
- * FieldSubset = FieldId [ “:” Interpolation ] [ “[” AxisSubsets - * “]” ]
- * AxisSubsets = AxisSubset *( “,” AxisSubset )
- * AxisSubset = AxisId “[” Keys “]”
- * Keys = Key *( “,” Key ) - * @return - * @throws RangeParseException - * if argument doesn't match above grammar or interpolation type - * isn't recognized - */ - public static RangeField getField(String fieldSubset) - throws RangeParseException { - if (fieldSubset == null) { - throw new RangeParseException("field subset cannot be null"); - } - Matcher m = fieldPattern.matcher(fieldSubset); - if (m.matches()) { - String id = m.group(1); - String interp = m.group(3); - RangeField rval = new RangeField(id, null); - rval.setDefaultInterpolation(getInterp(interp)); - if (m.group(5) != null) { - rval.setAxis(RangeAxis.getAxisList(m.group(5))); - } - return rval; - } - throw new RangeParseException("Invalid field subset: " + fieldSubset); - } - - /** - * @param interp - * @return - * @throws RangeParseException - */ - protected static InterpolationType getInterp(String interp) - throws RangeParseException { - InterpolationType rval = InterpolationType.none; - try { - if (interp != null) { - rval = InterpolationType.valueOf(interp); - } - } catch (Throwable t) { - throw new RangeParseException("Invalid interpolation type: " - + interp, t); - } - return rval; - } - - @Override - public String toString() { - String rval = String.valueOf(identifier); - if (defaultInterpolation != null - && !defaultInterpolation.equals(InterpolationType.none)) { - rval = rval + ':' + defaultInterpolation; - } - if (axis != null && !axis.isEmpty()) { - List strList = new ArrayList(axis.size()); - for (RangeAxis ra : axis) { - strList.add(ra.toString()); - } - String axisStr = StringUtils.join(strList, ','); - rval = rval + '[' + axisStr + ']'; - } - return rval; - } - - public String getNullValue() { - return nullValue; - } - - public void setNullValue(String nullValue) { - this.nullValue = nullValue; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public RangeFieldDefinition getDefinition() { - return definition; - } - - public void setDefinition(RangeFieldDefinition definition) { - this.definition = definition; - } - - public InterpolationType getDefaultInterpolation() { - return defaultInterpolation; - } - - public void setDefaultInterpolation(InterpolationType defaultInterpolation) { - this.defaultInterpolation = defaultInterpolation; - } - - public List getAdditionalInterpolations() { - return additionalInterpolations; - } - - public void setAdditionalInterpolations( - List additionalInterpolations) { - this.additionalInterpolations = additionalInterpolations; - } - - public List getAxis() { - return axis; - } - - public void setAxis(List axis) { - this.axis = axis; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeFieldDefinition.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeFieldDefinition.java deleted file mode 100644 index cd7f1f55a3..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeFieldDefinition.java +++ /dev/null @@ -1,105 +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 10, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -/** - * - * @author bclement - * @version 1.0 - */ -public class RangeFieldDefinition { - - public enum Closure { - open, closed, closedOpen, openClosed - }; - - protected double maxValue; - - protected double minValue; - - protected Closure closure; - - protected String units; - - /** - * @param maxValue - * @param minValue - */ - public RangeFieldDefinition(double maxValue, double minValue) { - this(maxValue, minValue, Closure.closed); - } - - /** - * @param maxValue - * @param minValue - * @param closure - */ - public RangeFieldDefinition(double maxValue, double minValue, - Closure closure) { - super(); - this.maxValue = maxValue; - this.minValue = minValue; - this.closure = closure; - } - - public String getUnits() { - return units; - } - - public void setUnits(String units) { - this.units = units; - } - - public double getMaxValue() { - return maxValue; - } - - public void setMaxValue(double maxValue) { - this.maxValue = maxValue; - } - - public double getMinValue() { - return minValue; - } - - public void setMinValue(double minValue) { - this.minValue = minValue; - } - - public Closure getClosure() { - return closure; - } - - public void setClosure(Closure closure) { - this.closure = closure; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeParseException.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeParseException.java deleted file mode 100644 index 676c4e2630..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/RangeParseException.java +++ /dev/null @@ -1,72 +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 26, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -/** - * TODO Add Description - * - * @author bclement - * @version 1.0 - */ -public class RangeParseException extends Exception { - - private static final long serialVersionUID = 2555591340601297507L; - - /** - * - */ - public RangeParseException() { - super(); - } - - /** - * @param message - * @param cause - */ - public RangeParseException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param message - */ - public RangeParseException(String message) { - super(message); - } - - /** - * @param cause - */ - public RangeParseException(Throwable cause) { - super(cause); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/WcsSource.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/WcsSource.java deleted file mode 100644 index 4234c1cffa..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/WcsSource.java +++ /dev/null @@ -1,67 +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 5, 2011 bclement Initial creation - * - */ - -package com.raytheon.uf.edex.wcs.reg; - -import java.util.List; - -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.wcs.WcsException; -import com.vividsolutions.jts.geom.Envelope; - -public interface WcsSource { - - public List listCoverages(); - - public CoverageDescription describeCoverage(String identifier) - throws WcsException; - - public Coverage getCoverage(String identifier, DataTime time, - CoordinateReferenceSystem crs, Envelope bbox, - List rangeFields) throws WcsException; - - public String getKey(); - - /** - * Get a quick true or false answer to the question - * "Does this WcsSource have a coverage description for this id" - *

- * Implementations should maintain a cache of valid identifiers so that this - * lookup is performed quickly. A for-loop is not a recommended solution. - * - * @param identifier - * @return true if the wcs source has a coverage description for the given - * identifier, false otherwise - */ - public boolean hasCoverageDescription(String identifier); -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/WcsSourceAccessor.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/WcsSourceAccessor.java deleted file mode 100644 index b2a5d198ea..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/reg/WcsSourceAccessor.java +++ /dev/null @@ -1,70 +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 5, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.reg; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.context.ApplicationContext; - -import com.raytheon.uf.edex.core.EDEXUtil; - -/** - * - * @author bclement - * @version 1.0 - */ -public class WcsSourceAccessor { - - public synchronized List getCoverages() { - ApplicationContext ctx = EDEXUtil.getSpringContext(); - String[] beans = ctx.getBeanNamesForType(WcsSource.class); - List cd = new ArrayList( - beans.length); - for (String bean : beans) { - WcsSource s = (WcsSource) ctx.getBean(bean); - cd.addAll(s.listCoverages()); - } - return cd; - } - - public synchronized WcsSource getSource(String id) { - ApplicationContext ctx = EDEXUtil.getSpringContext(); - String[] beans = ctx.getBeanNamesForType(WcsSource.class); - for (String bean : beans) { - WcsSource s = (WcsSource) ctx.getBean(bean); - if (s.hasCoverageDescription(id)) { - return s; - } - } - return null; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/DefactoEnabler.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/DefactoEnabler.java deleted file mode 100644 index e4f8b7badd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/DefactoEnabler.java +++ /dev/null @@ -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 - * - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Jul 29, 2011 jelkins Initial creation - * - */ -package com.raytheon.uf.edex.wcs.request; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.component.http.HttpMessage; - -/** - * TODO Add Description - * - * @author jelkins - * @version 1.0 - */ -public class DefactoEnabler implements Processor { - - public static final String HEADER_KEY = "replyStandard"; - public static final String HEADER_VALUE = "defacto"; - - /* - * (non-Javadoc) - * - * @see org.apache.camel.Processor#process(org.apache.camel.Exchange) - */ - @Override - public void process(Exchange exchange) throws Exception { - Message in = exchange.getIn(); - in.getHeaders().put(HEADER_KEY, HEADER_VALUE); - exchange.getIn().setBody( - new HttpMessage(exchange, in.getBody(HttpServletRequest.class), - in.getBody(HttpServletResponse.class))); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/DescCoverageRequest.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/DescCoverageRequest.java deleted file mode 100644 index 831095d581..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/DescCoverageRequest.java +++ /dev/null @@ -1,60 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.request; - - -public class DescCoverageRequest extends WcsRequest{ - - protected String outputformat = "text/xml; subtype=gml/3.1.1"; - - protected String[] identifiers; - - public DescCoverageRequest() { - super(Type.DescribeCoverage); - } - - public String getOutputformat() { - return outputformat; - } - - public void setOutputformat(String outputformat) { - this.outputformat = outputformat; - } - - public String[] getIdentifiers() { - return identifiers; - } - - public void setIdentifiers(String[] identifiers) { - this.identifiers = identifiers; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetCapRequest.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetCapRequest.java deleted file mode 100644 index 12cd60be8f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetCapRequest.java +++ /dev/null @@ -1,41 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.request; - - -public class GetCapRequest extends WcsRequest { - - public GetCapRequest() { - super(Type.GetCapabilities); - } - - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetCoverageRequest.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetCoverageRequest.java deleted file mode 100644 index d88ca42163..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetCoverageRequest.java +++ /dev/null @@ -1,162 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.request; - -import java.util.List; - -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.edex.ogc.common.OgcBoundingBox; -import com.raytheon.uf.edex.wcs.reg.RangeField; - -public class GetCoverageRequest extends WcsRequest { - - protected String identifier; - - protected String format; - - protected OgcBoundingBox bbox; - - protected List fields; - - protected boolean store = false; - - protected DataTime timeSequence; - - protected String gridBaseCrs; - - protected String gridType; - - protected List gridOrigin; - - protected List gridOffsets; - - protected boolean defacto = false; - - public GetCoverageRequest() { - super(Type.GetCoverage); - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public OgcBoundingBox getBbox() { - return bbox; - } - - public void setBbox(OgcBoundingBox bbox) { - this.bbox = bbox; - } - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - public boolean isStore() { - return store; - } - - public void setStore(boolean store) { - this.store = store; - } - - public DataTime getTimeSequence() { - return timeSequence; - } - - public void setTimeSequence(DataTime timeSequence) { - this.timeSequence = timeSequence; - } - - public String getGridBaseCrs() { - return gridBaseCrs; - } - - public void setGridBaseCrs(String gridBaseCrs) { - this.gridBaseCrs = gridBaseCrs; - } - - public String getGridType() { - return gridType; - } - - public void setGridType(String gridType) { - this.gridType = gridType; - } - - public List getGridOrigin() { - return gridOrigin; - } - - public void setGridOrigin(List gridOrigin) { - this.gridOrigin = gridOrigin; - } - - public List getGridOffsets() { - return gridOffsets; - } - - public void setGridOffsets(List gridOffsets) { - this.gridOffsets = gridOffsets; - } - - /** - * @param defacto - * the defacto to set - */ - public void setDefacto(boolean defacto) { - this.defacto = defacto; - } - - /** - * @return the defacto - */ - public boolean isDefacto() { - return defacto; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetDataRequest.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetDataRequest.java deleted file mode 100644 index 12be93ed95..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/GetDataRequest.java +++ /dev/null @@ -1,116 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wcs.request; - -public class GetDataRequest extends WcsRequest { - - private String group = ""; - - private String dataset = ""; - - protected String xOffset; - - protected String yOffset; - - protected String width; - - protected String height; - - public GetDataRequest() { - super(Type.GetData); - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public String getDataset() { - return dataset; - } - - public void setDataset(String dataset) { - this.dataset = dataset; - } - - public String getxOffset() { - return xOffset; - } - - public void setxOffset(String xOffset) { - this.xOffset = xOffset; - } - - public String getyOffset() { - return yOffset; - } - - public void setyOffset(String yOffset) { - this.yOffset = yOffset; - } - - public String getWidth() { - return width; - } - - public void setWidth(String width) { - this.width = width; - } - - public String getHeight() { - return height; - } - - public void setHeight(String height) { - this.height = height; - } - - public int[] getMinIndex() { - int[] minIndex = { 0, 0 }; - - minIndex[0] = Integer.parseInt(xOffset); - minIndex[1] = Integer.parseInt(yOffset); - - return minIndex; - } - - public int[] getMaxIndex() { - int[] maxIndex = { 0, 0 }; - - maxIndex[0] = Integer.parseInt(xOffset) + Integer.parseInt(width); - maxIndex[1] = Integer.parseInt(yOffset) + Integer.parseInt(height); - - return maxIndex; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/WcsRequest.java b/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/WcsRequest.java deleted file mode 100644 index 0d3568cc6a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wcs/src/com/raytheon/uf/edex/wcs/request/WcsRequest.java +++ /dev/null @@ -1,88 +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.wcs.request; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; - -/** - * TODO - Class comment here - * - *

- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------- --------------------------
- * 
- * 
- * - * @author - * @version 1 - */ - -public class WcsRequest { - - public enum Type { - GetCoverage, DescribeCoverage, GetCapabilities, GetData, ERROR - } - - protected Type type; - - protected Object request; - - protected String exceptionFormat = OgcResponse.TEXT_XML_MIME; - - public WcsRequest(Type type) { - this.type = type; - } - - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - public Object getRequest() { - return request; - } - - public void setRequest(Object request) { - this.request = request; - } - - /** - * @return the exceptionFormat - */ - public String getExceptionFormat() { - return exceptionFormat; - } - - /** - * @param exceptionFormat - * the exceptionFormat to set - */ - public void setExceptionFormat(String exceptionFormat) { - this.exceptionFormat = exceptionFormat; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/.classpath b/edexOsgi/com.raytheon.uf.edex.wfs/.classpath deleted file mode 100644 index ad32c83a78..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/.project b/edexOsgi/com.raytheon.uf.edex.wfs/.project deleted file mode 100644 index d5c193ce4f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.wfs - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.wfs/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 10ada26be0..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Feb 01 16:56:29 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 diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.wfs/META-INF/MANIFEST.MF deleted file mode 100644 index ff89fdbf8f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/META-INF/MANIFEST.MF +++ /dev/null @@ -1,26 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Wfs -Bundle-SymbolicName: com.raytheon.uf.edex.wfs -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: RAYTHEON -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.geotools;bundle-version="2.6.4", - com.raytheon.edex.common;bundle-version="1.12.1174", - com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0", - com.raytheon.uf.common.json;bundle-version="1.0.0", - org.codehaus.jackson;bundle-version="1.7.3", - org.apache.commons.logging;bundle-version="1.1.1", - javax.servlet;bundle-version="2.5.0", - org.apache.commons.pool;bundle-version="1.3.0", - net.opengis;bundle-version="1.0.2", - ogc.tools.gml;bundle-version="1.0.2", - org.apache.commons.lang;bundle-version="2.3.0" -Export-Package: com.raytheon.uf.edex.wfs, - com.raytheon.uf.edex.wfs.feature, - com.raytheon.uf.edex.wfs.filter, - com.raytheon.uf.edex.wfs.gml, - com.raytheon.uf.edex.wfs.provider, - com.raytheon.uf.edex.wfs.reg, - com.raytheon.uf.edex.wfs.request, - com.raytheon.uf.edex.wfs.util diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/build.properties b/edexOsgi/com.raytheon.uf.edex.wfs/build.properties deleted file mode 100644 index 2660b7d6a5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -source.. = src/ -bin.includes = .project,\ - component-deploy.xml,\ - .classpath,\ - META-INF/,\ - build.properties,\ - .settings/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/com.raytheon.uf.edex.wfs.ecl b/edexOsgi/com.raytheon.uf.edex.wfs/com.raytheon.uf.edex.wfs.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/component-deploy.xml b/edexOsgi/com.raytheon.uf.edex.wfs/component-deploy.xml deleted file mode 100644 index 9c1b8e8421..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/component-deploy.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/res/spring/wfs-ogc-request.xml b/edexOsgi/com.raytheon.uf.edex.wfs/res/spring/wfs-ogc-request.xml deleted file mode 100644 index f577df5c34..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/res/spring/wfs-ogc-request.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsException.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsException.java deleted file mode 100644 index bff335429c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsException.java +++ /dev/null @@ -1,70 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs; - -public class WfsException extends Exception { - - public enum Code { - INVALID_REQUEST, INTERNAL_SERVER_ERROR, INVALID_PARAMETER_VALUE - } - - private static final long serialVersionUID = 8797482743733419169L; - - protected Code code; - - public WfsException(Code code) { - this.code = code; - } - - public WfsException(Code code, String message) { - super(message); - this.code = code; - } - - public WfsException(Code code, Throwable cause) { - super(cause); - this.code = code; - } - - public WfsException(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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsFeatureType.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsFeatureType.java deleted file mode 100644 index 9df77f6e5b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsFeatureType.java +++ /dev/null @@ -1,173 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs; - -import java.util.LinkedList; -import java.util.List; - -import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox; -import com.raytheon.uf.edex.wfs.request.QualifiedName; - -/** - * @author bclement - * - */ -public class WfsFeatureType { - - protected QualifiedName name; - - protected String title; - - protected String abs; - - protected String defaultSRS; - - protected List keywords = new LinkedList(); - - protected List otherSRS = new LinkedList(); - - protected OgcGeoBoundingBox bbox; - - public WfsFeatureType(QualifiedName name, String title, String defaultSRS, - OgcGeoBoundingBox bbox) { - super(); - this.name = name; - this.title = title; - this.defaultSRS = defaultSRS; - this.bbox = bbox; - } - - public void addKeyword(String keyword) { - this.keywords.add(keyword); - } - - public void addOtherSRS(String srs) { - this.otherSRS.add(srs); - } - - public QualifiedName getName() { - return name; - } - - public void setName(QualifiedName name) { - this.name = name; - } - - /** - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * @param title - * the title to set - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * @return the abs - */ - public String getAbs() { - return abs; - } - - /** - * @param abs - * the abs to set - */ - public void setAbs(String abs) { - this.abs = abs; - } - - /** - * @return the defaultSRS - */ - public String getDefaultSRS() { - return defaultSRS; - } - - /** - * @param defaultSRS - * the defaultSRS to set - */ - public void setDefaultSRS(String defaultSRS) { - this.defaultSRS = defaultSRS; - } - - /** - * @return the keywords - */ - public List getKeywords() { - return keywords; - } - - /** - * @param keywords - * the keywords to set - */ - public void setKeywords(List keywords) { - this.keywords = keywords; - } - - /** - * @return the otherSRS - */ - public List getOtherSRS() { - return otherSRS; - } - - /** - * @param otherSRS - * the otherSRS to set - */ - public void setOtherSRS(List otherSRS) { - this.otherSRS = otherSRS; - } - - /** - * @return the bbox - */ - public OgcGeoBoundingBox getBbox() { - return bbox; - } - - /** - * @param bbox - * the bbox to set - */ - public void setBbox(OgcGeoBoundingBox bbox) { - this.bbox = bbox; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsHttpFactory.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsHttpFactory.java deleted file mode 100644 index 79af11db5e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsHttpFactory.java +++ /dev/null @@ -1,121 +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 19, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs; - -import org.apache.commons.pool.KeyedPoolableObjectFactory; - -import com.raytheon.uf.edex.wfs.provider.OgcWfsProvider; -import com.raytheon.uf.edex.wfs.reg.WfsRegistryImpl; - -/** - * TODO Add Description - * - * @author bclement - * @version 1.0 - */ -public class WfsHttpFactory implements KeyedPoolableObjectFactory { - - protected WfsRegistryImpl registry; - - /** - * @param registry - * @param converter - */ - public WfsHttpFactory(WfsRegistryImpl registry) { - super(); - this.registry = registry; - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#makeObject(java.lang - * .Object) - */ - @Override - public Object makeObject(Object key) throws Exception { - return new WfsHttpHandler(new OgcWfsProvider(registry)); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#destroyObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void destroyObject(Object key, Object obj) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#validateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public boolean validateObject(Object key, Object obj) { - // TODO Auto-generated method stub - return false; - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#activateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void activateObject(Object key, Object obj) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#passivateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void passivateObject(Object key, Object obj) throws Exception { - // TODO Auto-generated method stub - - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsHttpHandler.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsHttpHandler.java deleted file mode 100644 index e803a7e0fd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsHttpHandler.java +++ /dev/null @@ -1,461 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs; - -import java.io.InputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.raytheon.uf.edex.ogc.common.OgcBoundingBox; -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcPrefix; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.feature.JsonFeatureFormatter; -import com.raytheon.uf.edex.ogc.common.feature.ShpFeatureFormatter; -import com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler; -import com.raytheon.uf.edex.ogc.common.http.OgcHttpRequest; -import com.raytheon.uf.edex.ogc.common.output.OgcResponseOutput; -import com.raytheon.uf.edex.wfs.WfsException.Code; -import com.raytheon.uf.edex.wfs.WfsProvider.WfsOpType; -import com.raytheon.uf.edex.wfs.request.DescFeatureTypeReq; -import com.raytheon.uf.edex.wfs.request.FeatureQuery; -import com.raytheon.uf.edex.wfs.request.FeatureQuery.QFilterType; -import com.raytheon.uf.edex.wfs.request.GetCapReq; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq.ResultType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; -import com.raytheon.uf.edex.wfs.request.SortBy; -import com.raytheon.uf.edex.wfs.request.SortBy.Order; -import com.raytheon.uf.edex.wfs.request.TransReq; -import com.raytheon.uf.edex.wfs.request.WfsRequest; -import com.raytheon.uf.edex.wfs.request.WfsRequest.Type; - -public class WfsHttpHandler implements OgcHttpHandler { - - public static final String REQUEST_HEADER = "request"; - - public static final String CAP_PARAM = "getcapabilities"; - - public static final String DESC_PARAM = "describefeaturetype"; - - public static final String GET_PARAM = "getfeature"; - - public static final String OUTFORMAT_HEADER = "outputformat"; - - public static final String RESTYPE_HEADER = "resulttype"; - - public static final String PROPNAME_HEADER = "propertyname"; - - public static final String MAXFEAT_HEADER = "maxfeatures"; - - public static final String SRSNAME_HEADER = "srsname"; - - public static final String TYPENAME_HEADER = "typename"; - - public static final String FEATID_HEADER = "featureid"; - - public static final String FILTER_HEADER = "filter"; - - public static final String BBOX_HEADER = "bbox"; - - public static final String SORTBY_HEADER = "sortby"; - - public static final String NS_HEADER = "namespace"; - - protected Pattern nspattern = Pattern.compile("xmlns\\((\\S+)=(\\S+)\\)"); - - protected WfsProvider provider; - - protected Log log = LogFactory.getLog(this.getClass()); - - public WfsHttpHandler(WfsProvider provider) { - this.provider = provider; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler#handle(javax.servlet - * .http.HttpServletRequest, javax.servlet.http.HttpServletResponse, - * java.util.Map) - */ - @Override - public void handle(OgcHttpRequest req) { - try { - handleInternal(req); - } catch (Exception e) { - log.error("Unable to handle request", e); - } - } - - protected void handleInternal(OgcHttpRequest req) - throws Exception { - OgcResponse rval = null; - Map headers = req.getHeaders(); - HttpServletResponse response = req.getResponse(); - OgcServiceInfo serviceInfo = getServiceInfo(req.getRequest()); - WfsRequest request; - if (req.isPost()) { - InputStream is = req.getInputStream(); - request = provider.getRequest(is); - } else { - request = getRequestFromHeaders(headers); - } - - rval = validateExceptionFormat(request); - if (rval != null) { - sendResponse(response, rval); - } - - String username = (String) headers.get(USER_HEADER); - String[] roles = (String[]) headers.get(ROLES_HEADER); - request.setUsername(username); - request.setRoles(roles); - switch (request.getType()) { - case DescribeFeature: - rval = provider.describeFeatureType((DescFeatureTypeReq) request, - serviceInfo); - break; - case GetCapabilities: - rval = provider.getCapabilities((GetCapReq) request, serviceInfo); - break; - case GetFeature: - rval = provider.getFeature((GetFeatureReq) request, serviceInfo); - break; - case Transaction: - rval = provider.transaction((TransReq) request); - break; - case ERROR: - rval = (OgcResponse) request.getRawrequest(); - break; - } - sendResponse(response, rval); - } - - /** - * @param request - * @return - */ - private OgcResponse validateExceptionFormat(WfsRequest request) { - if (!request.getExceptionFormat().equalsIgnoreCase( - OgcResponse.TEXT_HTML_MIME) - && !request.getExceptionFormat().equalsIgnoreCase( - OgcResponse.TEXT_XML_MIME)) { - return provider.getError(new WfsException( - Code.INVALID_PARAMETER_VALUE, - "exceptions parameter invalid"), OgcResponse.TEXT_XML_MIME); - } - return null; - } - - protected WfsRequest getRequestFromHeaders(Map headers) { - WfsRequest rval = null; - Object obj = headers.get(REQUEST_HEADER); - if (obj instanceof String) { - String req = (String) obj; - if (req.equalsIgnoreCase(CAP_PARAM)) { - rval = new GetCapReq(); - } else if (req.equalsIgnoreCase(DESC_PARAM)) { - rval = buildDescFeatureReq(headers); - } else if (req.equalsIgnoreCase(GET_PARAM)) { - rval = buildGetFeatureReq(headers); - } - } - String exceptionFormat = getHeader(EXCEP_FORMAT_HEADER, headers); - if (exceptionFormat == null || exceptionFormat.isEmpty()) { - exceptionFormat = OgcResponse.TEXT_XML_MIME; - } - if (rval == null) { - OgcResponse error = provider.getError(new WfsException( - Code.INVALID_REQUEST, "Unable to decode request"), - exceptionFormat); - rval = new WfsRequest(Type.ERROR); - rval.setRawrequest(error); - } - - return rval; - } - - protected Map getNameSpaceMap(Map headers) { - Map nsmap = new HashMap(); - String ns = getHeader(NS_HEADER, headers); - if (ns != null) { - for (String s : splitOnComma(ns)) { - Matcher matcher = nspattern.matcher(s); - if (matcher.matches()) { - nsmap.put(matcher.group(1), matcher.group(2)); - } - } - } else { - nsmap.put(OgcPrefix.EDEX, OgcNamespace.EDEX); - } - return nsmap; - } - - protected String[] splitOnComma(String str) { - final String marker = "λλλ"; - String[] rval = str.replaceAll("\\\\,", marker).split(","); - for (int i = 0; i < rval.length; ++i) { - rval[i] = rval[i].replaceAll(marker, ","); - } - return rval; - } - - /** - * @param headers - * @return - */ - protected GetFeatureReq buildGetFeatureReq(Map headers) { - GetFeatureReq rval = new GetFeatureReq(); - String resType = getHeader(RESTYPE_HEADER, headers); - if (resType != null) { - ResultType valueOf = GetFeatureReq.ResultType.valueOf(resType); - if (valueOf != null) { - rval.setResulttype(valueOf); - } - } - String max = getHeader(MAXFEAT_HEADER, headers); - if (max != null) { - try { - rval.setMaxFeatures(Integer.parseInt(max)); - } catch (NumberFormatException e) { - // ignore - } - } - String outputformat = getHeader(OUTFORMAT_HEADER, headers); - if (outputformat != null) { - rval.setOutputformat(outputformat); - } - Map nsmap = getNameSpaceMap(headers); - String[] bboxes = splitOnParens(BBOX_HEADER, headers); - String[] filters = splitOnParens(FILTER_HEADER, headers); - String[] sorts = splitOnParens(SORTBY_HEADER, headers); - String[] props = splitOnParens(PROPNAME_HEADER, headers); - String[] srsnames = splitOnParens(SRSNAME_HEADER, headers); - String[] types = getHeaderArr(TYPENAME_HEADER, headers); - for (int i = 0; i < types.length; ++i) { - FeatureQuery fq = new FeatureQuery(); - if (bboxes.length > 0) { - fq.setFilter(getBoundingBox(bboxes[i]), QFilterType.BBOX); - } else if (filters.length > 0) { - fq.setFilter(filters[i], QFilterType.XML); - } - fq.setTypeNames(getTypeNames(types[i], nsmap)); - if (i < sorts.length) { - fq.setSortBys(getSortBys(sorts[i])); - } - if (i < props.length) { - fq.setPropertyNames(Arrays.asList(splitOnComma(props[i]))); - } - if (i < srsnames.length) { - fq.setSrsName(srsnames[i]); - } - rval.addQuery(fq); - } - return rval; - } - - /** - * @param nsmap - * @param string - * @return - */ - protected List getTypeNames(String typename, - Map nsmap) { - String[] parts = typename.split(":", 2); - List rval = new LinkedList(); - if (parts.length == 1) { - // default names to the edex namespace - rval.add(new QualifiedName(OgcNamespace.EDEX, parts[0], null)); - } else if (parts.length == 2) { - rval.add(new QualifiedName(nsmap.get(parts[0]), parts[1], parts[0])); - } - return rval; - } - - protected String[] splitOnParens(String name, Map headers) { - String val = getHeader(name, headers); - String[] rval; - if (val != null) { - val = val.replaceAll("\\s*\\(", ""); - rval = val.split("\\)"); - } else { - rval = new String[0]; - } - return rval; - } - - /** - * @param headers - * @return - */ - protected List getSortBys(String sortby) { - List rval = new LinkedList(); - String[] sorts = splitOnComma(sortby); - for (String s : sorts) { - String[] parts = s.split("\\s+"); - SortBy.Order order = Order.Ascending; - if (parts.length == 2) { - if (parts[1].trim().equalsIgnoreCase("D")) { - order = Order.Descending; - } - } - rval.add(new SortBy(parts[0].trim(), order)); - } - return rval; - } - - /** - * @param bboxes - * @return - */ - protected OgcBoundingBox getBoundingBox(String bbox) { - String[] parts = splitOnComma(bbox); - OgcBoundingBox rval = null; - if (parts.length == 4) { - rval = new OgcBoundingBox(); - try { - rval.setMinx(Double.parseDouble(parts[0])); - rval.setMiny(Double.parseDouble(parts[1])); - rval.setMaxx(Double.parseDouble(parts[2])); - rval.setMaxy(Double.parseDouble(parts[3])); - } catch (NumberFormatException e) { - // ignore - } - }// else TODO handle non 2d WGS84 - return rval; - } - - /** - * @param headers - * @return - */ - protected DescFeatureTypeReq buildDescFeatureReq(Map headers) { - DescFeatureTypeReq rval = new DescFeatureTypeReq(); - String outputformat = getHeader(OUTFORMAT_HEADER, headers); - if (outputformat != null) { - rval.setOutputformat(outputformat); - } - String typename = getHeader(TYPENAME_HEADER, headers); - if (typename != null) { - Map nsmap = getNameSpaceMap(headers); - rval.setTypenames(getTypeNames(typename, nsmap)); - } - return rval; - } - - protected String getHeader(String name, Map headers) { - Object obj = headers.get(name); - String rval = null; - if (obj != null && obj instanceof String) { - rval = (String) obj; - } - return rval; - } - - protected String[] getHeaderArr(String name, Map headers) { - String[] rval; - String value = getHeader(name, headers); - if (value != null) { - rval = splitOnComma(value); - } else { - rval = new String[0]; - } - return rval; - } - - /** - * @param httpRequest - * @return - */ - protected OgcServiceInfo getServiceInfo( - HttpServletRequest request) { - return getServiceInfo(request.getServerName(), request.getServerPort()); - } - - public OgcServiceInfo getServiceInfo(String host, int port) { - String base = "http://" + host; - if (port != 80) { - base += ":" + port; - } - base += "/wfs"; - OgcServiceInfo rval = new OgcServiceInfo(base); - String getCapGet = base + "?request=" + CAP_PARAM; - String getFeatureGet = base + "?request=" + GET_PARAM; - String descFeatureGet = base + "?request=" + DESC_PARAM; - rval.addOperationInfo(getOp(getCapGet, base, WfsOpType.GetCapabilities)); - rval.addOperationInfo(getOp(descFeatureGet, base, - WfsOpType.DescribeFeatureType)); - OgcOperationInfo getFeat = getOp(getFeatureGet, base, WfsOpType.GetFeature); - getFeat.addFormat(ShpFeatureFormatter.mimeType); - getFeat.addFormat(JsonFeatureFormatter.mimeType); - rval.addOperationInfo(getFeat); - return rval; - } - - protected OgcOperationInfo getOp(String get, String post, - WfsOpType type) { - OgcOperationInfo rval = new OgcOperationInfo(type); - rval.setHttpGetRes(get); - rval.setHttpPostRes(post); - rval.addVersion("1.1.0"); - rval.addFormat("text/xml"); - return rval; - } - - protected void sendResponse(HttpServletResponse httpRes, - OgcResponse response) throws Exception { - OgcResponseOutput.output(response, httpRes); - } - - public static void main(String[] args) { - String foo = "(InWaterA_1M/wkbGeom,InWaterA_1M/tileId) (InWaterA_1M/wkbGeom,InWaterA_1M/tileId)(InWaterA_1M/wkbGeom,InWaterA_1M/tileId)"; - foo = foo.replaceAll("\\s*\\(", ""); - for (String s : foo.split("\\)")) { - System.out.println("line: " + s); - } - } - -} \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsProvider.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsProvider.java deleted file mode 100644 index 484afd162e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/WfsProvider.java +++ /dev/null @@ -1,67 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs; - -import java.io.InputStream; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wfs.request.DescFeatureTypeReq; -import com.raytheon.uf.edex.wfs.request.GetCapReq; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq; -import com.raytheon.uf.edex.wfs.request.TransReq; -import com.raytheon.uf.edex.wfs.request.WfsRequest; - -public interface WfsProvider { - - public enum WfsOpType { - GetCapabilities, GetFeature, DescribeFeatureType - } - - public OgcResponse getCapabilities(GetCapReq request, - OgcServiceInfo serviceInfo); - - public OgcResponse describeFeatureType(DescFeatureTypeReq request, - OgcServiceInfo serviceInfo); - - public OgcResponse getFeature(GetFeatureReq request, - OgcServiceInfo serviceInfo); - - public WfsRequest getRequest(InputStream in); - - public OgcResponse getError(WfsException e, String exceptionFormat); - - /** - * @param request - * @return - */ - public OgcResponse transaction(TransReq request); -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureAdapter.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureAdapter.java deleted file mode 100644 index 166dff9cef..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureAdapter.java +++ /dev/null @@ -1,69 +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 - * ------------ ---------- ----------- -------------------------- - * Jul 19, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.feature; - -import java.util.Collection; -import java.util.Map; - -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.opengis.feature.Feature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.FeatureType; -import org.opengis.feature.type.PropertyDescriptor; - -import com.raytheon.uf.common.json.JsonException; -import com.raytheon.uf.common.json.JsonService; - -/** - * - * @author bclement - * @version 1.0 - */ -public class FeatureAdapter { - - protected JsonService jsonService; - - public FeatureAdapter(JsonService json) { - this.jsonService = json; - } - - public Feature convert(Object obj, FeatureType ft) throws JsonException { - Collection descriptors = ft.getDescriptors(); - Map map = jsonService.extract(obj); - SimpleFeatureBuilder builder = new SimpleFeatureBuilder( - (SimpleFeatureType) ft); - for (PropertyDescriptor pd : descriptors) { - String name = pd.getName().getLocalPart(); - builder.set(name, map.get(name)); - } - return builder.buildFeature(null); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureTypeCache.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureTypeCache.java deleted file mode 100644 index b2f06e3ef6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureTypeCache.java +++ /dev/null @@ -1,51 +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 - * ------------ ---------- ----------- -------------------------- - * Jul 19, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.feature; - -import org.opengis.feature.type.FeatureType; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.NoSuchAuthorityCodeException; - -/** - * - * @author bclement - * @version 1.0 - */ -public interface FeatureTypeCache { - - public FeatureType getFeatureType(FeatureTypeConfig config) - throws NoSuchAuthorityCodeException, FactoryException; - - public FeatureTypeCache removeClass(FeatureTypeConfig config); - - public FeatureTypeCache clear(); - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureTypeConfig.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureTypeConfig.java deleted file mode 100644 index abcfb263af..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/FeatureTypeConfig.java +++ /dev/null @@ -1,173 +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 - * ------------ ---------- ----------- -------------------------- - * Jul 19, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.feature; - -import com.raytheon.uf.edex.ogc.common.OgcNamespace; - -/** - * - * @author bclement - * @version 1.0 - */ -public class FeatureTypeConfig { - - public enum METHOD { - JAXB - }; - - protected String name; - - protected Class binding; - - protected String crs; - - protected METHOD method = METHOD.JAXB; - - protected String namespace = OgcNamespace.EDEX; - - protected String geomName = "the_geom"; - - public FeatureTypeConfig(String name, Class binding, String crs) { - super(); - this.name = name; - this.binding = binding; - this.crs = crs; - } - - /** - * - */ - public FeatureTypeConfig() { - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((binding == null) ? 0 : binding.hashCode()); - result = prime * result + ((crs == null) ? 0 : crs.hashCode()); - result = prime * result - + ((geomName == null) ? 0 : geomName.hashCode()); - result = prime * result + ((method == null) ? 0 : method.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result - + ((namespace == null) ? 0 : namespace.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; - FeatureTypeConfig other = (FeatureTypeConfig) obj; - if (binding == null) { - if (other.binding != null) - return false; - } else if (!binding.equals(other.binding)) - return false; - if (crs == null) { - if (other.crs != null) - return false; - } else if (!crs.equals(other.crs)) - return false; - if (geomName == null) { - if (other.geomName != null) - return false; - } else if (!geomName.equals(other.geomName)) - return false; - if (method != other.method) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (namespace == null) { - if (other.namespace != null) - return false; - } else if (!namespace.equals(other.namespace)) - return false; - return true; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Class getBinding() { - return binding; - } - - public void setBinding(Class binding) { - this.binding = binding; - } - - public String getCrs() { - return crs; - } - - public void setCrs(String crs) { - this.crs = crs; - } - - public METHOD getMethod() { - return method; - } - - public void setMethod(METHOD method) { - this.method = method; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public String getGeomName() { - return geomName; - } - - public void setGeomName(String geomName) { - this.geomName = geomName; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/SimpleFeatureTypeCache.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/SimpleFeatureTypeCache.java deleted file mode 100644 index 833e1499fd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/feature/SimpleFeatureTypeCache.java +++ /dev/null @@ -1,159 +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 - * ------------ ---------- ----------- -------------------------- - * Jul 19, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.feature; - -import java.lang.reflect.Field; -import java.util.concurrent.ConcurrentHashMap; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.opengis.feature.type.FeatureType; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.NoSuchAuthorityCodeException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.edex.ogc.common.spatial.CrsLookup; - -/** - * - * @author bclement - * @version 1.0 - */ -public class SimpleFeatureTypeCache implements FeatureTypeCache { - - protected ConcurrentHashMap cache = new ConcurrentHashMap(); - - protected Log log = LogFactory.getLog(this.getClass()); - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.feature.FeatureTypeCache#getFeatureType(java - * .lang.Class) - */ - @Override - public FeatureType getFeatureType(FeatureTypeConfig config) - throws NoSuchAuthorityCodeException, FactoryException { - if (config == null) { - return null; - } - FeatureType rval = cache.get(config); - if (rval == null) { - rval = extractFeatureType(config); - cache.put(config, rval); - } - - return rval; - } - - protected FeatureType extractFeatureType(FeatureTypeConfig config) - throws NoSuchAuthorityCodeException, FactoryException { - switch (config.method) { - case JAXB: - return extractFromJaxb(config); - default: - throw new RuntimeException("Invalid featuretype extraction method"); - } - } - - /** - * Naive implementation. Does not account for embedded types, lists (arrays) - * or adapters. - * - * @param config - * @return - * @throws NoSuchAuthorityCodeException - * @throws FactoryException - */ - protected FeatureType extractFromJaxb(FeatureTypeConfig config) - throws NoSuchAuthorityCodeException, FactoryException { - SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); - builder.setName(config.getName()); - builder.setNamespaceURI(config.getNamespace()); - CoordinateReferenceSystem crs = CrsLookup.lookup(config.getCrs()); - builder.setDefaultGeometry(config.getGeomName()); - builder.setCRS(crs); - Class binding = config.getBinding(); - Field[] fields = binding.getFields(); - for (Field f : fields) { - if (hasJaxb(f)) { - String name = f.getName(); - Class c = f.getDeclaringClass(); - builder.add(name, c); - } - } - return builder.buildFeatureType(); - } - - protected boolean hasJaxb(Field f) { - XmlElement xmle = f.getAnnotation(XmlElement.class); - if (xmle != null) { - return true; - } - XmlAttribute xmla = f.getAnnotation(XmlAttribute.class); - if (xmla != null) { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.feature.FeatureTypeCache#removeClass(java.lang - * .Class) - */ - @Override - public FeatureTypeCache removeClass(FeatureTypeConfig config) { - if (config != null) { - cache.remove(config); - } - return this; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wfs.feature.FeatureTypeCache#clear() - */ - @Override - public FeatureTypeCache clear() { - cache.clear(); - return this; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbsExpressionOp.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbsExpressionOp.java deleted file mode 100644 index cc39ed584a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbsExpressionOp.java +++ /dev/null @@ -1,134 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.JAXBElement; - -import net.opengis.filter.v_1_1_0.BinaryOperatorType; -import net.opengis.filter.v_1_1_0.FunctionType; -import net.opengis.filter.v_1_1_0.LiteralType; -import net.opengis.filter.v_1_1_0.PropertyNameType; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class AbsExpressionOp { - - public abstract Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception; - - public static class Literal extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - LiteralType literal = (LiteralType) element.getValue(); - return visitor.literal(literal.getContent(), obj); - } - } - - public static class Add extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - BinaryOperatorType binary = (BinaryOperatorType) element.getValue(); - List> exprs = binary.getExpression(); - ExpressionProcessor left = new ExpressionProcessor(exprs.get(0)); - ExpressionProcessor right = new ExpressionProcessor(exprs.get(1)); - return visitor.add(left, right, obj); - } - } - - public static class Sub extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - BinaryOperatorType binary = (BinaryOperatorType) element.getValue(); - List> exprs = binary.getExpression(); - ExpressionProcessor left = new ExpressionProcessor(exprs.get(0)); - ExpressionProcessor right = new ExpressionProcessor(exprs.get(1)); - return visitor.sub(left, right, obj); - } - } - - public static class Mul extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - BinaryOperatorType binary = (BinaryOperatorType) element.getValue(); - List> exprs = binary.getExpression(); - ExpressionProcessor left = new ExpressionProcessor(exprs.get(0)); - ExpressionProcessor right = new ExpressionProcessor(exprs.get(1)); - return visitor.mul(left, right, obj); - } - } - - public static class Div extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - BinaryOperatorType binary = (BinaryOperatorType) element.getValue(); - List> exprs = binary.getExpression(); - ExpressionProcessor left = new ExpressionProcessor(exprs.get(0)); - ExpressionProcessor right = new ExpressionProcessor(exprs.get(1)); - return visitor.div(left, right, obj); - } - } - - public static class Property extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - PropertyNameType prop = (PropertyNameType) element.getValue(); - return visitor.property(prop, obj); - } - } - - public static class Function extends AbsExpressionOp { - @Override - public Object visit(JAXBElement element, - OgcExpressionVisitor visitor, Object obj) throws Exception { - FunctionType f = (FunctionType) element.getValue(); - String name = f.getName(); - List> exprs = f.getExpression(); - List procs = new ArrayList( - exprs.size()); - for (JAXBElement expr : exprs) { - procs.add(new ExpressionProcessor(expr)); - } - return visitor.function(procs, name, obj); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractCompOp.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractCompOp.java deleted file mode 100644 index da8e7b6d0a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractCompOp.java +++ /dev/null @@ -1,201 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 20, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBElement; - -import net.opengis.filter.v_1_1_0.BinaryComparisonOpType; -import net.opengis.filter.v_1_1_0.ComparisonOpsType; -import net.opengis.filter.v_1_1_0.PropertyIsBetweenType; -import net.opengis.filter.v_1_1_0.PropertyIsLikeType; -import net.opengis.filter.v_1_1_0.PropertyIsNullType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class AbstractCompOp { - - protected static final Map binaryMap; - - protected Log log = LogFactory.getLog(this.getClass()); - - static { - binaryMap = new HashMap(); - binaryMap.put("PropertyIsEqualTo", new Equal()); - binaryMap.put("PropertyIsNotEqualTo", new NotEqual()); - binaryMap.put("PropertyIsLessThan", new LessThan()); - binaryMap.put("PropertyIsGreaterThan", new GreaterThan()); - binaryMap.put("PropertyIsLessThanOrEqualTo", new LessThanEqual()); - binaryMap.put("PropertyIsGreaterThanOrEqualTo", new GreaterThanEqual()); - } - - public abstract Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception; - - public static class Like extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - return visitor.isLike((PropertyIsLikeType) op.getValue(), obj); - } - } - - public static class Null extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - return visitor.isNull((PropertyIsNullType) op.getValue(), obj); - } - } - - public static class Between extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - PropertyIsBetweenType between = (PropertyIsBetweenType) op - .getValue(); - ExpressionProcessor exp = new ExpressionProcessor( - between.getExpression()); - ExpressionProcessor lower = new ExpressionProcessor(between - .getLowerBoundary().getExpression()); - ExpressionProcessor upper = new ExpressionProcessor(between - .getUpperBoundary().getExpression()); - return visitor.between(lower, exp, upper, obj); - } - } - - public static class BinaryOp extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - String name = op.getName().getLocalPart(); - AbstractCompOp compOp = binaryMap.get(name); - if (compOp != null) { - return compOp.visit(op, visitor, obj); - } else { - throw new Exception("Unknown binary operator: " + name); - } - } - } - - public static class Equal extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryComparisonOpType binary = (BinaryComparisonOpType) op - .getValue(); - List> expressions = binary.getExpression(); - return visitor.equal(new ExpressionProcessor(expressions.get(0)), - new ExpressionProcessor(expressions.get(1)), - binary.isMatchCase(), obj); - } - } - - public static class NotEqual extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryComparisonOpType binary = (BinaryComparisonOpType) op - .getValue(); - List> expressions = binary.getExpression(); - return visitor.notEqual( - new ExpressionProcessor(expressions.get(0)), - new ExpressionProcessor(expressions.get(1)), - binary.isMatchCase(), obj); - } - } - - public static class LessThan extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryComparisonOpType binary = (BinaryComparisonOpType) op - .getValue(); - List> expressions = binary.getExpression(); - return visitor.lessThan( - new ExpressionProcessor(expressions.get(0)), - new ExpressionProcessor(expressions.get(1)), - binary.isMatchCase(), obj); - } - } - - public static class GreaterThan extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryComparisonOpType binary = (BinaryComparisonOpType) op - .getValue(); - List> expressions = binary.getExpression(); - return visitor.greaterThan( - new ExpressionProcessor(expressions.get(0)), - new ExpressionProcessor(expressions.get(1)), - binary.isMatchCase(), obj); - } - } - - public static class LessThanEqual extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryComparisonOpType binary = (BinaryComparisonOpType) op - .getValue(); - List> expressions = binary.getExpression(); - return visitor.lessThanEqual( - new ExpressionProcessor(expressions.get(0)), - new ExpressionProcessor(expressions.get(1)), - binary.isMatchCase(), obj); - } - } - - public static class GreaterThanEqual extends AbstractCompOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryComparisonOpType binary = (BinaryComparisonOpType) op - .getValue(); - List> expressions = binary.getExpression(); - return visitor.greaterThanEqual( - new ExpressionProcessor(expressions.get(0)), - new ExpressionProcessor(expressions.get(1)), - binary.isMatchCase(), obj); - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractLogicOp.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractLogicOp.java deleted file mode 100644 index ff5885d432..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractLogicOp.java +++ /dev/null @@ -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 - * - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Apr 21, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBElement; - -import net.opengis.filter.v_1_1_0.BinaryLogicOpType; -import net.opengis.filter.v_1_1_0.ComparisonOpsType; -import net.opengis.filter.v_1_1_0.FilterType; -import net.opengis.filter.v_1_1_0.LogicOpsType; -import net.opengis.filter.v_1_1_0.SpatialOpsType; -import net.opengis.filter.v_1_1_0.UnaryLogicOpType; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class AbstractLogicOp { - - public abstract Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception; - - protected Map, List>> sortByType( - List> elements) { - Map, List>> rval = new HashMap, List>>(); - for (JAXBElement e : elements) { - List> list = rval.get(e.getDeclaredType()); - if (list == null) { - list = new ArrayList>(); - rval.put(e.getDeclaredType(), list); - } - list.add(e); - } - return rval; - } - - @SuppressWarnings("unchecked") - protected List getProcessors(List> elements) - throws Exception { - List rval = new ArrayList( - elements.size()); - for (JAXBElement e : elements) { - Class type = e.getDeclaredType(); - FilterProcessor p; - // FIXME this is slow - if (ComparisonOpsType.class.isAssignableFrom(type)) { - p = FilterProcessor - .newFromComparison((JAXBElement) e); - } else if (LogicOpsType.class.isAssignableFrom(type)) { - p = FilterProcessor - .newFromLogic((JAXBElement) e); - } else if (SpatialOpsType.class.isAssignableFrom(type)) { - p = FilterProcessor - .newFromSpatial((JAXBElement) e); - } else { - throw new Exception("Unknown operator: " + type); - } - rval.add(p); - } - return rval; - } - - protected FilterType createFilter( - JAXBElement comps, - JAXBElement spats, - JAXBElement logic) { - FilterType rval = new FilterType(); - rval.setComparisonOps(comps); - rval.setLogicOps(logic); - rval.setSpatialOps(spats); - return rval; - } - - public static class And extends AbstractLogicOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryLogicOpType and = (BinaryLogicOpType) op.getValue(); - List> gah = and - .getComparisonOpsOrSpatialOpsOrLogicOps(); - List processors = getProcessors(gah); - return visitor.and(processors, obj); - } - } - - public static class Or extends AbstractLogicOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinaryLogicOpType or = (BinaryLogicOpType) op.getValue(); - List> gah = or - .getComparisonOpsOrSpatialOpsOrLogicOps(); - List processors = getProcessors(gah); - return visitor.or(processors, obj); - } - } - - public static class Not extends AbstractLogicOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - UnaryLogicOpType not = (UnaryLogicOpType) op.getValue(); - JAXBElement comps = not - .getComparisonOps(); - JAXBElement spats = not.getSpatialOps(); - JAXBElement logics = not.getLogicOps(); - FilterType filter = createFilter(comps, spats, logics); - return visitor.not(new FilterProcessor(filter), obj); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractSpatialOp.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractSpatialOp.java deleted file mode 100644 index 3f5e1ff542..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/AbstractSpatialOp.java +++ /dev/null @@ -1,148 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 21, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import javax.xml.bind.JAXBElement; - -import net.opengis.filter.v_1_1_0.BBOXType; -import net.opengis.filter.v_1_1_0.BinarySpatialOpType; -import net.opengis.filter.v_1_1_0.DistanceBufferType; -import net.opengis.filter.v_1_1_0.SpatialOpsType; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class AbstractSpatialOp { - - public abstract Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception; - - public static class SpatialEquals extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.spatialEquals(binary, obj); - } - } - - public static class Disjoint extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.disjoint(binary, obj); - } - } - - public static class Touches extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.touches(binary, obj); - } - } - - public static class Within extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.within(binary, obj); - } - } - - public static class Overlaps extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.overlaps(binary, obj); - } - } - - public static class Crosses extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.crosses(binary, obj); - } - } - - public static class Intersects extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.intersects(binary, obj); - } - } - - public static class Contains extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BinarySpatialOpType binary = (BinarySpatialOpType) op.getValue(); - return visitor.contains(binary, obj); - } - } - - public static class DWithin extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - DistanceBufferType dist = (DistanceBufferType) op.getValue(); - return visitor.dWithin(dist, obj); - } - } - - public static class Beyond extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - DistanceBufferType dist = (DistanceBufferType) op.getValue(); - return visitor.beyond(dist, obj); - } - } - - public static class Bbox extends AbstractSpatialOp { - @Override - public Object visit(JAXBElement op, - OgcFilterVisitor visitor, Object obj) throws Exception { - BBOXType bbox = (BBOXType) op.getValue(); - return visitor.bbox(bbox, obj); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/ExpressionProcessor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/ExpressionProcessor.java deleted file mode 100644 index f0a89769bd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/ExpressionProcessor.java +++ /dev/null @@ -1,74 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 21, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBElement; - -/** - * - * @author bclement - * @version 1.0 - */ -public class ExpressionProcessor { - - protected static final Map expressionMap; - static { - expressionMap = new HashMap(); - expressionMap.put("Literal", new AbsExpressionOp.Literal()); - expressionMap.put("Add", new AbsExpressionOp.Add()); - expressionMap.put("Sub", new AbsExpressionOp.Sub()); - expressionMap.put("Mul", new AbsExpressionOp.Mul()); - expressionMap.put("Div", new AbsExpressionOp.Div()); - expressionMap.put("Function", new AbsExpressionOp.Function()); - expressionMap.put("PropertyName", new AbsExpressionOp.Property()); - } - - JAXBElement expression; - - /** - * @param expression - */ - public ExpressionProcessor(JAXBElement expression) { - super(); - this.expression = expression; - } - - public Object accept(OgcExpressionVisitor visitor, Object obj) - throws Exception { - AbsExpressionOp op = expressionMap.get(expression.getName() - .getLocalPart()); - return op.visit(expression, visitor, obj); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/FilterProcessor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/FilterProcessor.java deleted file mode 100644 index 7df76e00d5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/FilterProcessor.java +++ /dev/null @@ -1,140 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 20, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBElement; - -import net.opengis.filter.v_1_1_0.BinaryComparisonOpType; -import net.opengis.filter.v_1_1_0.ComparisonOpsType; -import net.opengis.filter.v_1_1_0.FilterType; -import net.opengis.filter.v_1_1_0.LogicOpsType; -import net.opengis.filter.v_1_1_0.PropertyIsBetweenType; -import net.opengis.filter.v_1_1_0.PropertyIsLikeType; -import net.opengis.filter.v_1_1_0.PropertyIsNullType; -import net.opengis.filter.v_1_1_0.SpatialOpsType; - -import com.raytheon.uf.edex.wfs.filter.AbstractCompOp.BinaryOp; - -/** - * - * @author bclement - * @version 1.0 - */ -public class FilterProcessor { - - protected static final Map, AbstractCompOp> compMap; - static { - compMap = new HashMap, AbstractCompOp>(); - compMap.put(BinaryComparisonOpType.class, new BinaryOp()); - compMap.put(PropertyIsLikeType.class, new AbstractCompOp.Like()); - compMap.put(PropertyIsNullType.class, new AbstractCompOp.Null()); - compMap.put(PropertyIsBetweenType.class, new AbstractCompOp.Between()); - } - - protected static final Map logicMap; - static { - logicMap = new HashMap(); - logicMap.put("And", new AbstractLogicOp.And()); - logicMap.put("Or", new AbstractLogicOp.Or()); - logicMap.put("Not", new AbstractLogicOp.Not()); - } - - protected static final Map spatialMap; - static { - spatialMap = new HashMap(); - spatialMap.put("Equals", new AbstractSpatialOp.SpatialEquals()); - spatialMap.put("Disjoint", new AbstractSpatialOp.Disjoint()); - spatialMap.put("Touches", new AbstractSpatialOp.Touches()); - spatialMap.put("Within", new AbstractSpatialOp.Within()); - spatialMap.put("Overlaps", new AbstractSpatialOp.Overlaps()); - spatialMap.put("Crosses", new AbstractSpatialOp.Crosses()); - spatialMap.put("Intersects", new AbstractSpatialOp.Intersects()); - spatialMap.put("Contains", new AbstractSpatialOp.Contains()); - spatialMap.put("DWithin", new AbstractSpatialOp.DWithin()); - spatialMap.put("Beyond", new AbstractSpatialOp.Beyond()); - spatialMap.put("BBOX", new AbstractSpatialOp.Bbox()); - } - - protected FilterType filter; - - public FilterProcessor(FilterType filter) { - this.filter = filter; - } - - public static FilterProcessor newFromLogic( - JAXBElement ops) { - FilterType f = new FilterType(); - f.setLogicOps(ops); - return new FilterProcessor(f); - } - - public static FilterProcessor newFromComparison( - JAXBElement ops) { - FilterType f = new FilterType(); - f.setComparisonOps(ops); - return new FilterProcessor(f); - } - - public static FilterProcessor newFromSpatial( - JAXBElement ops) { - FilterType f = new FilterType(); - f.setSpatialOps(ops); - return new FilterProcessor(f); - } - - public Object accept(OgcFilterVisitor visitor, Object obj) throws Exception { - JAXBElement comps = filter - .getComparisonOps(); - JAXBElement logics = filter.getLogicOps(); - JAXBElement spats = filter.getSpatialOps(); - Object rval; - if (logics != null && !logics.isNil()) { - String name = logics.getName().getLocalPart(); - AbstractLogicOp op = logicMap.get(name); - rval = op.visit(logics, visitor, obj); - } else if (comps != null && !comps.isNil()) { - Class type = comps.getDeclaredType(); - AbstractCompOp op = compMap.get(type); - rval = op.visit(comps, visitor, obj); - } else if (spats != null && !spats.isNil()) { - String name = spats.getName().getLocalPart(); - AbstractSpatialOp op = spatialMap.get(name); - rval = op.visit(spats, visitor, obj); - } else { - rval = null; - } - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/OgcExpressionVisitor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/OgcExpressionVisitor.java deleted file mode 100644 index 01c22935ea..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/OgcExpressionVisitor.java +++ /dev/null @@ -1,62 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 21, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.List; - -import net.opengis.filter.v_1_1_0.PropertyNameType; - -/** - * - * @author bclement - * @version 1.0 - */ -public interface OgcExpressionVisitor { - - public Object add(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception; - - public Object sub(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception; - - public Object mul(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception; - - public Object div(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception; - - public Object literal(List values, Object obj) throws Exception; - - public Object property(PropertyNameType prop, Object obj) throws Exception; - - public Object function(List expressions, String name, - Object obj) throws Exception; -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/OgcFilterVisitor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/OgcFilterVisitor.java deleted file mode 100644 index dee1a6b191..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/filter/OgcFilterVisitor.java +++ /dev/null @@ -1,114 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 20, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.filter; - -import java.util.List; - -import net.opengis.filter.v_1_1_0.BBOXType; -import net.opengis.filter.v_1_1_0.BinarySpatialOpType; -import net.opengis.filter.v_1_1_0.DistanceBufferType; -import net.opengis.filter.v_1_1_0.PropertyIsLikeType; -import net.opengis.filter.v_1_1_0.PropertyIsNullType; - -/** - * - * @author bclement - * @version 1.0 - */ -public interface OgcFilterVisitor { - - // comparison - - public Object equal(ExpressionProcessor left, ExpressionProcessor right, - boolean matchCase, Object obj) throws Exception; - - public Object notEqual(ExpressionProcessor left, ExpressionProcessor right, - boolean matchCase, Object obj) throws Exception; - - public Object lessThan(ExpressionProcessor left, ExpressionProcessor right, - boolean matchCase, Object obj) throws Exception; - - public Object greaterThan(ExpressionProcessor left, - ExpressionProcessor right, boolean matchCase, Object obj) - throws Exception; - - public Object greaterThanEqual(ExpressionProcessor left, - ExpressionProcessor right, boolean matchCase, Object obj) - throws Exception; - - public Object lessThanEqual(ExpressionProcessor left, - ExpressionProcessor right, boolean matchCase, Object obj) - throws Exception; - - public Object isLike(PropertyIsLikeType op, Object obj) throws Exception; - - public Object isNull(PropertyIsNullType op, Object obj) throws Exception; - - public Object between(ExpressionProcessor lower, ExpressionProcessor exp, - ExpressionProcessor upper, Object obj) throws Exception; - - // logic - - public Object and(List filters, Object obj) - throws Exception; - - public Object or(List filters, Object obj) - throws Exception; - - public Object not(FilterProcessor filter, Object obj) throws Exception; - - // spatial - - public Object spatialEquals(BinarySpatialOpType op, Object obj) - throws Exception; - - public Object disjoint(BinarySpatialOpType op, Object obj) throws Exception; - - public Object touches(BinarySpatialOpType op, Object obj) throws Exception; - - public Object within(BinarySpatialOpType op, Object obj) throws Exception; - - public Object overlaps(BinarySpatialOpType op, Object obj) throws Exception; - - public Object crosses(BinarySpatialOpType op, Object obj) throws Exception; - - public Object intersects(BinarySpatialOpType op, Object obj) - throws Exception; - - public Object contains(BinarySpatialOpType op, Object obj) throws Exception; - - public Object dWithin(DistanceBufferType op, Object obj) throws Exception; - - public Object beyond(DistanceBufferType op, Object obj) throws Exception; - - public Object bbox(BBOXType op, Object obj) throws Exception; - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/EnvelopeConverter.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/EnvelopeConverter.java deleted file mode 100644 index 921f31fd6c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/EnvelopeConverter.java +++ /dev/null @@ -1,134 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 26, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.gml; - -import java.util.Arrays; -import java.util.List; - -import net.opengis.gml.v_3_1_1.CoordType; -import net.opengis.gml.v_3_1_1.CoordinatesType; -import net.opengis.gml.v_3_1_1.DirectPositionType; -import net.opengis.gml.v_3_1_1.EnvelopeType; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Envelope; - -/** - * - * @author bclement - * @version 1.0 - */ -public class EnvelopeConverter { - - public Envelope convert(EnvelopeType env) throws Exception { - DirectPositionType lower = env.getLowerCorner(); - DirectPositionType upper = env.getUpperCorner(); - if (lower == null || upper == null) { - return handleDeprecated(env); - } - return translate(lower, upper); - } - - protected Envelope translate(DirectPositionType lower, - DirectPositionType upper) throws Exception { - List lowers = lower.getValue(); - List uppers = upper.getValue(); - if (lowers == null || uppers == null || lowers.size() != 2 - || uppers.size() != 2) { - throw new Exception("Unsupported envelope format"); - } - Coordinate l = new Coordinate(lowers.get(0), lowers.get(1)); - Coordinate u = new Coordinate(uppers.get(0), uppers.get(1)); - return new Envelope(l, u); - } - - protected Envelope handleDeprecated(EnvelopeType env) throws Exception { - List coord = env.getCoord(); - List pos = env.getPos(); - CoordinatesType coordinates = env.getCoordinates(); - DirectPositionType lower; - DirectPositionType upper; - if (coord != null && coord.size() == 2) { - CoordType c0 = coord.get(0); - CoordType c1 = coord.get(1); - lower = createPos(c0); - upper = createPos(c1); - } else if (pos != null && pos.size() == 2) { - lower = pos.get(0); - upper = pos.get(1); - } else if (coordinates != null) { - String value = coordinates.getValue(); - String[] parts = value.trim().split("\\s"); - lower = createPos(parts[0]); - upper = createPos(parts[1]); - } else { - throw new Exception("Unsupported envelope format"); - } - return translate(lower, upper); - } - - /** - * @param string - * @return - */ - private DirectPositionType createPos(String string) { - return createPos(string.split(",")); - } - - protected DirectPositionType createPos(String[] doubles) { - Double[] rval = new Double[doubles.length]; - for (int i = 0; i < doubles.length; ++i) { - rval[i] = Double.parseDouble(doubles[i]); - } - return createPos(rval); - } - - protected DirectPositionType createPos(CoordType coord) throws Exception { - Double[] rval; - if (coord.isSetZ()) { - rval = new Double[] { coord.getX().doubleValue(), - coord.getY().doubleValue(), coord.getZ().doubleValue() }; - } else if (coord.isSetY()) { - rval = new Double[] { coord.getX().doubleValue(), - coord.getY().doubleValue() }; - } else { - rval = new Double[] { coord.getX().doubleValue() }; - } - return createPos(rval); - } - - protected DirectPositionType createPos(Double... coords) { - DirectPositionType rval = new DirectPositionType(); - rval.setValue(Arrays.asList(coords)); - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/GeometryConverter.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/GeometryConverter.java deleted file mode 100644 index 46f07599a9..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/GeometryConverter.java +++ /dev/null @@ -1,62 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 25, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.gml; - -import net.opengis.gml.v_3_1_1.AbstractGeometryType; - -import org.geotools.geometry.jts.JTS; -import org.jvnet.jaxb2_commons.locator.DefaultRootObjectLocator; -import org.jvnet.ogc.gml.v_3_1_1.jts.ConversionFailedException; -import org.jvnet.ogc.gml.v_3_1_1.jts.GML311ToJTSGeometryConverter; - -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.io.ParseException; - -/** - * - * @author bclement - * @version 1.0 - */ -public class GeometryConverter { - - public Geometry convert(Envelope env) throws ParseException { - return JTS.toGeometry(env); - } - - public Geometry convert(AbstractGeometryType value) - throws ConversionFailedException { - GML311ToJTSGeometryConverter converter = new GML311ToJTSGeometryConverter(); - return converter.createGeometry(new DefaultRootObjectLocator(value), - value); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/GmlWktWriter.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/GmlWktWriter.java deleted file mode 100644 index dd8df6255b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/gml/GmlWktWriter.java +++ /dev/null @@ -1,401 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 25, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.gml; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBElement; - -import net.opengis.gml.v_3_1_1.AbstractCurveType; -import net.opengis.gml.v_3_1_1.AbstractGeometryType; -import net.opengis.gml.v_3_1_1.AbstractRingPropertyType; -import net.opengis.gml.v_3_1_1.AbstractRingType; -import net.opengis.gml.v_3_1_1.CoordType; -import net.opengis.gml.v_3_1_1.CurvePropertyType; -import net.opengis.gml.v_3_1_1.DirectPositionListType; -import net.opengis.gml.v_3_1_1.DirectPositionType; -import net.opengis.gml.v_3_1_1.LineStringPropertyType; -import net.opengis.gml.v_3_1_1.LineStringType; -import net.opengis.gml.v_3_1_1.LinearRingType; -import net.opengis.gml.v_3_1_1.MultiLineStringType; -import net.opengis.gml.v_3_1_1.MultiPointType; -import net.opengis.gml.v_3_1_1.MultiPolygonType; -import net.opengis.gml.v_3_1_1.PointArrayPropertyType; -import net.opengis.gml.v_3_1_1.PointPropertyType; -import net.opengis.gml.v_3_1_1.PointType; -import net.opengis.gml.v_3_1_1.PolygonPropertyType; -import net.opengis.gml.v_3_1_1.PolygonType; -import net.opengis.gml.v_3_1_1.RingType; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class GmlWktWriter { - - protected static final Map, GmlWktWriter> geomMap; - static { - geomMap = new HashMap, GmlWktWriter>(); - geomMap.put(PolygonType.class, new Polygon()); - geomMap.put(MultiPolygonType.class, new MultiPolygon()); - geomMap.put(PointType.class, new Point()); - geomMap.put(MultiPointType.class, new MultiPoint()); - geomMap.put(LinearRingType.class, new LinearRing()); - geomMap.put(LineStringType.class, new LineString()); - geomMap.put(MultiLineStringType.class, new MultiLineString()); - } - - public abstract String write(AbstractGeometryType geom) throws Exception; - - public static String write(JAXBElement elem) - throws Exception { - GmlWktWriter writer = geomMap.get(elem.getDeclaredType()); - if (writer != null) { - return writer.write(elem.getValue()); - } else { - throw new Exception("Unsupported geometry type: " - + elem.getDeclaredType()); - } - } - - protected void addPolygon(PolygonType poly, StringBuilder sb) - throws Exception { - sb.append('('); - AbstractRingPropertyType value = poly.getExterior().getValue(); - AbstractRingType ring = value.getRing().getValue(); - addAbstractRing(ring, sb); - List> interior = poly - .getInterior(); - if (interior != null && !interior.isEmpty()) { - sb.append(','); - addInterior(interior, sb); - } - sb.append(')'); - } - - /** - * @param interior - * @param sb - * @throws Exception - */ - protected void addInterior( - List> interior, - StringBuilder sb) throws Exception { - Iterator> i = interior.iterator(); - sb.append('('); - addAbstractRing(i.next().getValue().getRing().getValue(), sb); - while (i.hasNext()) { - sb.append(','); - addAbstractRing(i.next().getValue().getRing().getValue(), sb); - } - } - - protected void addAbstractRing(AbstractRingType ring, StringBuilder sb) - throws Exception { - if (ring instanceof LinearRingType) { - addLinearRing((LinearRingType) ring, sb); - } else if (ring instanceof RingType) { - addRing((RingType) ring, sb); - } else { - throw new Exception("Unsupported ring type" + ring.getClass()); - } - } - - /** - * @param ring - * @param sb - * @throws Exception - */ - private void addRing(RingType ring, StringBuilder sb) throws Exception { - List curvProps = ring.getCurveMember(); - Iterator i = curvProps.iterator(); - AbstractCurveType curve = i.next().getCurve().getValue(); - if (curve instanceof LineStringType) { - addLineString((LineStringType) curve, sb); - } else { - throw new Exception("Unsupported curve type: " + curve.getClass()); - } - } - - /** - * @param ring - * @param sb - * @throws Exception - */ - private void addLinearRing(LinearRingType ring, StringBuilder sb) - throws Exception { - DirectPositionListType posList = ring.getPosList(); - List coord = ring.getCoord(); - List> elems = ring.getPosOrPointPropertyOrPointRep(); - addLine(posList, elems, coord, sb); - } - - protected void addLine(DirectPositionListType posList, - List> elems, List coord, StringBuilder sb) - throws Exception { - sb.append("("); - if (posList != null) { - addPosList(posList, sb); - } else if (elems != null) { - addMixedPos(elems, sb); - } else if (coord != null) { - addCoords(coord, sb); - } else { - throw new Exception("Unsupported LineString format"); - } - sb.append(")"); - } - - /** - * @param coord - * @param sb - */ - protected void addCoords(List coord, StringBuilder sb) { - Iterator i = coord.iterator(); - addPoint(convert(i.next()), sb); - while (i.hasNext()) { - sb.append(", "); - addPoint(convert(i.next()), sb); - } - } - - protected void addLineString(LineStringType lst, StringBuilder sb) - throws Exception { - DirectPositionListType posList = lst.getPosList(); - List> elems = lst.getPosOrPointPropertyOrPointRep(); - addLine(posList, elems, null, sb); - } - - protected void addMixedPos(List> elems, StringBuilder sb) - throws Exception { - Iterator> i = elems.iterator(); - while (i.hasNext()) { - JAXBElement elem = i.next(); - Object value = elem.getValue(); - List point = null; - if (value instanceof DirectPositionType) { - DirectPositionType pos = (DirectPositionType) value; - point = pos.getValue(); - } else if (value instanceof PointPropertyType) { - PointPropertyType pointProp = (PointPropertyType) value; - DirectPositionType pos = pointProp.getPoint().getPos(); - CoordType coord = pointProp.getPoint().getCoord(); - if (pos != null) { - point = pos.getValue(); - } else if (coord != null) { - point = convert(coord); - } - } - if (point == null) { - throw new Exception("Unsupported position type: " - + value.getClass()); - } - addPoint(point, sb); - if (i.hasNext()) { - sb.append(", "); - } - } - } - - public void addPointPropList(List pointProps, - StringBuilder sb) throws Exception { - Iterator i = pointProps.iterator(); - addPoint(i.next().getPoint(), sb); - while (i.hasNext()) { - sb.append(' '); - addPoint(i.next().getPoint(), sb); - } - } - - public void addPointList(List point, StringBuilder sb) - throws Exception { - Iterator i = point.iterator(); - addPoint(i.next(), sb); - while (i.hasNext()) { - sb.append(' '); - addPoint(i.next(), sb); - } - } - - protected void addPoint(PointType point, StringBuilder sb) throws Exception { - DirectPositionType pos = point.getPos(); - CoordType coord = point.getCoord(); - if (pos != null) { - addPoint(pos.getValue(), sb); - } else if (coord != null) { - addPoint(convert(coord), sb); - } else { - throw new Exception("Unsupported point format"); - } - } - - protected void addPoint(List point, StringBuilder sb) { - Iterator j = point.iterator(); - sb.append(j.next()); - while (j.hasNext()) { - sb.append(" "); - sb.append(j.next()); - } - } - - protected List convert(CoordType coord) { - ArrayList rval = new ArrayList(3); - rval.add(coord.getX().doubleValue()); - BigDecimal y = coord.getY(); - BigDecimal z = coord.getZ(); - if (y != null) { - rval.add(y.doubleValue()); - if (z != null) { - rval.add(z.doubleValue()); - } - } - return rval; - } - - protected void addPosList(DirectPositionListType poslist, StringBuilder sb) - throws Exception { - int dim = poslist.getSrsDimension().intValue(); - List value = poslist.getValue(); - if (dim < 2 || value.size() % dim != 0) { - throw new Exception("Invalid dimensions for position list"); - } - Iterator i = value.iterator(); - while (i.hasNext()) { - sb.append(i.next()); - for (int j = 0; j < dim; ++j) { - sb.append(" "); - sb.append(i.next()); - } - if (i.hasNext()) { - sb.append(", "); - } - } - } - - public static class LineString extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - LineStringType lst = (LineStringType) geom; - StringBuilder sb = new StringBuilder("LINESTRING "); - addLineString(lst, sb); - return sb.toString(); - } - } - - public static class MultiLineString extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - MultiLineStringType mlst = (MultiLineStringType) geom; - StringBuilder sb = new StringBuilder("MULTILINESTRING ("); - Iterator i = mlst.getLineStringMember() - .iterator(); - addLineString(i.next().getLineString(), sb); - while (i.hasNext()) { - sb.append(','); - addLineString(i.next().getLineString(), sb); - } - sb.append(')'); - return sb.toString(); - } - } - - public static class Point extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - PointType p = (PointType) geom; - StringBuilder sb = new StringBuilder("POINT ("); - addPoint(p, sb); - sb.append(')'); - return sb.toString(); - } - } - - public static class MultiPoint extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - MultiPointType mult = (MultiPointType) geom; - StringBuilder sb = new StringBuilder("MULTIPOINT ("); - List pointProps = mult.getPointMember(); - PointArrayPropertyType array = mult.getPointMembers(); - if (pointProps != null) { - addPointPropList(pointProps, sb); - } - if (array != null) { - addPointList(array.getPoint(), sb); - } - sb.append(')'); - return sb.toString(); - } - } - - public static class Polygon extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - PolygonType poly = (PolygonType) geom; - StringBuilder sb = new StringBuilder("POLYGON "); - addPolygon(poly, sb); - return sb.toString(); - } - } - - public static class MultiPolygon extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - MultiPolygonType poly = (MultiPolygonType) geom; - StringBuilder sb = new StringBuilder("MULTIPOLYGON ("); - List value = poly.getPolygonMember(); - Iterator i = value.iterator(); - addPolygon(i.next().getPolygon(), sb); - while (i.hasNext()) { - sb.append(','); - addPolygon(i.next().getPolygon(), sb); - } - sb.append(')'); - return sb.toString(); - } - } - - public static class LinearRing extends GmlWktWriter { - @Override - public String write(AbstractGeometryType geom) throws Exception { - LinearRingType ring = (LinearRingType) geom; - StringBuilder sb = new StringBuilder("LINEARRING "); - addAbstractRing(ring, sb); - return sb.toString(); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/Capabilities.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/Capabilities.java deleted file mode 100644 index 85187d40ed..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/Capabilities.java +++ /dev/null @@ -1,380 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 29, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; - -import net.opengis.filter.v_1_1_0.ArithmeticOperatorsType; -import net.opengis.filter.v_1_1_0.ComparisonOperatorType; -import net.opengis.filter.v_1_1_0.ComparisonOperatorsType; -import net.opengis.filter.v_1_1_0.FilterCapabilities; -import net.opengis.filter.v_1_1_0.GeometryOperandsType; -import net.opengis.filter.v_1_1_0.IdCapabilitiesType; -import net.opengis.filter.v_1_1_0.LogicalOperators; -import net.opengis.filter.v_1_1_0.ScalarCapabilitiesType; -import net.opengis.filter.v_1_1_0.SpatialCapabilitiesType; -import net.opengis.filter.v_1_1_0.SpatialOperatorNameType; -import net.opengis.filter.v_1_1_0.SpatialOperatorType; -import net.opengis.filter.v_1_1_0.SpatialOperatorsType; -import net.opengis.ows.v_1_0_0.CodeType; -import net.opengis.ows.v_1_0_0.DCP; -import net.opengis.ows.v_1_0_0.DomainType; -import net.opengis.ows.v_1_0_0.HTTP; -import net.opengis.ows.v_1_0_0.Operation; -import net.opengis.ows.v_1_0_0.OperationsMetadata; -import net.opengis.ows.v_1_0_0.RequestMethodType; -import net.opengis.ows.v_1_0_0.ServiceIdentification; -import net.opengis.wfs.v_1_1_0.FeatureTypeListType; -import net.opengis.wfs.v_1_1_0.FeatureTypeType; -import net.opengis.wfs.v_1_1_0.GMLObjectTypeListType; -import net.opengis.wfs.v_1_1_0.GMLObjectTypeType; -import net.opengis.wfs.v_1_1_0.OutputFormatListType; -import net.opengis.wfs.v_1_1_0.WFSCapabilitiesType; - -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsProvider.WfsOpType; -import com.raytheon.uf.edex.wfs.reg.WfsRegistryImpl; -import com.raytheon.uf.edex.wfs.request.GetCapReq; - -/** - * - * @author bclement - * @version 1.0 - */ -public class Capabilities { - - protected String SERV_TYPE = "WFS"; - - protected String SERV_TITLE = "EDEX WFS"; - - protected String OWS_NS = OgcNamespace.OWS; - - protected String GML_NS = OgcNamespace.GML; - - protected String OGC_NS = OgcNamespace.OGC; - - protected String WFS_NS = OgcNamespace.WFS; - - protected String GML_MIME = "text/xml; subtype=gml/3.1.1"; - - protected String[] gmlObjects = { "AbstractFeatureType", "PointType", - "LineStringType", "PolygonType", "MultiPointType" }; - - protected String[] geometryOperands = { "Envelope", "Point", "LineString", - "Polygon" }; - - protected SpatialOperatorNameType[] spatialOperators = { - SpatialOperatorNameType.BBOX, SpatialOperatorNameType.EQUALS }; - - protected ComparisonOperatorType[] comparisonOperators = { - ComparisonOperatorType.LESS_THAN, - ComparisonOperatorType.GREATER_THAN, - ComparisonOperatorType.LESS_THAN_EQUAL_TO, - ComparisonOperatorType.GREATER_THAN_EQUAL_TO, - ComparisonOperatorType.EQUAL_TO, - ComparisonOperatorType.NOT_EQUAL_TO }; - - protected String[] logicOperators = { "And" }; - - protected FeatureTranslator translator = new FeatureTranslator(); - - protected WfsRegistryImpl registry; - - public Capabilities(WfsRegistryImpl registry) { - this.registry = registry; - } - - public WFSCapabilitiesType getCapabilities(GetCapReq request, - OgcServiceInfo serviceinfo) throws WfsException { - WFSCapabilitiesType cap = new WFSCapabilitiesType(); - cap.setServiceIdentification(getServiceId(serviceinfo)); - cap.setOperationsMetadata(getOpData(serviceinfo)); - cap.setFeatureTypeList(getFeatureTypes(request, serviceinfo)); - cap.setServesGMLObjectTypeList(getServesGML()); - cap.setSupportsGMLObjectTypeList(getSupportsGML()); - cap.setFilterCapabilities(getFilterCap()); - return cap; - } - - /** - * @param serviceinfo - * @return - */ - protected OperationsMetadata getOpData(OgcServiceInfo serviceinfo) { - OperationsMetadata rval = new OperationsMetadata(); - List operations = new LinkedList(); - for (OgcOperationInfo op : serviceinfo.getOperations()) { - Operation to = new Operation(); - to.setName(op.getType().toString()); - to.setDCP(getDcpList(op)); - to.setParameter(getOpParams(op)); - operations.add(to); - } - rval.setOperation(operations); - rval.setParameter(getParams(serviceinfo)); - // may want to do constraints as well - return rval; - } - - /** - * @param op - * @return - */ - private List getOpParams(OgcOperationInfo op) { - return Arrays.asList( - getAsDomainType("AcceptVersions", op.getVersions()), - getAsDomainType("AcceptFormats", op.getFormats())); - } - - /** - * @param op - * @return - */ - protected List getDcpList(OgcOperationInfo op) { - List rval = new LinkedList(); - DCP dcp = new DCP(); - HTTP http = new HTTP(); - List> value = new LinkedList>(); - if (op.hasHttpGet()) { - value.add(getRequestType("Get", op.getHttpGetRes())); - } - if (op.hasHttpPost()) { - value.add(getRequestType("Post", op.getHttpPostRes())); - } - http.setGetOrPost(value); - dcp.setHTTP(http); - rval.add(dcp); - return rval; - } - - protected JAXBElement getRequestType(String name, - String value) { - JAXBElement rval = new JAXBElement( - new QName(OWS_NS, name), RequestMethodType.class, - new RequestMethodType()); - rval.getValue().setHref(value); - return rval; - } - - protected DomainType getAsDomainType(String name, Collection values) { - DomainType rval = new DomainType(); - rval.setName(name); - List toVals = new ArrayList(values.size()); - for (String val : values) { - toVals.add(val); - } - rval.setValue(toVals); - return rval; - } - - /** - * @param serviceinfo - * @return - */ - protected List getParams(OgcServiceInfo serviceinfo) { - // TODO this info should be passed in from somewhere - return Arrays.asList(getAsDomainType("srsName", - Arrays.asList("EPSG:4326"))); - } - - /** - * @return - */ - protected FilterCapabilities getFilterCap() { - FilterCapabilities rval = new FilterCapabilities(); - rval.setScalarCapabilities(getScalarCapabilities()); - rval.setSpatialCapabilities(getSpatialCapabilities()); - rval.setIdCapabilities(getIdCapabilities()); - return rval; - } - - /** - * @return - */ - protected IdCapabilitiesType getIdCapabilities() { - // TODO Auto-generated method stub - return null; - } - - /** - * @return - */ - protected SpatialCapabilitiesType getSpatialCapabilities() { - SpatialCapabilitiesType rval = new SpatialCapabilitiesType(); - rval.setGeometryOperands(getGeometryOperands()); - rval.setSpatialOperators(getSpatialOperators()); - return rval; - } - - /** - * @return - */ - protected SpatialOperatorsType getSpatialOperators() { - SpatialOperatorsType rval = new SpatialOperatorsType(); - List ops = new ArrayList( - spatialOperators.length); - for (SpatialOperatorNameType name : spatialOperators) { - SpatialOperatorType op = new SpatialOperatorType(); - op.setName(name); - ops.add(op); - } - rval.setSpatialOperator(ops); - return rval; - } - - /** - * @return - */ - protected GeometryOperandsType getGeometryOperands() { - GeometryOperandsType rval = new GeometryOperandsType(); - List ops = new ArrayList(geometryOperands.length); - for (String op : geometryOperands) { - QName name = new QName(OgcNamespace.GML, op); - ops.add(name); - } - rval.setGeometryOperand(ops); - return rval; - } - - /** - * @return - */ - protected ScalarCapabilitiesType getScalarCapabilities() { - ScalarCapabilitiesType rval = new ScalarCapabilitiesType(); - rval.setArithmeticOperators(getArithmeticOperators()); - rval.setComparisonOperators(getComparisonOperators()); - rval.setLogicalOperators(GetLogicalOperators()); - return rval; - } - - /** - * @return - */ - protected LogicalOperators GetLogicalOperators() { - return null; - } - - /** - * @return - */ - protected ComparisonOperatorsType getComparisonOperators() { - ComparisonOperatorsType rval = new ComparisonOperatorsType(); - List ops = new ArrayList( - comparisonOperators.length); - for (ComparisonOperatorType op : comparisonOperators) { - ops.add(op); - } - rval.setComparisonOperator(ops); - return rval; - } - - /** - * @return - */ - protected ArithmeticOperatorsType getArithmeticOperators() { - // TODO Auto-generated method stub - return null; - } - - /** - * @return - */ - protected GMLObjectTypeListType getSupportsGML() { - GMLObjectTypeListType rval = new GMLObjectTypeListType(); - List gmlObs = new ArrayList( - gmlObjects.length); - for (String type : gmlObjects) { - gmlObs.add(getGMLObjType(type)); - } - rval.setGMLObjectType(gmlObs); - return rval; - } - - protected GMLObjectTypeType getGMLObjType(String name) { - GMLObjectTypeType rval = new GMLObjectTypeType(); - rval.setName(new QName(GML_NS, name)); - OutputFormatListType outFormats = new OutputFormatListType(); - outFormats.setFormat(Arrays.asList(GML_MIME)); - rval.setOutputFormats(outFormats); - return rval; - } - - /** - * @return - */ - protected GMLObjectTypeListType getServesGML() { - // TODO Auto-generated method stub - return null; - } - - /** - * @param request - * @param serviceinfo - * @return - * @throws WfsException - */ - protected FeatureTypeListType getFeatureTypes(GetCapReq request, - OgcServiceInfo serviceinfo) throws WfsException { - FeatureTypeListType rval = new FeatureTypeListType(); - // rval.setOperations(getOperations(serviceinfo)); - rval.setFeatureType(getFeatureTypes(request)); - return rval; - } - - protected List getFeatureTypes(GetCapReq request) - throws WfsException { - return translator.transform(registry.getFeatures()); - } - - /** - * @param serviceinfo - * @return - */ - protected ServiceIdentification getServiceId( - OgcServiceInfo serviceinfo) { - ServiceIdentification rval = new ServiceIdentification(); - CodeType ct = new CodeType(); - ct.setValue(SERV_TYPE); - rval.setServiceType(ct); - rval.setTitle(SERV_TITLE); - return rval; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java deleted file mode 100644 index 616f727b9e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureFetcher.java +++ /dev/null @@ -1,230 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 29, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; - -import net.opengis.filter.v_1_1_0.FilterType; -import net.opengis.gml.v_3_1_1.AbstractFeatureType; -import net.opengis.gml.v_3_1_1.FeaturePropertyType; -import net.opengis.wfs.v_1_1_0.FeatureCollectionType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.geotools.geometry.jts.JTS; -import org.hibernate.criterion.Criterion; -import org.hibernatespatial.criterion.SpatialRestrictions; -import org.opengis.feature.simple.SimpleFeature; - -import com.raytheon.uf.edex.ogc.common.OgcBoundingBox; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsException.Code; -import com.raytheon.uf.edex.wfs.WfsProvider.WfsOpType; -import com.raytheon.uf.edex.wfs.filter.FilterProcessor; -import com.raytheon.uf.edex.wfs.reg.WfsQuery; -import com.raytheon.uf.edex.wfs.reg.WfsRegistryImpl; -import com.raytheon.uf.edex.wfs.reg.WfsSource; -import com.raytheon.uf.edex.wfs.request.FeatureQuery; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq.ResultType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Polygon; - -/** - * - * @author bclement - * @version 1.0 - */ -public class FeatureFetcher { - - protected Log log = LogFactory.getLog(this.getClass()); - - protected WfsRegistryImpl registry; - - /** - * @param registry - */ - public FeatureFetcher(WfsRegistryImpl registry) { - this.registry = registry; - } - - public List> getSimpleFeatures(GetFeatureReq request, - OgcServiceInfo serviceinfo) throws WfsException { - List> rval = new ArrayList>(); - for (FeatureQuery q : request.getQueries()) { - for (QualifiedName type : q.getTypeNames()) { - WfsSource source = registry.getSource(type); - if (source != null) { - String spatial = source.getFeatureSpatialField(type); - VisitorBag bag = new VisitorBag( - source.getFeatureEntity(type), spatial); - bag.setFieldMap(source.getFieldMap()); - WfsQuery wfsq; - try { - wfsq = new WfsQuery(getQuery(q, bag), - request.getMaxFeatures(), q.getSortBys(), - q.getPropertyNames()); - } catch (Exception e) { - log.error("Problem parsing wfs query", e); - throw new WfsException(Code.INVALID_REQUEST, - "Invalid filter"); - } - rval.add(source.querySimple(type, wfsq)); - } else { - throw new WfsException(Code.INVALID_REQUEST, - "Unkown feature type: " + type); - } - } - } - return rval; - } - - public FeatureCollectionType getFeatures(GetFeatureReq request, - OgcServiceInfo serviceinfo) throws WfsException { - FeatureCollectionType featColl = new FeatureCollectionType(); - List members = featColl.getFeatureMember(); - long count = 0; - for (FeatureQuery q : request.getQueries()) { - for (QualifiedName type : q.getTypeNames()) { - WfsSource source = registry.getSource(type); - if (source != null) { - String spatial = source.getFeatureSpatialField(type); - VisitorBag bag = new VisitorBag( - source.getFeatureEntity(type), spatial); - bag.setFieldMap(source.getFieldMap()); - WfsQuery wfsq; - try { - wfsq = new WfsQuery(getQuery(q, bag), - request.getMaxFeatures(), q.getSortBys(), - q.getPropertyNames()); - } catch (Exception e) { - log.error("Problem parsing wfs query", e); - throw new WfsException(Code.INVALID_REQUEST, - "Invalid filter"); - } - if (request.getResulttype() == ResultType.hits) { - count += source.count(type, wfsq); - } else { - List> result = source - .query(type, wfsq); - count += populateFeatures(members, result); - } - } else { - throw new WfsException(Code.INVALID_REQUEST, - "Unkown feature type: " + type); - } - } - } - featColl.setNumberOfFeatures(new BigInteger("" + count)); - return featColl; - } - - protected long populateFeatures(List members, - List> results) { - if (results == null || results.isEmpty()) { - return 0; - } - for (JAXBElement feature : results) { - FeaturePropertyType propType = new FeaturePropertyType(); - propType.setFeature(feature); - members.add(propType); - } - return results.size(); - } - - /** - * @param q - * @param spatial - * @return - * @throws Exception - */ - protected Criterion getQuery(FeatureQuery q, VisitorBag bag) - throws Exception { - Criterion rval = null; - switch (q.getFilterType()) { - case BBOX: - OgcBoundingBox bbox = (OgcBoundingBox) q.getFilter(); - rval = getBbox(bbox.getMiny(), bbox.getMinx(), bbox.getMaxy(), - bbox.getMaxx(), bag); - break; - case FIDS: - // TODO - rval = getDefault(bag); - break; - case XML: - FilterType f = parseFilterXml((String) q.getFilter()); - rval = getFromFilter(f, bag); - break; - case XMLOBJ: - FilterType filter = (FilterType) q.getFilter(); - rval = getFromFilter(filter, bag); - break; - default: - rval = getDefault(bag); - } - return rval; - } - - protected Criterion getDefault(VisitorBag bag) { - return null; - } - - protected FilterType parseFilterXml(String xml) throws JAXBException { - return (FilterType) registry.unmarshal(xml); - } - - protected Criterion getFromFilter(FilterType filter, VisitorBag bag) - throws Exception { - if (filter != null) { - FilterProcessor proc = new FilterProcessor(filter); - return (Criterion) proc.accept(new QueryFilterVisitor(), bag); - } else { - // FIXME - return null; - } - - } - - protected Criterion getBbox(double lowerLat, double lowerLon, - double upperLat, double upperLon, VisitorBag bag) { - Polygon geom = JTS.toGeometry(new Envelope(lowerLon, upperLon, - lowerLat, lowerLat)); - return SpatialRestrictions.within(bag.getSpatialField(), geom); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureTranslator.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureTranslator.java deleted file mode 100644 index 02a0a9f4d7..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/FeatureTranslator.java +++ /dev/null @@ -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 - * - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Apr 27, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import javax.xml.namespace.QName; - -import net.opengis.ows.v_1_0_0.KeywordsType; -import net.opengis.ows.v_1_0_0.WGS84BoundingBoxType; -import net.opengis.wfs.v_1_1_0.FeatureTypeType; - -import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox; -import com.raytheon.uf.edex.wfs.WfsFeatureType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; - -/** - * - * @author bclement - * @version 1.0 - */ -public class FeatureTranslator { - - public List transform(List features) { - List rval = new ArrayList( - features.size()); - for (WfsFeatureType f : features) { - rval.add(transform(f)); - } - return rval; - } - - /** - * @param source - * @return - */ - public FeatureTypeType transform(WfsFeatureType from) { - FeatureTypeType fType = new FeatureTypeType(); - QName name = transform(from.getName()); - fType.setName(name); - fType.setTitle(from.getTitle()); - fType.setAbstract(from.getAbs()); - fType.setKeywords(getAsKeywordList(from.getKeywords())); - fType.setDefaultSRS(from.getDefaultSRS()); - fType.setOtherSRS(from.getOtherSRS()); - fType.setWGS84BoundingBox(getBBox(from.getBbox())); - return fType; - } - - protected QName transform(QualifiedName from) { - return new QName(from.getNamespace(), from.getName()); - } - - /** - * @param bbox - * @return - */ - private List getBBox(OgcGeoBoundingBox bbox) { - List rval = new LinkedList(); - WGS84BoundingBoxType to = new WGS84BoundingBoxType(); - List ur = new LinkedList(); - List ll = new LinkedList(); - ur.add(bbox.getMaxx()); - ur.add(bbox.getMaxy()); - ll.add(bbox.getMinx()); - ll.add(bbox.getMiny()); - to.setUpperCorner(ur); - to.setLowerCorner(ll); - rval.add(to); - return rval; - } - - protected List getAsKeywordList(List keywords) { - List rval = new LinkedList(); - if (keywords != null && !keywords.isEmpty()) { - KeywordsType kwType = new KeywordsType(); - kwType.setKeyword(keywords); - rval.add(kwType); - } - return rval; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/OgcWfsProvider.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/OgcWfsProvider.java deleted file mode 100644 index ef9383569a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/OgcWfsProvider.java +++ /dev/null @@ -1,416 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.xml.bind.JAXBException; - -import net.opengis.ows.v_1_0_0.ExceptionReport; -import net.opengis.ows.v_1_0_0.ExceptionType; -import net.opengis.wfs.v_1_1_0.DescribeFeatureTypeType; -import net.opengis.wfs.v_1_1_0.FeatureCollectionType; -import net.opengis.wfs.v_1_1_0.GetCapabilitiesType; -import net.opengis.wfs.v_1_1_0.GetFeatureType; -import net.opengis.wfs.v_1_1_0.ObjectFactory; -import net.opengis.wfs.v_1_1_0.TransactionResponseType; -import net.opengis.wfs.v_1_1_0.TransactionType; -import net.opengis.wfs.v_1_1_0.WFSCapabilitiesType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.opengis.feature.simple.SimpleFeature; -import org.springframework.context.ApplicationContext; - -import com.raytheon.uf.edex.core.EDEXUtil; -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcResponse.ErrorType; -import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter; -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsException.Code; -import com.raytheon.uf.edex.wfs.WfsFeatureType; -import com.raytheon.uf.edex.wfs.WfsProvider; -import com.raytheon.uf.edex.wfs.reg.WfsRegistryImpl; -import com.raytheon.uf.edex.wfs.reg.WfsSource; -import com.raytheon.uf.edex.wfs.request.DescFeatureTypeReq; -import com.raytheon.uf.edex.wfs.request.GetCapReq; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq; -import com.raytheon.uf.edex.wfs.request.GetFeatureReq.ResultType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; -import com.raytheon.uf.edex.wfs.request.TransReq; -import com.raytheon.uf.edex.wfs.request.WfsRequest; -import com.raytheon.uf.edex.wfs.request.WfsRequest.Type; - -public class OgcWfsProvider implements WfsProvider { - - protected String describeFeatureUrl; - - protected Log log = LogFactory.getLog(this.getClass()); - - protected WfsRegistryImpl registry; - - protected Capabilities capabilities; - - protected FeatureFetcher features; - - protected Transactor transactor; - - protected ObjectFactory wfsFactory = new ObjectFactory(); - - public OgcWfsProvider(WfsRegistryImpl registry) { - this.capabilities = new Capabilities(registry); - this.features = new FeatureFetcher(registry); - this.registry = registry; - this.transactor = new Transactor(); - } - - protected OgcWfsProvider() { - // unit tests - } - - @Override - public OgcResponse getError(WfsException e, String exceptionFormat) { - ExceptionType et = new ExceptionType(); - et.setExceptionCode(e.getCode().toString()); - et.setExceptionText(Arrays.asList(e.getMessage())); - ExceptionReport report = new ExceptionReport(); - report.setException(Arrays.asList(et)); - String rval = ""; - String mimeType = OgcResponse.TEXT_XML_MIME; - if (exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_XML_MIME)) { - try { - rval = registry.marshal(report); - mimeType = OgcResponse.TEXT_XML_MIME; - } catch (JAXBException e1) { - log.error("Unable to marshal WFS response", e1); - rval = ""; - rval += ""; - rval += "" + e.getMessage() - + ""; - rval += ""; - mimeType = OgcResponse.TEXT_XML_MIME; - } - } else if (exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_HTML_MIME)) { - rval = ""; - rval += "
An error occurred performing the request:
"; - rval += "
Error Code: " + e.getCode().toString(); - rval += "
Message: " + e.getMessage() + ""; - mimeType = OgcResponse.TEXT_HTML_MIME; - } - OgcResponse resp = new OgcResponse(rval, mimeType, TYPE.TEXT); - switch (e.getCode()) { - case INTERNAL_SERVER_ERROR: - resp.setError(ErrorType.INT_ERR); - break; - default: - resp.setError(ErrorType.BAD_REQ); - } - return resp; - } - - protected String getXml(InputStream in) throws IOException { - return new java.util.Scanner(in).useDelimiter("\\A").next(); - } - - @Override - public WfsRequest getRequest(InputStream in) { - Object obj; - WfsRequest rval; - String xml; - try { - xml = getXml(in); - obj = registry.unmarshal(xml); - } catch (Exception e) { - log.error("Unable to decode request", e); - return getDecodeError(OgcResponse.TEXT_XML_MIME); - } - if (obj instanceof GetCapabilitiesType) { - rval = new GetCapReq((GetCapabilitiesType) obj); - } else if (obj instanceof GetFeatureType) { - rval = new GetFeatureReq((GetFeatureType) obj); - } else if (obj instanceof DescribeFeatureTypeType) { - rval = new DescFeatureTypeReq((DescribeFeatureTypeType) obj); - } else if (obj instanceof TransactionType) { - rval = TransReq.buildTransReq((TransactionType) obj); - if (rval == null) { - rval = getDecodeError(OgcResponse.TEXT_XML_MIME); - } - } else { - rval = getDecodeError(OgcResponse.TEXT_XML_MIME); - } - if (rval.getType() != Type.ERROR) { - rval.setRawrequest(obj); - } - return rval; - } - - public WfsRequest getDecodeError(String exceptionFormat) { - OgcResponse error = getError(new WfsException(Code.INVALID_REQUEST, - "Unable to decode request"), exceptionFormat); - WfsRequest rval = new WfsRequest(Type.ERROR); - rval.setRawrequest(error); - return rval; - } - - @Override - public OgcResponse getCapabilities(GetCapReq request, - OgcServiceInfo serviceinfo) { - OgcResponse rval; - try { - WFSCapabilitiesType cap = capabilities.getCapabilities(request, - serviceinfo); - rval = marshalResponse(wfsFactory.createWFSCapabilities(cap)); - } catch (WfsException e) { - rval = getError(e, request.getExceptionFormat()); - } - return rval; - } - - protected OgcResponse marshalResponse(Object jaxbobject) { - OgcResponse rval; - try { - String xml = registry.marshal(jaxbobject); - rval = new OgcResponse(xml, "text/gml; subtype=gml/3.1.1", - TYPE.TEXT); - } catch (JAXBException e) { - log.error("Unable to marshal WFS response", e); - // TODO: real error code - rval = getError(new WfsException(Code.INVALID_REQUEST), - OgcResponse.TEXT_XML_MIME); - } - return rval; - } - - @Override - public OgcResponse getFeature(GetFeatureReq request, - OgcServiceInfo serviceinfo) { - OgcResponse rval; - FeatureCollectionType featColl; - String format = request.getOutputformat(); - try { - if (format.toLowerCase().contains("gml") - || format.toLowerCase().contains("xml")) { - // use JAXB instead of gml simple feature formatter - featColl = features.getFeatures(request, serviceinfo); - rval = marshalResponse(wfsFactory - .createFeatureCollection(featColl)); - } else { - if (request.getResulttype() == ResultType.hits) { - throw new WfsException(Code.INVALID_PARAMETER_VALUE, - "Hits result not supported in format: " + format); - } - SimpleFeatureFormatter formatter = getFormatter(format); - List> res = features.getSimpleFeatures( - request, serviceinfo); - try { - rval = formatter.format(res); - } catch (Exception e) { - log.error("Problem formatting features", e); - throw new WfsException(Code.INTERNAL_SERVER_ERROR); - } - } - } catch (WfsException e) { - rval = getError(e, request.getExceptionFormat()); - } - return rval; - } - - protected SimpleFeatureFormatter getFormatter(String format) - throws WfsException { - ApplicationContext ctx = EDEXUtil.getSpringContext(); - String[] beans = ctx.getBeanNamesForType(SimpleFeatureFormatter.class); - for (String bean : beans) { - SimpleFeatureFormatter sff = (SimpleFeatureFormatter) ctx - .getBean(bean); - if (sff.matchesFormat(format)) { - return sff; - } - } - throw new WfsException(Code.INVALID_PARAMETER_VALUE, - "Unsupported format: " + format); - } - - @Override - public OgcResponse transaction(TransReq request) { - TransactionResponseType rval = transactor.transaction(request); - return marshalResponse(wfsFactory.createTransactionResponse(rval)); - } - - @Override - public OgcResponse describeFeatureType(DescFeatureTypeReq request, - OgcServiceInfo serviceInfo) { - OgcResponse rval; - try { - String xml = descFeatureInternal(request, serviceInfo); - if (xml == null) { - throw new WfsException(Code.INVALID_REQUEST, - "Unknown type name(s)"); - } - rval = new OgcResponse(xml, "text/xml; subtype=gml/3.1.1", - TYPE.TEXT); - } catch (WfsException e) { - rval = getError(e, request.getExceptionFormat()); - } - return rval; - } - - public String descFeatureInternal(DescFeatureTypeReq request, - OgcServiceInfo serviceInfo) throws WfsException { - List typenames = request.getTypenames(); - String xml; - if (typenames == null || typenames.size() == 0) { - xml = getAllSchemas(serviceInfo); - } else if (typenames.size() == 1) { - xml = getOneSchema(typenames.get(0)); - } else { - xml = getMergedSchemas(typenames, serviceInfo); - } - return xml; - } - - // the following are desc feature type specific TODO move to separate object - - /** - * @param roles - * @param username - * @param typenames - * @return - * @throws WfsException - */ - protected String getMergedSchemas(List typenames, - OgcServiceInfo serviceInfo) throws WfsException { - int count = 0; - boolean success = false; - StringBuilder rval = new StringBuilder("\n"); - rval.append("\n"); - for (QualifiedName name : typenames) { - if (registry.getSource(name) == null) { - continue; - } - success = true; - if (name.getPrefix() == null) { - name.setPrefix("ns" + count++); - } - rval.append("\n"); - } - rval.append(""); - return success ? rval.toString() : null; - } - - protected String getDescUrl(OgcServiceInfo serviceInfo) { - if (describeFeatureUrl == null) { - for (OgcOperationInfo opinfo : serviceInfo - .getOperations()) { - String res = parse(opinfo.getHttpGetRes()); - if (res != null) { - describeFeatureUrl = res; - break; - } - } - if (describeFeatureUrl == null) { - log.error("Unable to construct describe feature URL"); - describeFeatureUrl = "http://localhost:8085/wfs?request=describefeaturetype"; - } - } - return describeFeatureUrl; - } - - /** - * @param httpGetRes - * @return - */ - private String parse(String target) { - if (target == null) { - return null; - } - if (target.toLowerCase().contains("describefeaturetype")) { - return target; - } - return null; - } - - /** - * @param roles - * @param username - * @param qualifiedName - * @return - * @throws WfsException - */ - protected String getOneSchema(QualifiedName feature) throws WfsException { - WfsSource source = registry.getSource(feature); - return source == null ? null : source.describeFeatureType(feature); - } - - /** - * @param roles - * @param username - * @return - * @throws WfsException - */ - protected String getAllSchemas(OgcServiceInfo serviceInfo) - throws WfsException { - return getMergedSchemas(getFeatureNames(), serviceInfo); - } - - public List getFeatureNames() { - // no authorization since the results of this will be authorized - // individually - List features = registry.getFeatures(); - List rval = new ArrayList(features.size()); - for (WfsFeatureType f : features) { - rval.add(f.getName()); - } - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/QueryExpressionVisitor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/QueryExpressionVisitor.java deleted file mode 100644 index 00d7b8ee53..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/QueryExpressionVisitor.java +++ /dev/null @@ -1,152 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.util.List; - -import net.opengis.filter.v_1_1_0.PropertyNameType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.raytheon.uf.edex.wfs.filter.ExpressionProcessor; -import com.raytheon.uf.edex.wfs.filter.OgcExpressionVisitor; - -/** - * - * @author bclement - * @version 1.0 - */ -public class QueryExpressionVisitor implements OgcExpressionVisitor { - - protected Log log = LogFactory.getLog(this.getClass()); - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#add(com.raytheon.uf. - * edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, java.lang.Object) - */ - @Override - public Object add(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception { - throw new Exception("Unsupported expression: add"); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#sub(com.raytheon.uf. - * edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, java.lang.Object) - */ - @Override - public Object sub(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception { - throw new Exception("Unsupported expression: sub"); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#mul(com.raytheon.uf. - * edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, java.lang.Object) - */ - @Override - public Object mul(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception { - throw new Exception("Unsupported expression: mul"); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#div(com.raytheon.uf. - * edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, java.lang.Object) - */ - @Override - public Object div(ExpressionProcessor left, ExpressionProcessor right, - Object obj) throws Exception { - throw new Exception("Unsupported expression: div"); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#literal(java.util.List, - * java.lang.Object) - */ - @Override - public Object literal(List values, Object obj) throws Exception { - if (values.size() != 1) { - log.warn("Unsupported literal values: " + values.toArray()); - } - return values.get(0); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#property(net.opengis - * .filter.v_1_1_0.PropertyNameType, java.lang.Object) - */ - @Override - public Object property(PropertyNameType prop, Object obj) throws Exception { - List content = prop.getContent(); - if (content.size() != 1) { - log.warn("Unsupported property name values: " + content.toArray()); - } - return content.get(0); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcExpressionVisitor#function(java.util.List, - * java.lang.String, java.lang.Object) - */ - @Override - public Object function(List expressions, String name, - Object obj) throws Exception { - throw new Exception("Unsupported expression type: function"); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/QueryFilterVisitor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/QueryFilterVisitor.java deleted file mode 100644 index a2ed8f0028..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/QueryFilterVisitor.java +++ /dev/null @@ -1,542 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.util.AbstractMap.SimpleEntry; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; - -import javax.xml.bind.JAXBElement; - -import net.opengis.filter.v_1_1_0.BBOXType; -import net.opengis.filter.v_1_1_0.BinarySpatialOpType; -import net.opengis.filter.v_1_1_0.DistanceBufferType; -import net.opengis.filter.v_1_1_0.PropertyIsLikeType; -import net.opengis.filter.v_1_1_0.PropertyIsNullType; -import net.opengis.gml.v_3_1_1.AbstractGeometryType; -import net.opengis.gml.v_3_1_1.EnvelopeType; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.geotools.geometry.jts.JTS; -import org.hibernate.criterion.Conjunction; -import org.hibernate.criterion.Criterion; -import org.hibernate.criterion.Disjunction; -import org.hibernate.criterion.Junction; -import org.hibernate.criterion.MatchMode; -import org.hibernate.criterion.Restrictions; -import org.hibernatespatial.criterion.SpatialRestrictions; - -import com.raytheon.uf.common.util.ConvertUtil; -import com.raytheon.uf.edex.wfs.filter.ExpressionProcessor; -import com.raytheon.uf.edex.wfs.filter.FilterProcessor; -import com.raytheon.uf.edex.wfs.filter.OgcFilterVisitor; -import com.raytheon.uf.edex.wfs.gml.EnvelopeConverter; -import com.raytheon.uf.edex.wfs.gml.GeometryConverter; -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Geometry; - -/** - * - * @author bclement - * @version 1.0 - */ -public class QueryFilterVisitor implements OgcFilterVisitor { - - protected Log log = LogFactory.getLog(this.getClass()); - - protected GeometryConverter geomConverter = new GeometryConverter(); - - protected EnvelopeConverter envConverter = new EnvelopeConverter(); - - protected QueryExpressionVisitor exprVisitor = new QueryExpressionVisitor(); - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#equal(com.raytheon.uf.edex - * .filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, boolean, - * java.lang.Object) - */ - @Override - public Criterion equal(ExpressionProcessor left, - ExpressionProcessor right, - boolean matchCase, Object obj) throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinaryProps(left, right, bag); - return Restrictions.eq(e.getKey(), e.getValue()); - } - - protected Entry getBinaryProps(ExpressionProcessor left, - ExpressionProcessor right, VisitorBag bag) throws Exception { - String prop = (String) left.accept(exprVisitor, bag); - String value = (String) right.accept(exprVisitor, bag); - Class ent = bag.getRootEntity(); - String[] path = parseProp(prop); - Object val = ConvertUtil.convertAsType(value, ent, path); - String field = StringUtils.join(path, "."); - return new SimpleEntry(bag.filterField(field), val); - } - - protected String[] parseProp(String prop) { - // TODO we may want to keep the namespaces - String[] rval = prop.trim().split("\\/"); - for (int i = 0; i < rval.length; ++i) { - int index = rval[i].lastIndexOf(':'); - if (index > -1) { - rval[i] = rval[i].substring(index + 1); - } - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#notEqual(com.raytheon.uf - * .edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, boolean, - * java.lang.Object) - */ - @Override - public Criterion notEqual(ExpressionProcessor left, - ExpressionProcessor right, - boolean matchCase, Object obj) throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinaryProps(left, right, bag); - return Restrictions.ne(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#lessThan(com.raytheon.uf - * .edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, boolean, - * java.lang.Object) - */ - @Override - public Criterion lessThan(ExpressionProcessor left, - ExpressionProcessor right, - boolean matchCase, Object obj) throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinaryProps(left, right, bag); - return Restrictions.lt(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#greaterThan(com.raytheon - * .uf.edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, boolean, - * java.lang.Object) - */ - @Override - public Criterion greaterThan(ExpressionProcessor left, - ExpressionProcessor right, boolean matchCase, Object obj) - throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinaryProps(left, right, bag); - return Restrictions.gt(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#greaterThanEqual(com.raytheon - * .uf.edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, boolean, - * java.lang.Object) - */ - @Override - public Criterion greaterThanEqual(ExpressionProcessor left, - ExpressionProcessor right, boolean matchCase, Object obj) - throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinaryProps(left, right, bag); - return Restrictions.ge(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#lessThanEqual(com.raytheon - * .uf.edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, boolean, - * java.lang.Object) - */ - @Override - public Criterion lessThanEqual(ExpressionProcessor left, - ExpressionProcessor right, boolean matchCase, Object obj) - throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinaryProps(left, right, bag); - return Restrictions.le(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#isLike(net.opengis.filter - * .v_1_1_0.PropertyIsLikeType, java.lang.Object) - */ - @Override - public Criterion isLike(PropertyIsLikeType op, Object obj) - throws Exception { - // FIXME this is not correct, needs to take wildcard, anychar and - // escapes into account - VisitorBag bag = (VisitorBag) obj; - String prop = (String) op.getPropertyName().getContent().get(0); - String value = (String) op.getLiteral().getContent().get(0); - return Restrictions.like(bag.filterField(prop), value, - MatchMode.ANYWHERE); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#isNull(net.opengis.filter - * .v_1_1_0.PropertyIsNullType, java.lang.Object) - */ - @Override - public Criterion isNull(PropertyIsNullType op, Object obj) - throws Exception { - VisitorBag bag = (VisitorBag) obj; - String field = (String) op.getPropertyName().getContent().get(0); - return Restrictions.isNull(bag.filterField(field)); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#between(com.raytheon.uf. - * edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, - * com.raytheon.uf.edex.filter.ExpressionProcessor, java.lang.Object) - */ - @Override - public Criterion between(ExpressionProcessor lower, - ExpressionProcessor exp, - ExpressionProcessor upper, Object obj) throws Exception { - VisitorBag bag = (VisitorBag) obj; - - Entry lowerPart = getBinaryProps(exp, lower, bag); - Entry upperPart = getBinaryProps(exp, upper, bag); - - return Restrictions.between(lowerPart.getKey(), lowerPart.getValue(), - upperPart.getValue()); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.filter.OgcFilterVisitor#and(java.util.List, - * java.lang.Object) - */ - @Override - public Criterion and(List filters, Object obj) - throws Exception { - Conjunction rval = Restrictions.conjunction(); - acceptAll(filters, obj, rval); - return rval; - } - - protected void acceptAll(List filters, Object obj, - Junction junc) throws Exception { - Iterator i = filters.iterator(); - while (i.hasNext()) { - junc.add((Criterion) i.next().accept(this, obj)); - } - } - - protected List addAll(List l1, List l2) { - if (l1 == null) { - return l2; - } - if (l2 == null) { - return l1; - } - ArrayList rval = new ArrayList(l1.size() + l2.size()); - rval.addAll(l1); - rval.addAll(l2); - return rval; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.filter.OgcFilterVisitor#or(java.util.List, - * java.lang.Object) - */ - @Override - public Criterion or(List filters, Object obj) - throws Exception { - Disjunction rval = Restrictions.disjunction(); - acceptAll(filters, obj, rval); - return rval; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#not(com.raytheon.uf.edex - * .filter.FilterProcessor, java.lang.Object) - */ - @Override - public Criterion not(FilterProcessor filter, Object obj) throws Exception { - return Restrictions.not((Criterion) filter.accept(this, obj)); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#spatialEquals(net.opengis - * .filter.v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion spatialEquals(BinarySpatialOpType op, Object obj) - throws Exception { - VisitorBag bag = (VisitorBag) obj; - Entry e = getBinarySpatial(op, bag); - return SpatialRestrictions.eq(bag.filterField(e.getKey()), e.getValue()); - } - - - protected Entry getBinarySpatial( - BinarySpatialOpType binary, VisitorBag bag) throws Exception { - List lst = binary.getPropertyName().getContent(); - String str = getStringWarn(lst, "Unsupported property name type"); - String prop = StringUtils.join(parseProp(str), '.'); - Geometry shape = getGeometry(binary); - return new SimpleEntry(bag.filterField(prop), shape); - } - - protected Geometry getGeometry(BinarySpatialOpType binary) throws Exception { - JAXBElement env = binary.getEnvelope(); - JAXBElement geom = binary.getGeometry(); - Geometry shape; - if (env != null && !env.isNil()) { - Envelope envelope = envConverter.convert(env.getValue()); - shape = geomConverter.convert(envelope); - } else if (geom != null && !geom.isNil()) { - shape = geomConverter.convert(geom.getValue()); - } else { - throw new Exception("Unsupported geometry format"); - } - return shape; - } - - protected String getStringWarn(List lst, String msg) { - if (lst.size() != 1) { - log.warn(msg); - } - return (String) lst.get(0); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#disjoint(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion disjoint(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.disjoint(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#touches(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion touches(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.touches(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#within(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion within(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.within(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#overlaps(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion overlaps(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.overlaps(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#crosses(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion crosses(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.crosses(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#intersects(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion intersects(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.intersects(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#contains(net.opengis.filter - * .v_1_1_0.BinarySpatialOpType, java.lang.Object) - */ - @Override - public Criterion contains(BinarySpatialOpType op, Object obj) - throws Exception { - Entry e = getBinarySpatial(op, (VisitorBag) obj); - return SpatialRestrictions.contains(e.getKey(), e.getValue()); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#dWithin(net.opengis.filter - * .v_1_1_0.DistanceBufferType, java.lang.Object) - */ - @Override - public Object dWithin(DistanceBufferType op, Object obj) - throws Exception { - throw new Exception("dWithin queries not supported"); - } - - // public RangeParameter getDistance(DistanceBufferType dist, RangeOperand - // op, - // VisitorBag bag) throws Exception { - // List lst = dist.getPropertyName().getContent(); - // String str = getStringWarn(lst, "Unsupported property name type"); - // String prop = StringUtils.join(parseProp(str), '.'); - // AbstractGeometryType geom = dist.getGeometry().getValue(); - // Geometry res = geomConverter.convert(geom); - // if (!(res instanceof Point)) { - // throw new Exception("Unsupported distance geometry" - // + res.getClass()); - // } - // double distance = 0;// FIXME jaxb classes do not contain distance value - // RangeParameter param = new RangeParameter(prop, (Point) res, distance, - // op); - // throw new Exception("Distance types not supported"); - // // return rval; - // } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#beyond(net.opengis.filter - * .v_1_1_0.DistanceBufferType, java.lang.Object) - */ - @Override - public Object beyond(DistanceBufferType op, Object obj) - throws Exception { - throw new Exception("Beyond queries not supported"); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.filter.OgcFilterVisitor#bbox(net.opengis.filter. - * v_1_1_0.BBOXType, java.lang.Object) - */ - @Override - public Criterion bbox(BBOXType op, Object obj) throws Exception { - VisitorBag bag = (VisitorBag) obj; - List lst = op.getPropertyName().getContent(); - String str = getStringWarn(lst, "Unsupported property name type"); - String prop = StringUtils.join(parseProp(str), '.'); - EnvelopeType value = op.getEnvelope().getValue(); - Envelope env = envConverter.convert(value); - return SpatialRestrictions.within(bag.filterField(prop), - JTS.toGeometry(env)); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/SimpleFilterHandler.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/SimpleFilterHandler.java deleted file mode 100644 index 5ca23681d7..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/SimpleFilterHandler.java +++ /dev/null @@ -1,53 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import org.geotools.filter.FilterHandler; -import org.opengis.filter.Filter; -import org.xml.sax.helpers.DefaultHandler; - -/** - * @author bclement - * - */ -public class SimpleFilterHandler extends DefaultHandler implements - FilterHandler { - - private Filter filter; - - public void filter(Filter filter) { - this.filter = filter; - } - - public Filter getFilter() { - return filter; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/SqlQueryParts.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/SqlQueryParts.java deleted file mode 100644 index 28ec6a3952..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/SqlQueryParts.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.raytheon.uf.edex.wfs.provider; - -public class SqlQueryParts { - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/Transactor.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/Transactor.java deleted file mode 100644 index 66d49ff9fd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/Transactor.java +++ /dev/null @@ -1,122 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 29, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.math.BigInteger; -import java.util.Iterator; -import java.util.List; - -import net.opengis.wfs.v_1_1_0.TransactionResponseType; -import net.opengis.wfs.v_1_1_0.TransactionResultsType; -import net.opengis.wfs.v_1_1_0.TransactionSummaryType; - -import com.raytheon.uf.edex.wfs.request.TransReq; - -/** - * - * @author bclement - * @version 1.0 - */ -public class Transactor { - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.WfsProvider#transaction(com.raytheon.uf.edex - * .wfs.request.TransReq) - */ - public TransactionResponseType transaction(TransReq request) { - TransactionResponseType rval = new TransactionResponseType(); - rval.setTransactionSummary(getTransSummary(0, 0, 0)); - // FIXME should use source - // rval.setTransactionResults(getTransResults(request)); - return rval; - } - - /** - * @param request - * @return - */ - protected TransactionResultsType getTransResults(TransReq request) { - TransactionResultsType rval = new TransactionResultsType(); - switch (request.getTransType()) { - case Native: - String[] parts = request.getParameter().replaceAll("\\w+:", "") - .split("/"); - String param = (parts.length > 1 ? parts[1] : parts[0]); - for (int i = 2; i < parts.length; ++i) { - param += "." + parts[i]; - } - // String plugname = featureManager.getFeaturePlugName(parts[0]); - // MorphiaStrategy strat = new MorphiaStrategy(); - // try { - // List unique = strat.getUnique(plugname, param); - // ActionType atype = new ActionType(); - // atype.setLocator("unique"); - // atype.setMessage(join(unique)); - // List alist = Arrays.asList(atype); - // rval.setAction(alist); - // } catch (PluginException e) { - // log.error("Problem querying for plugin: " + plugname, e); - // } - } - return rval; - } - - protected String join(List list) { - String rval = ""; - if (!list.isEmpty()) { - Iterator i = list.iterator(); - rval = i.next().toString(); - while (i.hasNext()) { - rval += "," + i.next(); - } - } - return rval; - } - - /** - * @return - */ - protected TransactionSummaryType getTransSummary(int deleted, int inserted, - int updated) { - TransactionSummaryType rval = new TransactionSummaryType(); - rval.setTotalDeleted(getBigInt(deleted)); - rval.setTotalInserted(getBigInt(inserted)); - rval.setTotalUpdated(getBigInt(updated)); - return rval; - } - - protected BigInteger getBigInt(int i) { - return new BigInteger("" + i); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/VisitorBag.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/VisitorBag.java deleted file mode 100644 index b7bdad56cb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/provider/VisitorBag.java +++ /dev/null @@ -1,93 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.provider; - -import java.util.Map; - - -/** - * - * @author bclement - * @version 1.0 - */ -public class VisitorBag { - - protected Class rootEntity; - - protected String spatialField; - - protected Map fieldMap; - - /** - * @param converter - * @param rootEntity - * @param spatialField - */ - public VisitorBag(Class rootEntity, - String spatialField) { - super(); - this.rootEntity = rootEntity; - this.spatialField = spatialField; - } - - public String filterField(String field) { - if (fieldMap == null || field == null) { - return field; - } - String rval = fieldMap.get(field); - return rval != null ? rval : field; - } - - public Class getRootEntity() { - return rootEntity; - } - - public void setRootEntity(Class rootEntity) { - this.rootEntity = rootEntity; - } - - public String getSpatialField() { - return spatialField; - } - - public void setSpatialField(String spatialField) { - this.spatialField = spatialField; - } - - public Map getFieldMap() { - return fieldMap; - } - - public void setFieldMap(Map fieldMap) { - this.fieldMap = fieldMap; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java deleted file mode 100644 index d202da5949..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/AbstractWfsSource.java +++ /dev/null @@ -1,296 +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 9, 2012 bclement Initial creation -* -*/ -package com.raytheon.uf.edex.wfs.reg; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Criteria; -import org.hibernate.SessionFactory; -import org.hibernate.classic.Session; -import org.hibernate.criterion.Criterion; -import org.hibernate.criterion.Order; -import org.hibernate.criterion.Projections; - -import com.raytheon.uf.edex.database.dao.CoreDao; -import com.raytheon.uf.edex.ogc.common.OgcGeoBoundingBox; -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsException.Code; -import com.raytheon.uf.edex.wfs.WfsFeatureType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; -import com.raytheon.uf.edex.wfs.request.SortBy; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class AbstractWfsSource implements WfsSource { - - protected String key; - - protected static String defaultCRS = "crs:84"; - - protected static OgcGeoBoundingBox fullBbox = new OgcGeoBoundingBox(180, - -180, 90, -90); - - protected Log log = LogFactory.getLog(this.getClass()); - - protected abstract CoreDao getDao() throws Exception; - - public AbstractWfsSource(String key) { - this.key = key; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wfs.reg.WfsSource#listFeatureTypes() - */ - @Override - public abstract List listFeatureTypes(); - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#describeFeatureType(com.raytheon - * .uf.edex.wfs.request.QualifiedName) - */ - @Override - public abstract String describeFeatureType(QualifiedName feature); - - /** - * Utility method for reading text files from the classpath - * - * @param loader - * @param location - * @return - * @throws IOException - */ - protected String getResource(ClassLoader loader, String location) - throws IOException { - String rval; - try { - InputStream in = loader.getResourceAsStream(location); - rval = new java.util.Scanner(in).useDelimiter("\\A").next(); - } catch (Throwable e) { - throw new IOException(e); - } - return rval; - } - - protected List queryInternal(QualifiedName feature, WfsQuery query) - throws WfsException { - query = modQuery(query); - List rval; - Session sess = null; - try { - CoreDao dao = getDao(); - sess = dao.getSessionFactory().openSession(); - Criteria criteria = sess.createCriteria(getFeatureEntity(feature)); - criteria = modCriteria(criteria); - criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); - populateCriteria(criteria, query); - criteria.setMaxResults(query.getMaxResults()); - List sortBys = query.getSortBys(); - addOrder(criteria, sortBys); - rval = getResults(criteria); - } catch (Exception e) { - log.error("Problem querying for feature", e); - throw new WfsException(Code.INTERNAL_SERVER_ERROR); - } finally { - if (sess != null) { - sess.close(); - } - } - return rval; - } - - @SuppressWarnings("unchecked") - protected List getResults(Criteria criteria) { - return criteria.list(); - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#getFeatureSpatialField(com.raytheon - * .uf.edex.wfs.request.QualifiedName) - */ - @Override - public abstract String getFeatureSpatialField(QualifiedName feature); - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#getFeatureEntity(com.raytheon. - * uf.edex.wfs.request.QualifiedName) - */ - @Override - public abstract Class getFeatureEntity(QualifiedName feature); - - /** - * Hook for implementing classes to modify the query object - * - * @param wfsq - * @return - */ - protected WfsQuery modQuery(WfsQuery wfsq) { - return wfsq; - } - - protected Criteria modCriteria(Criteria crit) { - return crit; - } - - protected void addOrder(Criteria criteria, List sortBys) { - if (sortBys == null || sortBys.isEmpty()) { - return; - } - for (SortBy sb : sortBys) { - switch (sb.getOrder()) { - case Ascending: - criteria.addOrder(Order.asc(sb.getProperty())); - break; - case Descending: - criteria.addOrder(Order.desc(sb.getProperty())); - break; - default: - log.warn("Unrecognized order: " + sb.getOrder()); - } - } - } - - protected void populateCriteria(Criteria criteria, WfsQuery query) { - query = modQuery(query); - Criterion criterion = query.getCriterion(); - if (criterion != null) { - criteria.add(criterion); - } - int maxResults = query.getMaxResults(); - if (maxResults > -1) { - criteria.setMaxResults(maxResults); - } - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#distinct(com.raytheon.uf.edex. - * wfs.request.QualifiedName, com.raytheon.uf.edex.db.api.DatabaseQuery) - */ - @Override - public List distinct(QualifiedName feature, WfsQuery query) { - query = modQuery(query); - List rval; - try { - // List res = getDao().queryByCriteria(query); - // rval = new ArrayList(res.size()); - // for (Object obj : res) { - // ConvertUtil converter = BundleContextAccessor - // .getService(ConvertUtil.class); - // rval.add(converter.toString(obj)); - // } - // FIXME - rval = null; - } catch (Exception e) { - log.error("Problem querying for metar", e); - rval = new ArrayList(0); - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#count(com.raytheon.uf.edex.wfs - * .request.QualifiedName, com.raytheon.uf.edex.db.api.DatabaseQuery) - */ - @SuppressWarnings("unchecked") - @Override - public long count(QualifiedName feature, WfsQuery query) - throws WfsException { - long rval; - Session sess = null; - try { - CoreDao dao = getDao(); - SessionFactory sessFact = dao.getSessionFactory(); - sess = sessFact.openSession(); - Criteria criteria = sess.createCriteria(getFeatureEntity(feature)); - criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); - populateCriteria(criteria, query); - criteria.setProjection(Projections.rowCount()); - List list = criteria.list(); - rval = list.get(0).longValue(); - } catch (Exception e) { - log.error(e); - throw new WfsException(Code.INTERNAL_SERVER_ERROR); - } finally { - if (sess != null) { - sess.close(); - } - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wfs.reg.WfsSource#getKey() - */ - @Override - public String getKey() { - return key; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wfs.reg.WfsSource#getJaxbClasses() - */ - @Override - public abstract Class[] getJaxbClasses(); - - @Override - public Map getFieldMap() { - return null; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/DefaultWfsSource.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/DefaultWfsSource.java deleted file mode 100644 index 4e68747ac1..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/DefaultWfsSource.java +++ /dev/null @@ -1,121 +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 - * ------------ ---------- ----------- -------------------------- - * Jul 26, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.reg; - -import java.util.List; - -import javax.xml.bind.JAXBElement; - -import net.opengis.gml.v_3_1_1.AbstractFeatureType; - -import org.opengis.feature.simple.SimpleFeature; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; -import com.raytheon.uf.common.dataplugin.PluginException; -import com.raytheon.uf.common.dataplugin.PluginProperties; -import com.raytheon.uf.edex.database.dao.CoreDao; -import com.raytheon.uf.edex.database.plugin.PluginFactory; -import com.raytheon.uf.edex.ogc.common.feature.FeatureFactory; -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsException.Code; -import com.raytheon.uf.edex.wfs.request.QualifiedName; - -/** - * - * @author bclement - * @version 1.0 - */ -public abstract class DefaultWfsSource extends - AbstractWfsSource { - - protected CoreDao _dao; - - protected PluginProperties props; - - protected WfsTranslator translator; - - protected FeatureFactory featFactory; - - public DefaultWfsSource(PluginProperties props, String key, - WfsTranslator translator, FeatureFactory featFactory) { - super(key); - this.props = props; - this.translator = translator; - this.featFactory = featFactory; - } - - @Override - protected CoreDao getDao() throws PluginException { - if (_dao == null) { - _dao = PluginFactory.getInstance().getPluginDao( - props.getPluginName()); - } - return _dao; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#query(com.raytheon.uf.edex.wfs - * .request.QualifiedName, com.raytheon.uf.edex.db.api.DatabaseQuery) - */ - @Override - public List> query( - QualifiedName feature, WfsQuery query) throws WfsException { - List pdos = queryInternal(feature, query); - PluginDataObject[] arr = pdos - .toArray(new PluginDataObject[pdos.size()]); - try { - return translator.translate(arr); - } catch (Exception e) { - log.error("Problem translating pdos to jaxb features", e); - throw new WfsException(Code.INTERNAL_SERVER_ERROR); - } - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wfs.reg.WfsSource#querySimple(com.raytheon.uf.edex - * .wfs.request.QualifiedName, com.raytheon.uf.edex.wfs.reg.WfsQuery) - */ - @Override - public List querySimple(QualifiedName feature, WfsQuery q) - throws WfsException { - List pdos = queryInternal(feature, q); - PluginDataObject[] arr = pdos - .toArray(new PluginDataObject[pdos.size()]); - return featFactory.convert(arr); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/Unique.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/Unique.java deleted file mode 100644 index d40414d55d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/Unique.java +++ /dev/null @@ -1,67 +0,0 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.3 in JDK 1.6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2010.12.10 at 02:54:21 PM CST -// - -package com.raytheon.uf.edex.wfs.reg; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - -import net.opengis.wfs.v_1_1_0.NativeType; - -/** - *

- * Java class for unique complex type. - * - *

- * The following schema fragment specifies the expected content contained within - * this class. - * - *

- * <complexType name="unique">
- *   <complexContent>
- *     <extension base="{http://www.opengis.net/wfs}NativeType">
- *       <sequence>
- *         <element name="parameter" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *       </sequence>
- *     </extension>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "unique", propOrder = { "parameter" }, namespace = "http://edex.uf.raytheon.com") -public class Unique extends NativeType { - - @XmlElement(required = true) - protected String parameter; - - /** - * Gets the value of the parameter property. - * - * @return possible object is {@link String } - * - */ - public String getParameter() { - return parameter; - } - - /** - * Sets the value of the parameter property. - * - * @param value - * allowed object is {@link String } - * - */ - public void setParameter(String value) { - this.parameter = value; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsQuery.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsQuery.java deleted file mode 100644 index a307bd8564..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsQuery.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.raytheon.uf.edex.wfs.reg; - -import java.util.LinkedList; -import java.util.List; - -import org.hibernate.criterion.Criterion; - -import com.raytheon.uf.edex.wfs.request.SortBy; - -public class WfsQuery { - - protected Criterion criterion; - - protected int maxResults; - - protected List sortBys = new LinkedList(); - - protected List propertyNames = new LinkedList(); - - public WfsQuery() { - // TODO Auto-generated constructor stub - } - - public WfsQuery(Criterion criterion, int maxResults, List sortBys, - List propertyNames) { - this.criterion = criterion; - this.maxResults = maxResults; - this.sortBys = sortBys; - this.propertyNames = propertyNames; - } - - public Criterion getCriterion() { - return criterion; - } - - public void setCriterion(Criterion criterion) { - this.criterion = criterion; - } - - public int getMaxResults() { - return maxResults; - } - - public void setMaxResults(int maxResults) { - this.maxResults = maxResults; - } - - public List getSortBys() { - return sortBys; - } - - public void setSortBys(List sortBys) { - this.sortBys = sortBys; - } - - public List getPropertyNames() { - return propertyNames; - } - - public void setPropertyNames(List propertyNames) { - this.propertyNames = propertyNames; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsRegistry.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsRegistry.java deleted file mode 100644 index e360b1c35f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsRegistry.java +++ /dev/null @@ -1,54 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.reg; - -import com.raytheon.uf.common.util.registry.RegistryException; - -/** - * @author bclement - * - */ -public interface WfsRegistry { - - /** - * @param source - * @return - * @throws RegistryException - */ - WfsRegistry register(WfsSource source) - throws RegistryException; - - /** - * @param source - * @return - */ - WfsRegistry unregister(WfsSource source); - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsRegistryImpl.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsRegistryImpl.java deleted file mode 100644 index 21425d64cc..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsRegistryImpl.java +++ /dev/null @@ -1,192 +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 - * ------------ ---------- ----------- -------------------------- - * Apr 11, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.reg; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.xml.bind.JAXBException; - -import net.opengis.gml.v_3_1_1.ObjectFactory; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.raytheon.uf.common.util.registry.RegistryException; -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcPrefix; -import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager; -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsFeatureType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; - -/** - * - * @author bclement - * @version 1.0 - */ -public class WfsRegistryImpl implements WfsRegistry { - - protected Map byKey = new HashMap(); - - protected Map byFeature = new HashMap(); - - protected Class[] jaxbClasses = new Class[] { ObjectFactory.class, - net.opengis.wfs.v_1_1_0.ObjectFactory.class, - net.opengis.filter.v_1_1_0.ObjectFactory.class, Unique.class }; - - protected OgcJaxbManager jaxbManager; - - protected Log log = LogFactory.getLog(this.getClass()); - - protected long currentVersion = 0; - - protected long jaxbContextVersion = 0; - - protected String prefix = "wfs"; - - protected static final Map NS_MAP = new ConcurrentHashMap(); - - static { - NS_MAP.put(OgcNamespace.EDEX, OgcPrefix.EDEX); - NS_MAP.put(OgcNamespace.GML, OgcPrefix.GML); - NS_MAP.put(OgcNamespace.OGC, OgcPrefix.OGC); - NS_MAP.put(OgcNamespace.OWS, OgcPrefix.OWS); - NS_MAP.put(OgcNamespace.WFS, OgcPrefix.WFS); - NS_MAP.put(OgcNamespace.XSI, OgcPrefix.XSI); - NS_MAP.put(OgcNamespace.XLINK, OgcPrefix.XLINK); - } - - public WfsRegistryImpl() { - - } - - @Override - public synchronized WfsRegistry register(final WfsSource source) - throws RegistryException { - addByKey(source); - addByFeature(source); - jaxbClasses = (Class[]) ArrayUtils.addAll(jaxbClasses, - source.getJaxbClasses()); - currentVersion++; - - return this; - } - - protected OgcJaxbManager getManager() throws JAXBException { - if (jaxbManager == null || jaxbContextVersion < currentVersion) { - jaxbContextVersion = currentVersion; - jaxbManager = new OgcJaxbManager(jaxbClasses); - jaxbManager.setPrefixMap(NS_MAP); - } - return jaxbManager; - } - - public Object unmarshal(String xml) throws JAXBException { - return getManager().unmarshal(xml); - } - - public String marshal(Object obj) throws JAXBException { - return getManager().marshal(obj); - } - - protected void addByKey(WfsSource source) throws RegistryException { - String key = source.getKey(); - if (byKey.containsKey(key)) { - throw new RegistryException("WFS Source already exists with key: " - + key); - } - byKey.put(source.getKey(), source); - } - - protected void addByFeature(WfsSource source) throws RegistryException { - for (WfsFeatureType f : source.listFeatureTypes()) { - QualifiedName feature = f.getName(); - if (byFeature.containsKey(feature)) { - throw new RegistryException( - "Already providing a feature with name: " + feature); - } - String prefix = (feature.getPrefix() != null ? feature.getPrefix() - : feature.getName()); - NS_MAP.put(feature.getNamespace(), prefix); - byFeature.put(f.getName(), source); - } - } - - protected void removeAll(WfsSource source) { - WfsSource removed = byKey.remove(source.getKey()); - if (removed != null) { - for (WfsFeatureType f : removed.listFeatureTypes()) { - byFeature.remove(f.getName()); - } - } - } - - @Override - public synchronized WfsRegistry unregister(WfsSource source) { - removeAll(source); - return this; - } - - public WfsSource getSource(QualifiedName feature) throws WfsException { - WfsSource rval = byFeature.get(feature); - return rval; - } - - public List getFeatures() { - List rval = new LinkedList(); - for (WfsSource source : byKey.values()) { - rval.addAll(source.listFeatureTypes()); - } - return rval; - } - - /** - * @return the prefix - */ - public String getPrefix() { - return prefix; - } - - /** - * @param prefix - * the prefix to set - */ - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsSource.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsSource.java deleted file mode 100644 index b0f4ba422d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsSource.java +++ /dev/null @@ -1,76 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.reg; - -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBElement; - -import net.opengis.gml.v_3_1_1.AbstractFeatureType; - -import org.opengis.feature.simple.SimpleFeature; - -import com.raytheon.uf.edex.wfs.WfsException; -import com.raytheon.uf.edex.wfs.WfsFeatureType; -import com.raytheon.uf.edex.wfs.request.QualifiedName; - -/** - * @author bclement - * - */ -public interface WfsSource { - - public List listFeatureTypes(); - - public String describeFeatureType(QualifiedName feature) - throws WfsException; - - public String getFeatureSpatialField(QualifiedName feature); - - public Class getFeatureEntity(QualifiedName feature); - - public Map getFieldMap(); - - public List> query( - QualifiedName feature, WfsQuery q) throws WfsException; - - public List querySimple(QualifiedName feature, WfsQuery q) - throws WfsException; - - public List distinct(QualifiedName feature, WfsQuery q) - throws WfsException; - - public long count(QualifiedName feature, WfsQuery q) throws WfsException; - - public String getKey(); - - public Class[] getJaxbClasses(); -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsTranslator.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsTranslator.java deleted file mode 100644 index 34851d871e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/reg/WfsTranslator.java +++ /dev/null @@ -1,50 +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 - * ------------ ---------- ----------- -------------------------- - * Jul 26, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.reg; - -import java.util.ArrayList; - -import javax.xml.bind.JAXBElement; - -import net.opengis.gml.v_3_1_1.AbstractFeatureType; - -import com.raytheon.uf.common.dataplugin.PluginDataObject; - -/** - * - * @author bclement - * @version 1.0 - */ -public interface WfsTranslator { - - public ArrayList> translate( - PluginDataObject[] pdos) throws Exception; -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/DescFeatureTypeReq.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/DescFeatureTypeReq.java deleted file mode 100644 index 9292724226..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/DescFeatureTypeReq.java +++ /dev/null @@ -1,121 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import javax.xml.namespace.QName; - -import net.opengis.wfs.v_1_1_0.DescribeFeatureTypeType; - -/** - * @author bclement - * - */ -public class DescFeatureTypeReq extends WfsRequest { - - protected List typenames; - - protected String outputformat = "text/xml; subtype=gml/3.1.1"; - - /** - * @param type - */ - public DescFeatureTypeReq() { - super(Type.DescribeFeature); - this.typenames = new LinkedList(); - } - - public DescFeatureTypeReq(List typenames) { - super(Type.DescribeFeature); - this.typenames = typenames; - } - - /** - * @param obj - * @return - */ - public DescFeatureTypeReq(DescribeFeatureTypeType req) { - super(Type.DescribeFeature); - setRawrequest(req); - String outputFormat = req.getOutputFormat(); - if (outputFormat != null && !outputFormat.isEmpty()) { - setOutputformat(outputFormat); - } - List typeName = req.getTypeName(); - if (typeName != null) { - for (QName n : typeName) { - QualifiedName qname = new QualifiedName(n.getNamespaceURI(), - n.getLocalPart(), n.getPrefix()); - addTypename(qname); - } - } - } - - public void addTypename(QualifiedName typename) { - if (this.typenames == null) { - this.typenames = new ArrayList(); - } - this.typenames.add(typename); - } - - /** - * @return the typenames - */ - public List getTypenames() { - return typenames; - } - - /** - * @param typenames - * the typenames to set - */ - public void setTypenames(List typenames) { - this.typenames = typenames; - } - - /** - * @return the outputformat - */ - public String getOutputformat() { - return outputformat; - } - - /** - * @param outputformat - * the outputformat to set - */ - public void setOutputformat(String outputformat) { - this.outputformat = outputformat; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/FeatureQuery.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/FeatureQuery.java deleted file mode 100644 index 54ace9a9a8..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/FeatureQuery.java +++ /dev/null @@ -1,151 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -import java.util.LinkedList; -import java.util.List; - -/** - * @author bclement - * - */ -public class FeatureQuery { - - public enum QFilterType { - XML, BBOX, FIDS, XMLOBJ, NONE - } - - protected String srsName; - - protected List typeNames = new LinkedList(); - - protected QFilterType filterType = QFilterType.NONE; - - protected Object filter; - - protected List sortBys = new LinkedList(); - - protected List propertyNames = new LinkedList(); - - public void addPropertyName(String propertyName) { - this.propertyNames.add(propertyName); - } - - public void addTypeName(QualifiedName typeName) { - this.typeNames.add(typeName); - } - - public void addSortBy(SortBy sortBy) { - this.sortBys.add(sortBy); - } - - /** - * @return the propertyNames - */ - public List getPropertyNames() { - return propertyNames; - } - - /** - * @param propertyNames - * the propertyNames to set - */ - public void setPropertyNames(List propertyNames) { - this.propertyNames = propertyNames; - } - - /** - * @return the srsName - */ - public String getSrsName() { - return srsName; - } - - /** - * @param srsName - * the srsName to set - */ - public void setSrsName(String srsName) { - this.srsName = srsName; - } - - /** - * @return the typeNames - */ - public List getTypeNames() { - return typeNames; - } - - /** - * @param typeNames - * the typeNames to set - */ - public void setTypeNames(List typeNames) { - this.typeNames = typeNames; - } - - /** - * @return the filter - */ - public Object getFilter() { - return filter; - } - - /** - * @param filter - * the filter to set - */ - public void setFilter(Object filter, QFilterType type) { - this.filter = filter; - this.filterType = type; - } - - /** - * @return the filterType - */ - public QFilterType getFilterType() { - return filterType; - } - - /** - * @return the sortBys - */ - public List getSortBys() { - return sortBys; - } - - /** - * @param sortBys - * the sortBys to set - */ - public void setSortBys(List sortBys) { - this.sortBys = sortBys; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/GetCapReq.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/GetCapReq.java deleted file mode 100644 index 023d780db7..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/GetCapReq.java +++ /dev/null @@ -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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -import net.opengis.wfs.v_1_1_0.GetCapabilitiesType; - -/** - * @author bclement - * - */ -public class GetCapReq extends WfsRequest { - - /** - * @param type - */ - public GetCapReq() { - super(Type.GetCapabilities); - } - - public GetCapReq(GetCapabilitiesType getCap) { - super(Type.GetCapabilities); - setRawrequest(getCap); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/GetFeatureReq.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/GetFeatureReq.java deleted file mode 100644 index 4463d52706..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/GetFeatureReq.java +++ /dev/null @@ -1,189 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -import java.math.BigInteger; -import java.util.LinkedList; -import java.util.List; - -import javax.xml.namespace.QName; - -import net.opengis.filter.v_1_1_0.SortByType; -import net.opengis.filter.v_1_1_0.SortOrderType; -import net.opengis.filter.v_1_1_0.SortPropertyType; -import net.opengis.wfs.v_1_1_0.GetFeatureType; -import net.opengis.wfs.v_1_1_0.QueryType; -import net.opengis.wfs.v_1_1_0.ResultTypeType; - -import com.raytheon.uf.edex.wfs.request.FeatureQuery.QFilterType; -import com.raytheon.uf.edex.wfs.request.SortBy.Order; - -/** - * @author bclement - * - */ -public class GetFeatureReq extends WfsRequest { - - public enum ResultType { - results, hits - } - - protected List queries = new LinkedList(); - - protected String outputformat = "text/xml; subtype=gml/3.1.1"; - - protected ResultType resulttype = ResultType.results; - - // may want to set default - protected int maxFeatures = Integer.MAX_VALUE; - - /** - * @param type - */ - public GetFeatureReq() { - super(Type.GetFeature); - } - - public GetFeatureReq(GetFeatureType req) { - super(Type.GetFeature); - setRawrequest(req); - ResultTypeType resultType = req.getResultType(); - if (resultType == ResultTypeType.HITS) { - setResulttype(ResultType.hits); - } - String outputFormat = req.getOutputFormat(); - if (outputFormat != null) { - setOutputformat(outputFormat); - } - BigInteger maxFeatures = req.getMaxFeatures(); - if (maxFeatures != null) { - setMaxFeatures(maxFeatures.intValue()); - } - List query = req.getQuery(); - if (query != null) { - for (QueryType qt : query) { - addQuery(getQuery(qt)); - } - } - } - - /** - * @param qt - * @return - */ - protected FeatureQuery getQuery(QueryType qt) { - FeatureQuery rval = new FeatureQuery(); - rval.setFilter(qt.getFilter(), QFilterType.XMLOBJ); - SortByType sortBy = qt.getSortBy(); - if (sortBy != null) { - for (SortPropertyType prop : sortBy.getSortProperty()) { - String name = prop.getPropertyName().getContent().get(0) - .toString(); - Order o = (prop.getSortOrder() == SortOrderType.DESC ? Order.Descending - : Order.Ascending); - rval.addSortBy(new SortBy(name, o)); - } - } - String srsName = qt.getSrsName(); - if (srsName != null) { - rval.setSrsName(srsName); - } - for (QName q : qt.getTypeName()) { - rval.addTypeName(new QualifiedName(q.getNamespaceURI(), q - .getLocalPart(), q.getPrefix())); - } - return rval; - } - - public void addQuery(FeatureQuery query) { - this.queries.add(query); - } - - /** - * @return the queries - */ - public List getQueries() { - return queries; - } - - /** - * @param queries - * the queries to set - */ - public void setQueries(List queries) { - this.queries = queries; - } - - /** - * @return the outputformat - */ - public String getOutputformat() { - return outputformat; - } - - /** - * @param outputformat - * the outputformat to set - */ - public void setOutputformat(String outputformat) { - this.outputformat = outputformat; - } - - /** - * @return the resulttype - */ - public ResultType getResulttype() { - return resulttype; - } - - /** - * @param resulttype - * the resulttype to set - */ - public void setResulttype(ResultType resulttype) { - this.resulttype = resulttype; - } - - /** - * @return the maxFeatures - */ - public int getMaxFeatures() { - return maxFeatures; - } - - /** - * @param maxFeatures - * the maxFeatures to set - */ - public void setMaxFeatures(int maxFeatures) { - this.maxFeatures = maxFeatures; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/QualifiedName.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/QualifiedName.java deleted file mode 100644 index 13ea44d0fe..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/QualifiedName.java +++ /dev/null @@ -1,136 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -/** - * @author bclement - * - */ -public class QualifiedName { - - protected String namespace; - - protected String name; - - protected String prefix; - - public QualifiedName(String namespace, String name, String prefix) { - this.namespace = namespace; - this.name = name; - this.prefix = prefix; - } - - public QualifiedName(String namespace, String name) { - this(namespace, name, null); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result - + ((namespace == null) ? 0 : namespace.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; - QualifiedName other = (QualifiedName) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (namespace == null) { - if (other.namespace != null) - return false; - } else if (!namespace.equals(other.namespace)) - return false; - return true; - } - - /** - * @return the namespace - */ - public String getNamespace() { - return namespace; - } - - /** - * @param namespace - * the namespace to set - */ - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the prefix - */ - public String getPrefix() { - return prefix; - } - - /** - * @param prefix - * the prefix to set - */ - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - @Override - public String toString() { - return namespace + ":" + name; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/SortBy.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/SortBy.java deleted file mode 100644 index 5b820b7874..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/SortBy.java +++ /dev/null @@ -1,82 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -/** - * @author bclement - * - */ -public class SortBy { - - public enum Order { - Ascending, Descending - } - - protected String property; - - protected Order order; - - public SortBy(String property, Order order) { - super(); - this.property = property; - this.order = order; - } - - /** - * @return the property - */ - public String getProperty() { - return property; - } - - /** - * @param property - * the property to set - */ - public void setProperty(String property) { - this.property = property; - } - - /** - * @return the order - */ - public Order getOrder() { - return order; - } - - /** - * @param order - * the order to set - */ - public void setOrder(Order order) { - this.order = order; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/TransReq.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/TransReq.java deleted file mode 100644 index c5b966f166..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/TransReq.java +++ /dev/null @@ -1,142 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wfs.request; - -import net.opengis.wfs.v_1_1_0.TransactionType; - -import com.raytheon.uf.edex.wfs.reg.Unique; - -/** - * @author bclement - * - */ -public class TransReq extends WfsRequest { - - public enum TransType { - Insert, Update, Delete, Native - } - - protected TransType transType; - - protected String vendorId; - - protected boolean safeToIgnore = true; - - protected String parameter; - - /** - * @param type - */ - public TransReq(TransType type) { - super(WfsRequest.Type.Transaction); - this.transType = type; - } - - /** - * @param xml - * @param obj - * @return - */ - public static WfsRequest buildTransReq(TransactionType transaction) { - WfsRequest rval = null; - for (Object obj : transaction.getInsertOrUpdateOrDelete()) { - if (obj instanceof Unique) { - TransReq ret = new TransReq(TransType.Native); - Unique op = (Unique) obj; - ret.setSafeToIgnore(op.isSafeToIgnore()); - ret.setVendorId(op.getVendorId()); - ret.setParameter(op.getParameter()); - rval = ret; - } - } - return rval; - } - - /** - * @return the transType - */ - public TransType getTransType() { - return transType; - } - - /** - * @param transType - * the transType to set - */ - public void setTransType(TransType transType) { - this.transType = transType; - } - - /** - * @return the vendorId - */ - public String getVendorId() { - return vendorId; - } - - /** - * @param vendorId - * the vendorId to set - */ - public void setVendorId(String vendorId) { - this.vendorId = vendorId; - } - - /** - * @return the safeToIgnore - */ - public boolean isSafeToIgnore() { - return safeToIgnore; - } - - /** - * @param safeToIgnore - * the safeToIgnore to set - */ - public void setSafeToIgnore(boolean safeToIgnore) { - this.safeToIgnore = safeToIgnore; - } - - /** - * @return the parameter - */ - public String getParameter() { - return parameter; - } - - /** - * @param parameter - * the parameter to set - */ - public void setParameter(String parameter) { - this.parameter = parameter; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/WfsRequest.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/WfsRequest.java deleted file mode 100644 index 92dfe6cc73..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/request/WfsRequest.java +++ /dev/null @@ -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 - * ------------ ---------- ----------- -------------------------- - * Apr 22, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.request; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; - -public class WfsRequest { - - public enum Type { - GetFeature, DescribeFeature, GetCapabilities, Transaction, ERROR - } - - protected Object rawrequest; - - protected Type type; - - protected String username; - - protected String[] roles; - - private String exceptionFormat = OgcResponse.TEXT_XML_MIME; - - public WfsRequest(Type type) { - super(); - this.type = type; - } - - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - /** - * @return the rawrequest - */ - public Object getRawrequest() { - return rawrequest; - } - - /** - * @param rawrequest - * the rawrequest to set - */ - public void setRawrequest(Object rawrequest) { - this.rawrequest = rawrequest; - } - - /** - * @return the username - */ - public String getUsername() { - return username; - } - - /** - * @param username - * the username to set - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * @return the roles - */ - public String[] getRoles() { - return roles; - } - - /** - * @param roles - * the roles to set - */ - public void setRoles(String[] roles) { - this.roles = roles; - } - - /** - * @param exceptionFormat the exceptionFormat to set - */ - public void setExceptionFormat(String exceptionFormat) { - this.exceptionFormat = exceptionFormat; - } - - /** - * @return the exceptionFormat - */ - public String getExceptionFormat() { - return exceptionFormat; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/util/JaxbTransUtil.java b/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/util/JaxbTransUtil.java deleted file mode 100644 index 6736c01108..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wfs/src/com/raytheon/uf/edex/wfs/util/JaxbTransUtil.java +++ /dev/null @@ -1,73 +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 15, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wfs.util; - -import java.util.Arrays; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; - -import net.opengis.gml.v_3_1_1.DirectPositionType; -import net.opengis.gml.v_3_1_1.PointType; - -import com.vividsolutions.jts.geom.Point; - -/** - * - * @author bclement - * @version 1.0 - */ -public class JaxbTransUtil { - - protected final static TimeZone GMT = TimeZone.getTimeZone("GMT"); - - public static XMLGregorianCalendar getCalendar(Date dt) - throws DatatypeConfigurationException { - GregorianCalendar gcal = new GregorianCalendar(); - gcal.setTimeZone(GMT); - gcal.setTimeInMillis(dt.getTime()); - return DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal); - } - - public static PointType getGmlPoint(Point p) { - Double lat = p.getY(); - Double lon = p.getX(); - PointType point = new PointType(); - DirectPositionType pos = new DirectPositionType(); - pos.setValue(Arrays.asList(lon, lat)); - point.setPos(pos); - return point; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/.classpath b/edexOsgi/com.raytheon.uf.edex.wms/.classpath deleted file mode 100644 index bcf9c5c105..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.wms/.project b/edexOsgi/com.raytheon.uf.edex.wms/.project deleted file mode 100644 index 8c2ce000d6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.uf.edex.wms - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/edexOsgi/com.raytheon.uf.edex.wms/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.wms/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 620e405976..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Mon Jan 23 15:47:57 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 diff --git a/edexOsgi/com.raytheon.uf.edex.wms/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.wms/META-INF/MANIFEST.MF deleted file mode 100644 index f160d7cfdd..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/META-INF/MANIFEST.MF +++ /dev/null @@ -1,39 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Wms -Bundle-SymbolicName: com.raytheon.uf.edex.wms -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: RAYTHEON -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: com.raytheon.edex.common;bundle-version="1.12.1174", - net.opengis;bundle-version="1.0.2", - org.codehaus.jackson;bundle-version="1.7.3", - org.geotools;bundle-version="2.6.4", - org.apache.commons.logging;bundle-version="1.1.1", - org.apache.commons.lang;bundle-version="2.3.0", - org.apache.commons.pool;bundle-version="1.3.0", - com.raytheon.uf.edex.ogc.common;bundle-version="1.0.0", - javax.servlet;bundle-version="2.5.0", - com.raytheon.uf.common.colormap;bundle-version="1.12.1174", - org.apache.camel;bundle-version="1.0.0", - org.dom4j;bundle-version="1.0.0", - org.apache.velocity;bundle-version="1.5.0", - com.raytheon.uf.common.json;bundle-version="1.0.0", - com.raytheon.uf.common.localization;bundle-version="1.12.1174", - com.raytheon.uf.edex.database, - org.apache.commons.codec;bundle-version="1.4.0", - org.apache.commons.collections;bundle-version="3.2.0", - com.raytheon.uf.common.spatial;bundle-version="1.0.0" -Import-Package: com.raytheon.uf.common.colormap, - com.raytheon.uf.common.time.util, - 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.http -Export-Package: com.raytheon.uf.edex.wms, - com.raytheon.uf.edex.wms.format, - com.raytheon.uf.edex.wms.provider, - com.raytheon.uf.edex.wms.reg, - com.raytheon.uf.edex.wms.sld, - com.raytheon.uf.edex.wms.styling, - com.raytheon.uf.edex.wms.util diff --git a/edexOsgi/com.raytheon.uf.edex.wms/META-INF/templates/gfi-html-body.vm b/edexOsgi/com.raytheon.uf.edex.wms/META-INF/templates/gfi-html-body.vm deleted file mode 100644 index d1f90fc272..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/META-INF/templates/gfi-html-body.vm +++ /dev/null @@ -1,23 +0,0 @@ - - - - -#foreach( $attribute in $type.getAttributeDescriptors() ) - -#end ##foreach attribute in attributes - -#set( $odd = false ) -#foreach( $feature in $features ) -#if ( $odd ) - -#{else} - -#end ##if odd -#set( $odd = !$odd ) -#foreach( $attribute in $feature.getAttributes() ) - -#end ##foreach attribute in attributes - -#end ##foreach feature in features -
${type.name}
${attribute.getLocalName()}
${attribute.toString()}
-
diff --git a/edexOsgi/com.raytheon.uf.edex.wms/META-INF/templates/gfi-html-header.txt b/edexOsgi/com.raytheon.uf.edex.wms/META-INF/templates/gfi-html-header.txt deleted file mode 100644 index a1f5c8770a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/META-INF/templates/gfi-html-header.txt +++ /dev/null @@ -1,31 +0,0 @@ - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wms/build.properties b/edexOsgi/com.raytheon.uf.edex.wms/build.properties deleted file mode 100644 index 2660b7d6a5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -source.. = src/ -bin.includes = .project,\ - component-deploy.xml,\ - .classpath,\ - META-INF/,\ - build.properties,\ - .settings/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.wms/com.raytheon.uf.edex.wms.ecl b/edexOsgi/com.raytheon.uf.edex.wms/com.raytheon.uf.edex.wms.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.wms/component-deploy.xml b/edexOsgi/com.raytheon.uf.edex.wms/component-deploy.xml deleted file mode 100644 index ac0a31dff9..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/component-deploy.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wms/res/spring/wms-ogc-request.xml b/edexOsgi/com.raytheon.uf.edex.wms/res/spring/wms-ogc-request.xml deleted file mode 100644 index 42a7dfe72e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/res/spring/wms-ogc-request.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - net.opengis.wms.v_1_3_0.ObjectFactory - net.opengis.sld.v_1_1_0.ObjectFactory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/BaseRequest.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/BaseRequest.java deleted file mode 100644 index d1d40b1e5e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/BaseRequest.java +++ /dev/null @@ -1,184 +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 - * ------------ ---------- ----------- -------------------------- - * Sep 7, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wms; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.wms.WmsProvider.WmsOpType; - -/** - * - * @author bclement - * @version 1.0 - */ -public class BaseRequest { - - protected String version; - - protected String format; - - protected String userName; - - protected String[] roles; - - protected String exceptionFormat = "text/xml"; - - protected String updateSequence; - - protected OgcServiceInfo serviceinfo; - - /** - * - */ - public BaseRequest() { - // TODO Auto-generated constructor stub - } - - public BaseRequest(String version, String format, String userName, - String[] roles) { - super(); - this.version = version; - this.format = format; - this.userName = userName; - this.roles = roles; - } - - @SuppressWarnings("unchecked") - public OgcResponse execute(WmsProvider provider) { - return provider.getCapabilities((BaseRequest) this); - } - - /** - * @return the version - */ - public String getVersion() { - return version; - } - - /** - * @param version - * the version to set - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * @return the format - */ - public String getFormat() { - return format; - } - - /** - * @param format - * the format to set - */ - public void setFormat(String format) { - this.format = format; - } - - /** - * @return the exceptionFormat - */ - public String getExceptionFormat() { - return exceptionFormat; - } - - /** - * @param exceptionFormat - * the exceptionFormat to set - */ - public void setExceptionFormat(String exceptionFormat) { - this.exceptionFormat = exceptionFormat; - } - - /** - * @return the updateSequence - */ - public String getUpdateSequence() { - return updateSequence; - } - - /** - * @param updateSequence - * the updateSequence to set - */ - public void setUpdateSequence(String updateSequence) { - this.updateSequence = updateSequence; - } - - /** - * @return the serviceinfo - */ - public OgcServiceInfo getServiceinfo() { - return serviceinfo; - } - - /** - * @param serviceinfo - * the serviceinfo to set - */ - public void setServiceinfo(OgcServiceInfo serviceinfo) { - this.serviceinfo = serviceinfo; - } - - /** - * @return the userName - */ - public String getUserName() { - return userName; - } - - /** - * @param userName - * the userName to set - */ - public void setUserName(String userName) { - this.userName = userName; - } - - /** - * @return the roles - */ - public String[] getRoles() { - return roles; - } - - /** - * @param roles - * the roles to set - */ - public void setRoles(String[] roles) { - this.roles = roles; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetFeatureInfoRequest.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetFeatureInfoRequest.java deleted file mode 100644 index 9be259626b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetFeatureInfoRequest.java +++ /dev/null @@ -1,127 +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 4, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wms; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; - -/** - * - * @author bclement - * @version 1.0 - */ -public class GetFeatureInfoRequest extends GetMapRequest { - - protected String[] reqLayers; - - protected int featureCount = 1; - - protected Integer i; - - protected Integer j; - - protected String infoFormat; - - public GetFeatureInfoRequest() { - } - - public GetFeatureInfoRequest(GetMapRequest mapRequest, String[] reqLayers, - Integer i, Integer j, String infoFormat) { - super(mapRequest); - this.reqLayers = reqLayers; - this.i = i; - this.j = j; - this.infoFormat = infoFormat; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.BaseRequest#execute(com.raytheon.uf.edex.wms - * .WmsProvider) - */ - @Override - public OgcResponse execute(WmsProvider provider) { - return provider.getFeatureInfo(this); - } - - public GetMapRequest getMapRequest() { - return this; - } - - public int getFeatureCount() { - return featureCount; - } - - public void setFeatureCount(int featureCount) { - this.featureCount = featureCount; - } - - public Integer getI() { - return i; - } - - public void setI(Integer i) { - this.i = i; - } - - public Integer getJ() { - return j; - } - - public void setJ(Integer j) { - this.j = j; - } - - /** - * @return the reqLayers - */ - public String[] getReqLayers() { - return reqLayers; - } - - /** - * @param reqLayers - * the reqLayers to set - */ - public void setReqLayers(String[] reqLayers) { - this.reqLayers = reqLayers; - } - - public String getInfoFormat() { - return infoFormat; - } - - public void setInfoFormat(String infoFormat) { - this.infoFormat = infoFormat; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetLegendGraphicRequest.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetLegendGraphicRequest.java deleted file mode 100644 index 1ebac5b186..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetLegendGraphicRequest.java +++ /dev/null @@ -1,276 +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.wms; - -import java.util.Map; - -import org.geotools.styling.StyledLayerDescriptor; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.wms.WmsProvider.WmsOpType; - -public class GetLegendGraphicRequest extends BaseRequest { - - protected String layer; - - protected String style; - - protected Integer width; - - protected Integer height; - - protected String time; - - protected String elevation; - - protected Map dimensions; - - protected StyledLayerDescriptor sld; - - protected String rule; - - protected String scale; - - protected String featureType; - - protected Boolean transparent; - - protected String bgcolor; - - public GetLegendGraphicRequest(GetLegendGraphicRequest req) { - this.layer = req.getLayer(); - this.style = req.getStyle(); - this.width = req.getWidth(); - this.height = req.getHeight(); - this.time = req.time; - this.elevation = req.elevation; - this.dimensions = req.dimensions; - this.sld = req.getSld(); - this.rule = req.getRule(); - this.scale = req.getScale(); - this.featureType = req.getFeatureType(); - } - - public GetLegendGraphicRequest(String layer, String style, Integer width, - Integer height, String time, String elevation, - Map dimensions, StyledLayerDescriptor sld, - String rule, String scale, String featureType) { - this.layer = layer; - this.style = style; - this.width = width; - this.height = height; - this.time = time; - this.elevation = elevation; - this.dimensions = dimensions; - this.sld = sld; - this.rule = rule; - this.scale = scale; - this.featureType = featureType; - } - - /** - * @return the layers - */ - public String getLayer() { - return layer; - } - - /** - * @param layers - * the layers to set - */ - public void setLayer(String layer) { - this.layer = layer; - } - - /** - * @return the styles - */ - public String getStyle() { - return style; - } - - /** - * @param styles - * the styles to set - */ - public void setStyle(String style) { - this.style = style; - } - - /** - * @return the width - */ - public Integer getWidth() { - return width; - } - - /** - * @param width - * the width to set - */ - public void setWidth(Integer width) { - this.width = width; - } - - /** - * @return the height - */ - public Integer getHeight() { - return height; - } - - /** - * @param height - * the height to set - */ - public void setHeight(Integer height) { - this.height = height; - } - - /** - * @return the time - */ - public String getTime() { - return time; - } - - /** - * @param time - * the time to set - */ - public void setTime(String time) { - this.time = time; - } - - /** - * @return the elevation - */ - public String getElevation() { - return elevation; - } - - /** - * @param elevation - * the elevation to set - */ - public void setElevation(String elevation) { - this.elevation = elevation; - } - - /** - * @return the dimensions - */ - public Map getDimensions() { - return dimensions; - } - - /** - * @param dimensions - * the dimensions to set - */ - public void setDimensions(Map dimensions) { - this.dimensions = dimensions; - } - - /** - * @return the sld - */ - public StyledLayerDescriptor getSld() { - return sld; - } - - /** - * @param sld - * the sld to set - */ - public void setSld(StyledLayerDescriptor sld) { - this.sld = sld; - } - - public String getRule() { - return rule; - } - - public void setRule(String rule) { - this.rule = rule; - } - - public String getScale() { - return scale; - } - - public void setScale(String scale) { - this.scale = scale; - } - - public String getFeatureType() { - return featureType; - } - - public void setFeatureType(String featureType) { - this.featureType = featureType; - } - - /** - * @return the transparent - */ - public Boolean getTransparent() { - return transparent; - } - - /** - * @param transparent - * the transparent to set - */ - public void setTransparent(Boolean transparent) { - this.transparent = transparent; - } - - /** - * @return the bgcolor - */ - public String getBgcolor() { - return bgcolor; - } - - /** - * @param bgcolor - * the bgcolor to set - */ - public void setBgcolor(String bgcolor) { - this.bgcolor = bgcolor; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.BaseRequest#execute(com.raytheon.uf.edex.wms - * .WmsProvider) - */ - @Override - public OgcResponse execute(WmsProvider provider) { - return provider.getLegendGraphic(this); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetMapRequest.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetMapRequest.java deleted file mode 100644 index d6505dc3cb..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/GetMapRequest.java +++ /dev/null @@ -1,213 +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.wms; - -import java.util.Map; - -import org.geotools.styling.StyledLayerDescriptor; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.wms.WmsProvider.WmsOpType; - -/** - * - * @author bclement - * @version 1.0 - */ -public class GetMapRequest extends BaseRequest { - - protected String[] layers; - - protected String[] styles; - - protected String crs; - - protected String bbox; - - protected Integer width; - - protected Integer height; - - protected Boolean transparent; - - protected String bgcolor; - - protected String time; - - protected String elevation; - - protected Map dimensions; - - protected StyledLayerDescriptor sld; - - public GetMapRequest() { - } - - public GetMapRequest(GetMapRequest req) { - super(req.getVersion(), req.getFormat(), req.getUserName(), req - .getRoles()); - this.layers = req.getLayers(); - this.styles = req.getStyles(); - this.crs = req.getCrs(); - this.crs = req.crs; - this.bbox = req.bbox; - this.width = req.width; - this.height = req.height; - this.transparent = req.transparent; - this.bgcolor = req.bgcolor; - this.time = req.time; - this.elevation = req.elevation; - this.dimensions = req.dimensions; - this.sld = req.sld; - } - - public GetMapRequest(String[] layers, String[] styles, String crs, - String bbox, Integer width, Integer height, Boolean transparent, - String bgcolor, String time, String elevation, - Map dimensions, StyledLayerDescriptor sld) { - super(); - this.layers = layers; - this.styles = styles; - this.crs = crs; - this.bbox = bbox; - this.width = width; - this.height = height; - this.transparent = transparent; - this.bgcolor = bgcolor; - this.time = time; - this.elevation = elevation; - this.dimensions = dimensions; - this.sld = sld; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.BaseRequest#execute(com.raytheon.uf.edex.wms - * .WmsProvider) - */ - @Override - public OgcResponse execute(WmsProvider provider) { - return provider.getMap(this); - } - - public String[] getLayers() { - return layers; - } - - public void setLayers(String[] layers) { - this.layers = layers; - } - - public String[] getStyles() { - return styles; - } - - public void setStyles(String[] styles) { - this.styles = styles; - } - - public Integer getWidth() { - return width; - } - - public void setWidth(Integer width) { - this.width = width; - } - - public Integer getHeight() { - return height; - } - - public void setHeight(Integer height) { - this.height = height; - } - - public Boolean getTransparent() { - return transparent; - } - - public void setTransparent(Boolean transparent) { - this.transparent = transparent; - } - - public String getBgcolor() { - return bgcolor; - } - - public void setBgcolor(String bgcolor) { - this.bgcolor = bgcolor; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public String getElevation() { - return elevation; - } - - public void setElevation(String elevation) { - this.elevation = elevation; - } - - public Map getDimensions() { - return dimensions; - } - - public void setDimensions(Map dimensions) { - this.dimensions = dimensions; - } - - public StyledLayerDescriptor getSld() { - return sld; - } - - public void setSld(StyledLayerDescriptor sld) { - this.sld = sld; - } - - public String getCrs() { - return crs; - } - - public void setCrs(String crs) { - this.crs = crs; - } - - public String getBbox() { - return bbox; - } - - public void setBbox(String bbox) { - this.bbox = bbox; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsException.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsException.java deleted file mode 100644 index 69cab29ba7..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsException.java +++ /dev/null @@ -1,71 +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.wms; - -import com.raytheon.uf.edex.ogc.common.OgcException; - -public class WmsException extends Exception { - - private static final long serialVersionUID = 3643250462683412896L; - - public enum Code { - InvalidFormat, InvalidCRS, LayerNotDefined, StyleNotDefined, LayerNotQueryable, InvalidPoint, CurrentUpdateSequence, InvalidUpdateSequence, MissingDimensionValue, InvalidDimensionValue, OperationNotSupported, MissingParameterValue, InvalidParameterValue, InternalServerError - } - - protected Code code; - - public WmsException(OgcException ogc) { - this(Code.valueOf(ogc.getCode().toString()), ogc.getMessage()); - } - - public WmsException(Code code) { - super(); - this.code = code; - } - - public WmsException(Code code, String message) { - super(message); - this.code = code; - } - - public WmsException(Code code, Throwable cause) { - super(cause); - this.code = code; - } - - public WmsException(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; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsHttpFactory.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsHttpFactory.java deleted file mode 100644 index 41729db7e6..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsHttpFactory.java +++ /dev/null @@ -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 - * ------------ ---------- ----------- -------------------------- - * May 20, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wms; - -import org.apache.commons.pool.KeyedPoolableObjectFactory; - -import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager; -import com.raytheon.uf.edex.wms.provider.OgcGetMapTranslator; -import com.raytheon.uf.edex.wms.provider.OgcWmsProvider; -import com.raytheon.uf.edex.wms.provider.WmsLayerManager; - -/** - * - * @author bclement - * @version 1.0 - */ -public class WmsHttpFactory implements KeyedPoolableObjectFactory { - - protected WmsLayerManager layerManager = new WmsLayerManager(); - - protected OgcJaxbManager jaxbManager; - - protected OgcGetMapTranslator gmTranslator; - - /** - * @param layerManager - * @param jaxbManager - */ - public WmsHttpFactory(OgcJaxbManager jaxbManager, - OgcGetMapTranslator gmTranslator) { - super(); - this.jaxbManager = jaxbManager; - this.gmTranslator = gmTranslator; - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#makeObject(java.lang - * .Object) - */ - @Override - public Object makeObject(Object key) throws Exception { - return new WmsHttpHandler(new OgcWmsProvider(layerManager, jaxbManager, - gmTranslator), gmTranslator.getRegistry()); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#destroyObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void destroyObject(Object key, Object obj) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#validateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public boolean validateObject(Object key, Object obj) { - // TODO Auto-generated method stub - return false; - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#activateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void activateObject(Object key, Object obj) throws Exception { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.commons.pool.KeyedPoolableObjectFactory#passivateObject(java - * .lang.Object, java.lang.Object) - */ - @Override - public void passivateObject(Object key, Object obj) throws Exception { - // TODO Auto-generated method stub - - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsHttpHandler.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsHttpHandler.java deleted file mode 100644 index 2a481d0435..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsHttpHandler.java +++ /dev/null @@ -1,524 +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.wms; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.collections.map.CaseInsensitiveMap; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.geotools.styling.StyledLayerDescriptor; - -import com.raytheon.uf.edex.ogc.common.OgcException; -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.feature.JsonFeatureFormatter; -import com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler; -import com.raytheon.uf.edex.ogc.common.http.OgcHttpRequest; -import com.raytheon.uf.edex.ogc.common.output.OgcResponseOutput; -import com.raytheon.uf.edex.wms.WmsException.Code; -import com.raytheon.uf.edex.wms.WmsProvider.WmsOpType; -import com.raytheon.uf.edex.wms.format.GmlFeatureFormatter; -import com.raytheon.uf.edex.wms.format.HtmlFeatureFormatter; -import com.raytheon.uf.edex.wms.sld.SldParser; -import com.raytheon.uf.edex.wms.sld.SldParserRegistry; -import com.vividsolutions.jts.geom.Envelope; - -public class WmsHttpHandler implements OgcHttpHandler { - - public static final String REQUEST_HEADER = "request"; - - public static final String SLD_HEADER = "sld"; - - public static final String SLD_VERSION_HEADER = "sld_version"; - - public static final String SLD_BODY_HEADER = "sld_body"; - - public static final String VERSION_HEADER = "version"; - - public static final String FORMAT_HEADER = "format"; - - public static final String UPDATESEQ_HEADER = "updatesequence"; - - public static final String LAYERS_HEADER = "layers"; - - public static final String STYLES_HEADER = "styles"; - - public static final String CRS_HEADER = "crs"; - - public static final String BBOX_HEADER = "bbox"; - - public static final String WIDTH_HEADER = "width"; - - public static final String HEIGHT_HEADER = "height"; - - public static final String TRANSPARENT_HEADER = "transparent"; - - public static final String BGCOLOR_HEADER = "bgcolor"; - - public static final String TIME_HEADER = "time"; - - public static final String ELEVATION_HEADER = "elevation"; - - public static final String MIME_HEADER = "Content-Type"; - - public static final String QLAYERS_HEADER = "query_layers"; - - public static final String FCOUNT_HEADER = "feature_count"; - - public static final String IFORMAT_HEADER = "info_format"; - - public static final String I_HEADER = "i"; - - public static final String J_HEADER = "j"; - - public static final String LAYER_HEADER = "layer"; - - public static final String STYLE_HEADER = "style"; - - public static final String RULE_HEADER = "rule"; - - public static final String SCALE_HEADER = "scale"; - - public static final String FEATURE_TYPE_HEADER = "feature_type"; - - protected static final String CAP_PARAM = "getcapabilities"; - - protected static final String MAP_PARAM = "getmap"; - - protected static final String FEAT_PARAM = "getfeatureinfo"; - - protected static final String LEG_PARAM = "getlegendgraphic"; - - protected WmsProvider provider; - - protected Log log = LogFactory.getLog(this.getClass()); - - protected SldParserRegistry sldRegistry; - - public WmsHttpHandler(WmsProvider provider, SldParserRegistry sldRegistry) { - this.provider = provider; - this.sldRegistry = sldRegistry; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.ogc.common.http.OgcHttpHandler#handle(javax.servlet - * .http.HttpServletRequest, javax.servlet.http.HttpServletResponse, - * java.util.Map) - */ - @Override - public void handle(OgcHttpRequest request) { - try { - handleInternal(request); - } catch (Exception e) { - log.error("Unable to handle request", e); - } - } - - protected void handleInternal(OgcHttpRequest ogcRequest) throws Exception { - HttpServletResponse response = ogcRequest.getResponse(); - if (ogcRequest.isPost()) { - InputStream is = ogcRequest.getInputStream(); - sendResponse(response, provider.handlePost(is)); - return; - } - Map headers = ogcRequest.getHeaders(); - String exceptionFormat = getString(headers.get(EXCEP_FORMAT_HEADER)); - if (exceptionFormat == null || exceptionFormat.isEmpty()) { - exceptionFormat = OgcResponse.TEXT_XML_MIME; - } - OgcResponse rval; - - rval = validateExceptionFormat(exceptionFormat); - if (rval != null) { - sendResponse(response, rval); - } - - Object obj = headers.get(REQUEST_HEADER); - if (obj instanceof String) { - String reqName = (String) obj; - rval = getResponse(reqName, ogcRequest.getRequest(), headers); - } else { - rval = handleError(new WmsException(Code.MissingParameterValue, - "Missing parameter: " + REQUEST_HEADER), exceptionFormat); - } - sendResponse(response, rval); - } - - /** - * @param exceptionFormat - * @return - */ - private OgcResponse validateExceptionFormat(String exceptionFormat) { - WmsException ex = validateExceptionFormatAsException(exceptionFormat); - if (ex != null) { - return provider.getError(ex, OgcResponse.TEXT_XML_MIME); - } - return null; - } - - private WmsException validateExceptionFormatAsException( - String exceptionFormat) { - if (!exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_HTML_MIME) - && !exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_XML_MIME) - && !exceptionFormat - .equalsIgnoreCase(OgcResponse.APP_VND_OGC_SE_XML)) { - new WmsException(Code.InvalidParameterValue, - "exceptions parameter invalid"); - } - return null; - } - - protected OgcResponse getResponse(String reqName, - HttpServletRequest request, Map headers) { - BaseRequest req; - OgcResponse rval; - String exceptionFormat = getString(headers.get(EXCEP_FORMAT_HEADER)); - if (exceptionFormat == null || exceptionFormat.isEmpty()) { - exceptionFormat = OgcResponse.TEXT_XML_MIME; - } - try { - req = getRequest(reqName, request, headers); - if (req != null) { - req.setVersion(getString(headers.get(VERSION_HEADER))); - req.setFormat(getString(headers.get(FORMAT_HEADER))); - req.setUpdateSequence(getString(headers.get(UPDATESEQ_HEADER))); - req.setUserName(getString(headers.get(USER_HEADER))); - req.setRoles(getStringArr(headers.get(ROLES_HEADER))); - req.setExceptionFormat(exceptionFormat); - rval = req.execute(provider); - } else { - throw new WmsException(Code.OperationNotSupported, - "No such operation: " + reqName); - } - } catch (WmsException e) { - rval = handleError(e, exceptionFormat); - } - return rval; - } - - protected BaseRequest getRequest(String reqName, - HttpServletRequest request, Map headers) - throws WmsException { - BaseRequest req = null; - if (reqName.equalsIgnoreCase(CAP_PARAM)) { - req = getBaseRequest(request, headers); - } else if (reqName.equalsIgnoreCase(MAP_PARAM)) { - req = parseMapRequest(headers); - } else if (reqName.equalsIgnoreCase(FEAT_PARAM)) { - req = getFeatureInfoReq(headers); - } else if (reqName.equalsIgnoreCase(LEG_PARAM)) { - req = getLegendGraphicReq(headers); - } - - return req; - } - - protected BaseRequest getBaseRequest(HttpServletRequest request, - Map headers) { - OgcServiceInfo serviceInfo = getServiceInfo(request); - BaseRequest req = new BaseRequest(); - req.setServiceinfo(serviceInfo); - return req; - } - - /** - * @param request - */ - private OgcServiceInfo getServiceInfo(HttpServletRequest request) { - int port = request.getServerPort(); - String base = "http://" + request.getServerName(); - if (port != 80) { - base += ":" + port; - } - base += "/wms"; - OgcServiceInfo rval = new OgcServiceInfo(base); - - OgcOperationInfo cap = new OgcOperationInfo( - WmsOpType.GetCapabilities); - cap.setHttpGetRes(base + "?request=" + CAP_PARAM); - cap.addFormat("text/xml"); - rval.addOperationInfo(cap); - - OgcOperationInfo map = new OgcOperationInfo( - WmsOpType.GetMap); - map.setHttpGetRes(base + "?request=" + MAP_PARAM); - map.addFormat("image/gif"); - map.addFormat("image/png"); - // map.addFormat("image/tiff"); - map.addFormat("image/jpeg"); - rval.addOperationInfo(map); - - OgcOperationInfo info = new OgcOperationInfo( - WmsOpType.GetFeatureInfo); - info.setHttpGetRes(base + "?request=" + FEAT_PARAM); - List formats = Arrays.asList(GmlFeatureFormatter.mimeType, - JsonFeatureFormatter.mimeType, HtmlFeatureFormatter.mimeType); - info.setFormats(formats); - rval.addOperationInfo(info); - - OgcOperationInfo legend = new OgcOperationInfo( - WmsOpType.GetLegendGraphic); - legend.setHttpGetRes(base + "?request=" + LEG_PARAM); - legend.addFormat("image/gif"); - legend.addFormat("image/png"); - legend.addFormat("image/jpeg"); - rval.addOperationInfo(legend); - - return rval; - } - - /** - * @param headers - * @return - * @throws WmsException - */ - protected GetFeatureInfoRequest getFeatureInfoReq( - Map headers) throws WmsException { - // TODO lookup provider based on version - // String version = getString(headers.get(VERSION_HEADER)); - GetMapRequest mapReq = parseMapRequest(headers); - - String[] layers = getStringArr(headers.get(QLAYERS_HEADER)); - String format = getString(headers.get(IFORMAT_HEADER)); - Integer i = getInt(headers.get(I_HEADER)); - Integer j = getInt(headers.get(J_HEADER)); - String exFormat = getString(headers.get(EXCEP_FORMAT_HEADER)); - GetFeatureInfoRequest req = new GetFeatureInfoRequest(mapReq, layers, - i, j, format); - Integer count = getInt(headers.get(FCOUNT_HEADER)); - if (count != null) { - req.setFeatureCount(count); - } - req.setExceptionFormat(exFormat); - return req; - } - - protected GetLegendGraphicRequest getLegendGraphicReq( - Map headers) throws WmsException { - String layer = getString(headers.get(LAYER_HEADER)); - String style = getString(headers.get(STYLE_HEADER)); - Integer width = getInt(headers.get(WIDTH_HEADER)); - Integer height = getInt(headers.get(HEIGHT_HEADER)); - String time = getString(headers.get(TIME_HEADER)); - String elevation = getString(headers.get(ELEVATION_HEADER)); - Map dimensions = getDimensions(headers); - StyledLayerDescriptor sld = getSLD(headers); - String rule = getString(headers.get(RULE_HEADER)); - String scale = getString(headers.get(SCALE_HEADER)); - String featureType = getString(headers.get(FEATURE_TYPE_HEADER)); - String bgcolor = getString(headers.get(BGCOLOR_HEADER)); - Boolean transparent = getBool(headers.get(TRANSPARENT_HEADER)); - GetLegendGraphicRequest req = new GetLegendGraphicRequest(layer, style, - width, height, time, elevation, dimensions, sld, rule, scale, - featureType); - req.setTransparent(transparent); - req.setBgcolor(bgcolor); - return req; - } - - protected GetMapRequest parseMapRequest(Map headers) - throws WmsException { - String[] layers = getStringArr(headers.get(LAYERS_HEADER)); - String[] styles = getStringArr(headers.get(STYLES_HEADER)); - if (styles == null) { - throw new WmsException(Code.MissingParameterValue, - "style parameter not in request."); - } - - String crs = getString(headers.get(CRS_HEADER)); - String bbox = getBbox(headers.get(BBOX_HEADER)); - Integer width = getInt(headers.get(WIDTH_HEADER)); - Integer height = getInt(headers.get(HEIGHT_HEADER)); - // String format = getString(headers.get(FORMAT_HEADER)); - Boolean transparent = getBool(headers.get(TRANSPARENT_HEADER)); - String bgcolor = getString(headers.get(BGCOLOR_HEADER)); - // String exceptionFormat = getString(headers.get(EXCEP_FORMAT_HEADER)); - String time = getString(headers.get(TIME_HEADER)); - String elevation = getString(headers.get(ELEVATION_HEADER)); - StyledLayerDescriptor sld = getSLD(headers); - Map dimensions = getDimensions(headers); - return new GetMapRequest(layers, styles, crs, bbox, width, height, - transparent, bgcolor, time, elevation, dimensions, sld); - } - - protected StyledLayerDescriptor getSLD(Map headers) - throws WmsException { - StyledLayerDescriptor rval = null; - String urlStr = getString(headers.get(SLD_HEADER)); - InputStream body = null; - if (urlStr != null) { - try { - URL url = new URL(urlStr); - body = url.openStream(); - } catch (Exception e) { - String msg = "Unable to open SLD at " + urlStr; - log.error(msg, e); - throw new WmsException(Code.InvalidParameterValue, msg); - } - } else if (headers.containsKey(SLD_BODY_HEADER)) { - String str = getString(headers.get(SLD_BODY_HEADER)); - body = new ByteArrayInputStream(str.getBytes(Charset - .forName("UTF-8"))); - } - if (body != null) { - String version = getString(headers.get(SLD_VERSION_HEADER)); - rval = parseSldXml(version, body); - } - return rval; - } - - protected StyledLayerDescriptor parseSldXml(String version, InputStream body) - throws WmsException { - SldParser parser = sldRegistry.getParser(version); - if (parser == null) { - throw new WmsException(Code.InvalidParameterValue, - "Missing or unknown SLD version"); - } - try { - return parser.parse(body); - } catch (Throwable t) { - String msg = "Unable to parse SLD"; - log.error(msg, t); - throw new WmsException(Code.InvalidParameterValue, msg); - } - } - - @SuppressWarnings("unchecked") - protected Map getDimensions(Map headers) { - Map rval = new CaseInsensitiveMap(); - for (String key : headers.keySet()) { - if (key.toLowerCase().startsWith("dim_")) { - String dim = key.substring(4); - rval.put(dim, (String) headers.get(key)); - } - } - return rval; - } - - /** - * @param object - * @return - */ - protected String getBbox(Object object) { - String rval = null; - if (object instanceof String) { - rval = (String) object; - } else if (object instanceof Envelope) { - Envelope env = (Envelope) object; - rval = String.format("%f,%f,%f,%f", env.getMinX(), env.getMinY(), - env.getMaxX(), env.getMinY()); - } - return rval; - } - - protected OgcResponse handleError(WmsException e, String exceptionFormat) { - return provider.getError(e, exceptionFormat); - } - - protected String getString(Object obj) { - String rval = null; - if (obj != null) { - if (obj instanceof String) { - rval = (String) obj; - } - } - return rval; - } - - protected String[] getStringArr(Object obj) { - String[] rval = null; - if (obj != null) { - if (obj instanceof String[]) { - rval = (String[]) obj; - } else if (obj instanceof String) { - rval = ((String) obj).split(","); - } - } - return rval; - } - - protected Integer getInt(Object obj) { - Integer rval = null; - if (obj != null) { - if (obj instanceof Integer) { - rval = (Integer) obj; - } else if (obj instanceof String) { - rval = getInt((String) obj); - } - } - return rval; - } - - protected Integer getInt(String str) { - Integer rval = null; - try { - rval = Integer.parseInt(str); - } catch (Exception e) { - // leave rval as null - } - return rval; - } - - protected Boolean getBool(Object obj) { - Boolean rval = null; - if (obj != null) { - if (obj instanceof Boolean) { - rval = (Boolean) obj; - } else if (obj instanceof String) { - try { - rval = Boolean.parseBoolean((String) obj); - } catch (Exception e) { - // leave rval as null - } - } - } - return rval; - } - - protected void sendResponse(HttpServletResponse httpRes, - OgcResponse response) throws Exception { - try { - OgcResponseOutput.output(response, httpRes); - } catch (OgcException e) { - OgcResponse error = handleError(new WmsException(e), null); - OgcResponseOutput.output(error, httpRes); - } - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsProvider.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsProvider.java deleted file mode 100644 index 1e137e319f..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/WmsProvider.java +++ /dev/null @@ -1,54 +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.wms; - -import java.io.InputStream; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; - -/** - * @author bclement - * - */ -public interface WmsProvider { - - public static final String wmsName = "wms"; - - public enum WmsOpType { - GetCapabilities, GetMap, GetFeatureInfo, GetLegendGraphic - } - - public OgcResponse getCapabilities(BaseRequest req); - - public OgcResponse getMap(GetMapRequest req); - - public OgcResponse getError(WmsException e, String exceptionFormat); - - public OgcResponse handlePost(InputStream in); - - public OgcResponse getFeatureInfo(GetFeatureInfoRequest req); - - public OgcResponse getLegendGraphic(GetLegendGraphicRequest req); -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/format/GmlFeatureFormatter.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/format/GmlFeatureFormatter.java deleted file mode 100644 index 06ea49518d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/format/GmlFeatureFormatter.java +++ /dev/null @@ -1,222 +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.wms.format; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.xml.transform.TransformerException; - -import org.geotools.data.memory.MemoryFeatureCollection; -import org.geotools.feature.FeatureCollection; -import org.geotools.gml.producer.FeatureTransformer; -import org.geotools.gml3.GMLConfiguration; -import org.geotools.referencing.CRS; -import org.geotools.xml.Configuration; -import org.geotools.xml.Encoder; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.Name; - -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcPrefix; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE; -import com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter; - -/** - * - * @author bclement - * @version 1.0 - */ -public class GmlFeatureFormatter implements SimpleFeatureFormatter { - - public static final String mimeType = "text/xml; subtype=\"gml/3.1.1\""; - - public static final String empty = "\n" - + "\n" - + ""; - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#format(java.util - * .List) - */ - @Override - public OgcResponse format(List> features) - throws Exception { - - if (features == null || features.isEmpty()) { - return new OgcResponse(empty, mimeType, TYPE.TEXT); - } - List> colls = getAsCollections(features); - StringBuilder rval = new StringBuilder(); - populate(rval, colls); - return new OgcResponse(rval.toString(), mimeType, TYPE.TEXT); - } - - protected void populate(StringBuilder sb, - List> colls) - throws IOException { - Configuration conf = new GMLConfiguration(); - Encoder encoder = new Encoder(conf); - Iterator> i = colls - .iterator(); - String xml = toXml(i.next(), encoder); - populate(sb, xml, true, !i.hasNext()); - while (i.hasNext()) { - xml = toXml(i.next(), encoder); - populate(sb, xml, false, !i.hasNext()); - } - } - - protected String toXml(FeatureCollection coll, Encoder encoder) - throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FeatureTransformer trans = new FeatureTransformer(); - trans.setIndentation(4); - trans.setGmlPrefixing(true); - trans.getFeatureTypeNamespaces().declareDefaultNamespace(OgcPrefix.GML, - OgcNamespace.GML); - SimpleFeatureType schema = coll.getSchema(); - Name name = schema.getName(); - trans.getFeatureTypeNamespaces().declareNamespace(schema, - name.getLocalPart(), name.getNamespaceURI()); - trans.setCollectionNamespace(null); - trans.setCollectionPrefix(null); - trans.setCollectionBounding(true); - trans.getFeatureNamespaces(); - String srs = CRS.toSRS(schema.getCoordinateReferenceSystem()); - if (srs != null) { - trans.setSrsName(srs); - } - try { - trans.transform(coll, out); - } catch (TransformerException e) { - throw new IOException(e); - } - return new String(out.toByteArray(), encoder.getEncoding()); - } - - protected void populate(StringBuilder sb, String xml, boolean header, - boolean footer) { - String[] parts = split(xml); - if (header) { - sb.append(parts[0]); - sb.append('\n'); - } - sb.append(parts[1]); - sb.append('\n'); - if (footer) { - sb.append(parts[2]); - sb.append('\n'); - } - } - - protected String[] split(String xml) { - String[] rval = new String[3]; - int endHeader; - int beginBody; - int endBody; - int beginFooter; - // FIXME xml should not be parsed like this - int i = xml.indexOf("FeatureCollection"); - endHeader = xml.indexOf('>', i) + 1; - i = xml.indexOf("featureMember"); - beginBody = xml.lastIndexOf('<', i); - i = xml.lastIndexOf("featureMember"); - endBody = xml.indexOf('>', i) + 1; - i = xml.lastIndexOf("FeatureCollection"); - beginFooter = xml.lastIndexOf('<', i); - rval[0] = xml.substring(0, endHeader); - rval[1] = xml.substring(beginBody, endBody); - rval[2] = xml.substring(beginFooter); - return rval; - } - - protected List> getAsCollections( - List> features) { - List> colls = new ArrayList>( - features.size()); - SimpleFeature sample; - for (List l : features) { - if (l == null || l.isEmpty()) { - continue; - } - sample = l.get(0); - MemoryFeatureCollection coll = new MemoryFeatureCollection( - sample.getFeatureType()); - coll.addAll(l); - // ListFeatureCollection coll = new ListFeatureCollection( - // sample.getFeatureType(), l); - colls.add(coll); - } - return colls; - } - - /* - * (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) { - if ( mimeType.equalsIgnoreCase(format)){ - return true; - } - if (format.toLowerCase().contains("gml")) { - return true; - } - return false; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/format/HtmlFeatureFormatter.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/format/HtmlFeatureFormatter.java deleted file mode 100644 index fa506b6dbe..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/format/HtmlFeatureFormatter.java +++ /dev/null @@ -1,155 +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.wms.format; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.util.List; -import java.util.Scanner; - -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.VelocityEngine; -import org.apache.velocity.runtime.RuntimeConstants; -import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; - -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE; -import com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter; - -/** - * - * @author bclement - * @version 1.0 - */ -public class HtmlFeatureFormatter implements SimpleFeatureFormatter { - - public static final String mimeType = "text/html"; - - private VelocityEngine _ve; - - private Template _bodyTemplate; - - private String _header; - - protected String bodyLocation = "META-INF/templates/gfi-html-body.vm"; - - protected String headerLocation = "META-INF/templates/gfi-html-header.txt"; - - protected Template getBodyTemplate() throws Exception { - if (_bodyTemplate == null) { - _ve = new VelocityEngine(); - _ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); - _ve.setProperty("classpath.resource.loader.class", - ClasspathResourceLoader.class.getName()); - _ve.init(); - _bodyTemplate = _ve.getTemplate(bodyLocation); - } - return _bodyTemplate; - } - - protected String getHeader() throws IOException { - if (_header == null) { - ClassLoader loader = this.getClass().getClassLoader(); - InputStream in = loader.getResourceAsStream(headerLocation); - if (in == null) { - throw new IOException("Unable to find classpath resource: " - + headerLocation); - } - _header = new Scanner(in).useDelimiter("\\A").next(); - } - return _header; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#format(java.util - * .List) - */ - @Override - public OgcResponse format(List> features) - throws Exception { - if (features == null || features.isEmpty()) { - return new OgcResponse("", mimeType, TYPE.TEXT); - } - StringBuilder rval = new StringBuilder(getHeader()); - for (List typeList : features) { - addFeatures(typeList, rval); - } - rval.append("\n"); - return new OgcResponse(rval.toString(), mimeType, TYPE.TEXT); - } - - protected void addFeatures(List features, - StringBuilder builder) throws Exception { - if (features == null || features.isEmpty()) { - return; - } - SimpleFeature sample = features.get(0); - SimpleFeatureType type = sample.getType(); - Template t = getBodyTemplate(); - VelocityContext vc = new VelocityContext(); - vc.put("type", type); - vc.put("features", features); - StringWriter writer = new StringWriter(); - t.merge(vc, writer); - builder.append(writer.getBuffer()); - writer.close(); - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#getKey() - */ - @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); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/GetLegendProcessor.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/GetLegendProcessor.java deleted file mode 100644 index 467e7fe77a..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/GetLegendProcessor.java +++ /dev/null @@ -1,116 +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.wms.provider; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.geotools.styling.StyledLayerDescriptor; - -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.reg.WmsSource; -import com.raytheon.uf.edex.wms.styling.SldStyleProvider; -import com.raytheon.uf.edex.wms.util.StyleLibrary; - -public class GetLegendProcessor { - - protected String time; - - protected String elevation; - - protected Map dimensions; - - protected Integer width; - - protected Integer height; - - protected String username; - - protected Set roles; - - protected WmsLayerManager layerManager; - - protected Log log = LogFactory.getLog(this.getClass()); - - public GetLegendProcessor(WmsLayerManager layerManager, String time, - String elevation, Map dimensions, Integer width, - Integer height, String username, String[] roles) { - super(); - this.layerManager = layerManager; - this.time = time; - this.elevation = elevation; - this.dimensions = dimensions; - this.width = width; - this.height = height; - } - - protected WmsSource getSource(String layer) throws WmsException { - return layerManager.getSource(layer, username, roles); - } - - public BufferedImage getLegend(String layerName, String styleName, - boolean includeLabels) throws WmsException { - WmsSource source = getSource(layerName); - return source.getLegend(layerName, styleName, time, elevation, - dimensions, height, width); - } - - public BufferedImage getLegendSld(StyledLayerDescriptor sld) - throws WmsException { - StyleLibrary lib = new StyleLibrary(sld); - return SldStyleProvider.getLegend(lib.getAny(), width, height); - } - - /** - * @param layer - * @param style - * @param sld - * @return - * @throws WmsException - */ - public BufferedImage getLegendStyleLib(String layer, String style, - StyledLayerDescriptor sld) throws WmsException { - SldStyleProvider styler = new SldStyleProvider(sld); - Map dims = new HashMap(0); - Map units = new HashMap(0); - return styler.getLegend(layer, style, dims, units, width, height); - } - - public static BufferedImage applyBackground(BufferedImage img, Color bgColor) { - BufferedImage rval = new BufferedImage(img.getWidth(), img.getHeight(), - BufferedImage.TYPE_INT_ARGB); - Graphics2D g = rval.createGraphics(); - g.setColor(bgColor); - g.fillRect(0, 0, img.getWidth(), img.getHeight()); - g.drawImage(img, 0, 0, null); - g.dispose(); - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/GetMapProcessor.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/GetMapProcessor.java deleted file mode 100644 index e44eec6b73..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/GetMapProcessor.java +++ /dev/null @@ -1,186 +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 - * ------------ ---------- ----------- -------------------------- - * Sep 8, 2011 bclement Initial creation - * - */ -package com.raytheon.uf.edex.wms.provider; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.geotools.styling.NamedLayer; -import org.geotools.styling.Style; -import org.geotools.styling.StyledLayer; -import org.geotools.styling.StyledLayerDescriptor; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.reg.WmsImage; -import com.raytheon.uf.edex.wms.reg.WmsSource; -import com.raytheon.uf.edex.wms.util.StyleLibrary; -import com.vividsolutions.jts.geom.Envelope; - -/** - * - * @author bclement - * @version 1.0 - */ -public class GetMapProcessor { - - protected CoordinateReferenceSystem crs; - protected Envelope env; - protected String time; - protected String elevation; - protected Map dimensions; - protected int width; - protected int height; - protected String username; - protected Set roles; - protected WmsLayerManager layerManager; - protected double scale; - - public GetMapProcessor(WmsLayerManager layerManager, - CoordinateReferenceSystem crs, Envelope env, String time, - String elevation, Map dimensions, int width, - int height, double scale, String username, String[] roles) { - this(layerManager, crs, env, time, elevation, dimensions, width, - height, scale); - this.username = username; - this.roles = getAsSet(roles); - } - - public GetMapProcessor(WmsLayerManager layerManager, - CoordinateReferenceSystem crs, Envelope env, String time, - String elevation, Map dimensions, int width, - int height, double scale) { - super(); - this.layerManager = layerManager; - this.crs = crs; - this.env = env; - this.time = time; - this.elevation = elevation; - this.dimensions = dimensions; - this.width = width; - this.height = height; - this.scale = scale; - } - - public List getMapSld(StyledLayerDescriptor sld) - throws WmsException { - StyledLayer[] layers = sld.getStyledLayers(); - ArrayList rval = new ArrayList(layers.length); - for (StyledLayer sl : layers) { - if (sl instanceof NamedLayer) { - NamedLayer layer = (NamedLayer) sl; - String layerName = layer.getName(); - WmsSource source = getSource(layerName); - Style[] styles = layer.getStyles(); - if (styles == null || styles.length < 1) { - // request a layer with default style - WmsImage img = source.getImage(layerName, null, true, crs, - env, time, elevation, dimensions, scale); - rval.add(img); - } else { - for (Style s : styles) { - WmsImage img = source.getImage(layerName, null, false, - crs, env, time, elevation, dimensions, scale); - img.setStyle(s); - rval.add(img); - } - } - } - } - return rval; - } - - protected WmsSource getSource(String layer) throws WmsException { - return layerManager.getSource(layer); - } - - protected Set getAsSet(String[] strs) { - Set rval = null; - if (strs != null) { - rval = new HashSet(Arrays.asList(strs)); - } - return rval; - } - - public List getMapStyleLib(String[] layers, String[] styles, - StyledLayerDescriptor sld) throws WmsException { - StyleLibrary lib = new StyleLibrary(sld); - ArrayList rval = new ArrayList(layers.length); - for (int i = 0; i < layers.length; ++i) { - String layerName = layers[i]; - WmsSource source = getSource(layerName); - String styleName = styles[i]; - Style style = null; - if (styleName != null && styleName.trim().isEmpty()) { - // use default - style = lib.getDefault(layerName); - } else { - // use library - style = lib.getNamedStyle(styleName); - } - WmsImage img; - if (style == null) { - // not in library, pass to source to see if they know it - img = source.getImage(layerName, styleName, false, crs, env, - time, elevation, dimensions, scale); - } else { - // get without style - img = source.getImage(layerName, null, false, crs, env, time, - elevation, dimensions, scale); - img.setStyle(style); - } - rval.add(img); - } - return rval; - } - - public List getMap(String[] layers, String[] styles) - throws WmsException { - ArrayList rval = new ArrayList(layers.length); - for (int i = 0; i < layers.length; ++i) { - String layerName = layers[i]; - WmsSource source = getSource(layerName); - String styleName = styles[i]; - boolean defaultStyle = (styleName == null || styleName.isEmpty()); - WmsImage img = source.getImage(layerName, styleName, defaultStyle, - crs, env, time, elevation, dimensions, scale); - if (img != null) { - rval.add(img); - } - } - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/OgcGetMapTranslator.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/OgcGetMapTranslator.java deleted file mode 100644 index 82a73b8d3c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/OgcGetMapTranslator.java +++ /dev/null @@ -1,318 +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 - * ------------ ---------- ----------- -------------------------- - * - */ -package com.raytheon.uf.edex.wms.provider; - -import java.math.BigInteger; -import java.util.Arrays; -import java.util.List; - -import javax.xml.datatype.XMLGregorianCalendar; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMResult; - -import net.opengis.ows.v_1_0_0.BoundingBoxType; -import net.opengis.sld.v_1_1_0.ElevationType; -import net.opengis.sld.v_1_1_0.GetMapType; -import net.opengis.sld.v_1_1_0.OutputType; -import net.opengis.sld.v_1_1_0.OutputType.Size; -import net.opengis.sld.v_1_1_0.StyledLayerDescriptorElement; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.dom4j.Element; -import org.dom4j.Namespace; -import org.dom4j.Node; -import org.dom4j.QName; -import org.dom4j.io.DocumentSource; -import org.geotools.styling.StyledLayerDescriptor; -import org.w3c.dom.Document; - -import com.raytheon.uf.common.time.util.TimeUtil; -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcPrefix; -import com.raytheon.uf.edex.wms.GetMapRequest; -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.WmsException.Code; -import com.raytheon.uf.edex.wms.sld.SldParser; -import com.raytheon.uf.edex.wms.sld.SldParserRegistry; - -public class OgcGetMapTranslator { - - protected Log log = LogFactory.getLog(this.getClass()); - - protected SldParserRegistry registry; - - protected Namespace sldNS = new Namespace(OgcPrefix.SLD, OgcNamespace.SLD); - - protected Namespace owsNS = new Namespace(OgcPrefix.OWS, OgcNamespace.OWS); - - protected Namespace wmsNS = new Namespace(OgcPrefix.WMS, OgcNamespace.WMS); - - protected QName sldName = new QName("StyledLayerDescriptor", sldNS); - - protected QName crsName = new QName("CRS", sldNS); - - protected QName bboxName = new QName("BoundingBox", sldNS); - - protected QName lcName = new QName("LowerCorner", owsNS); - - protected QName ucName = new QName("UpperCorner", owsNS); - - protected QName outputName = new QName("Output", sldNS); - - protected QName sizeName = new QName("Size", sldNS); - - protected QName widthName = new QName("Width", sldNS); - - protected QName heightName = new QName("Height", sldNS); - - protected QName formatName = new QName("Format", wmsNS); - - protected QName transparentName = new QName("Transparent", sldNS); - - protected QName execptionsName = new QName("Exceptions", sldNS); - - protected QName elevationName = new QName("Elevation", sldNS); - - protected QName timeName = new QName("Time", sldNS); - - protected QName valueName = new QName("Value", sldNS); - - public OgcGetMapTranslator(SldParserRegistry registry) { - this.registry = registry; - } - - public GetMapRequest translate(Element root) throws WmsException { - GetMapRequest rval = new GetMapRequest(); - rval.setSld(parseSld(root.element(sldName))); - rval.setBbox(parseBbox(root.element(bboxName))); - rval.setCrs(getTextElement(root.element(crsName))); - rval.setElevation(parseElevation(root.element(elevationName))); - parseOutput(root.element(outputName), rval); - rval.setTime(getTextElement(root.element(timeName))); - rval.setExceptionFormat(root.elementTextTrim(execptionsName)); - return rval; - } - - /** - * @param element - * @param rval - */ - protected void parseOutput(Element output, GetMapRequest rval) { - if (output == null) { - return; - } - Element size = output.element(sizeName); - if (size != null) { - try { - String width = size.elementTextTrim(widthName); - rval.setWidth(Integer.valueOf(width)); - String height = size.elementTextTrim(heightName); - rval.setHeight(Integer.valueOf(height)); - } catch (NumberFormatException e) { - // leave sizes null - } - } - rval.setFormat(output.elementTextTrim(formatName)); - rval.setTransparent(getBoolElement(output.element(transparentName))); - } - - protected Boolean getBoolElement(Element elem) { - if (elem == null) { - return null; - } - String txt = elem.getTextTrim(); - return txt != null && txt.equalsIgnoreCase("true"); - } - - protected String parseElevation(Element elev) { - if (elev == null) { - return null; - } - String rval = null; - // TODO handle intervals - Element val = elev.element(valueName); - if (val != null) { - rval = val.getTextTrim(); - } - return rval; - } - - /** - * @param element - * @return - */ - protected String getTextElement(Element elem) { - if (elem == null) { - return null; - } - return elem.getTextTrim(); - } - - /** - * @param element - * @return - */ - protected String parseBbox(Element bboxElem) { - if (bboxElem == null) { - return null; - } - String lcText = bboxElem.elementTextTrim(lcName); - String ucText = bboxElem.elementTextTrim(ucName); - String[] lc = StringUtils.split(lcText); - String[] uc = StringUtils.split(ucText); - List bounds = Arrays.asList(lc[0], lc[1], uc[0], uc[1]); - return StringUtils.join(bounds, ','); - } - - protected StyledLayerDescriptor parseSld(Element e) throws WmsException { - if (e == null) { - return null; - } - String version = e.attributeValue("version"); - SldParser parser = registry.getParser(version); - if (parser == null) { - throw new WmsException(Code.MissingParameterValue, - "SLD version must be specified"); - } - Document doc; - try { - doc = convert(e); - StyledLayerDescriptor rval = parser.parse(doc); - return rval; - } catch (Exception e1) { - log.error("Unable to parse SLD docuement", e1); - throw new WmsException(Code.InternalServerError); - } - } - - protected Document convert(Node n) throws TransformerException { - TransformerFactory factory = TransformerFactory.newInstance(); - Transformer transformer = factory.newTransformer(); - DocumentSource source = new DocumentSource(n); - DOMResult result = new DOMResult(); - transformer.transform(source, result); - return (Document) result.getNode(); - } - - // below are JAXB utility methods (would need jaxb context) - - /** - * @param req - * @return - * @throws Throwable - */ - @Deprecated - protected GetMapRequest translate(GetMapType req) throws Throwable { - GetMapRequest rval = new GetMapRequest(); - rval.setBbox(formatBbox(req.getBoundingBox())); - rval.setCrs(req.getCRS()); - rval.setElevation(formatElevation(req.getElevation())); - parseOutput(req.getOutput(), rval); - rval.setTime(formatTime(req.getTime())); - rval.setSld(translate(req.getStyledLayerDescriptor())); - return rval; - } - - protected String formatBbox(BoundingBoxType bbox) { - if (bbox == null) { - return null; - } - List lc = bbox.getLowerCorner(); - List uc = bbox.getUpperCorner(); - - return String.format("%f,%f,%f,%f", lc.get(0), lc.get(1), uc.get(0), - uc.get(1)); - } - - protected String formatElevation(ElevationType elev) { - if (elev == null) { - return null; - } - List value = elev.getValue(); - if (value != null && !value.isEmpty()) { - return StringUtils.join(value, ","); - } else { - return null; - } - } - - protected void parseOutput(OutputType out, GetMapRequest req) { - if (out == null) { - return; - } - req.setBgcolor(out.getBGcolor()); - req.setFormat(out.getFormat()); - Size size = out.getSize(); - if (size != null) { - BigInteger width = size.getWidth(); - BigInteger height = size.getHeight(); - if (width != null) { - req.setWidth(width.intValue()); - } - if (height != null) { - req.setHeight(height.intValue()); - } - } - } - - protected String formatTime(XMLGregorianCalendar cal) { - if (cal == null) { - return null; - } - return TimeUtil.formatCalendar(cal.toGregorianCalendar()); - } - - protected StyledLayerDescriptor translate(StyledLayerDescriptorElement sld) - throws Throwable { - if (sld == null) { - return null; - } - // FIXME there must be a better way than this - // String xml = manager.marshal(sld); - // InputStream in = new StringInputStream(xml); - // SLDParser stylereader = new SLDParser( - // CommonFactoryFinder.getStyleFactory(null), in); - // return stylereader.parseSLD(); - return null; - } - - public SldParserRegistry getRegistry() { - return registry; - } - - public void setRegistry(SldParserRegistry registry) { - this.registry = registry; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/OgcWmsProvider.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/OgcWmsProvider.java deleted file mode 100644 index 3c570942ad..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/OgcWmsProvider.java +++ /dev/null @@ -1,917 +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.wms.provider; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.image.BufferedImage; -import java.io.InputStream; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import javax.imageio.ImageIO; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -import net.opengis.wms.v_1_3_0.Capability; -import net.opengis.wms.v_1_3_0.DCPType; -import net.opengis.wms.v_1_3_0.Exception; -import net.opengis.wms.v_1_3_0.Get; -import net.opengis.wms.v_1_3_0.HTTP; -import net.opengis.wms.v_1_3_0.Layer; -import net.opengis.wms.v_1_3_0.OnlineResource; -import net.opengis.wms.v_1_3_0.OperationType; -import net.opengis.wms.v_1_3_0.Post; -import net.opengis.wms.v_1_3_0.Request; -import net.opengis.wms.v_1_3_0.Service; -import net.opengis.wms.v_1_3_0.ServiceExceptionReport; -import net.opengis.wms.v_1_3_0.ServiceExceptionType; -import net.opengis.wms.v_1_3_0.WMSCapabilities; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.dom4j.Document; -import org.dom4j.Element; -import org.dom4j.Namespace; -import org.dom4j.QName; -import org.dom4j.io.SAXReader; -import org.geotools.coverage.grid.GeneralGridEnvelope; -import org.geotools.coverage.grid.GridGeometry2D; -import org.geotools.data.memory.MemoryFeatureCollection; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.feature.FeatureCollection; -import org.geotools.geometry.DirectPosition2D; -import org.geotools.geometry.GeneralEnvelope; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.map.DefaultMapContext; -import org.geotools.map.MapContext; -import org.geotools.styling.FeatureTypeStyle; -import org.geotools.styling.NamedLayer; -import org.geotools.styling.Style; -import org.geotools.styling.StyleFactory; -import org.geotools.styling.StyledLayer; -import org.geotools.styling.StyledLayerDescriptor; -import org.opengis.coverage.grid.GridEnvelope; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.geometry.DirectPosition; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.referencing.crs.GeographicCRS; -import org.opengis.referencing.operation.MathTransform2D; -import org.springframework.context.ApplicationContext; - -import com.raytheon.uf.edex.core.EDEXUtil; -import com.raytheon.uf.edex.ogc.common.OgcNamespace; -import com.raytheon.uf.edex.ogc.common.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcPrefix; -import com.raytheon.uf.edex.ogc.common.OgcResponse; -import com.raytheon.uf.edex.ogc.common.OgcResponse.ErrorType; -import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter; -import com.raytheon.uf.edex.ogc.common.jaxb.OgcJaxbManager; -import com.raytheon.uf.edex.ogc.common.spatial.CrsLookup; -import com.raytheon.uf.edex.wms.BaseRequest; -import com.raytheon.uf.edex.wms.GetFeatureInfoRequest; -import com.raytheon.uf.edex.wms.GetLegendGraphicRequest; -import com.raytheon.uf.edex.wms.GetMapRequest; -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.WmsException.Code; -import com.raytheon.uf.edex.wms.WmsHttpHandler; -import com.raytheon.uf.edex.wms.WmsProvider; -import com.raytheon.uf.edex.wms.reg.WmsImage; -import com.raytheon.uf.edex.wms.reg.WmsSource; -import com.raytheon.uf.edex.wms.util.StyleUtility; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Envelope; - -public class OgcWmsProvider implements WmsProvider { - - protected static final String svcTitle = "EDEX Map Server"; - - protected WmsLayerManager layerManager; - - protected OgcJaxbManager jaxbManager; - - private Log log = LogFactory.getLog(this.getClass()); - - protected String resizeHint = "quality"; - - protected OgcGetMapTranslator getMapTranslator; - - protected QName getMapName = new QName("GetMap", new Namespace( - OgcPrefix.SLD, OgcNamespace.SLD)); - - public OgcWmsProvider(WmsLayerManager layerManager, - OgcJaxbManager jaxbManager, OgcGetMapTranslator getMapTranslator) { - this.layerManager = layerManager; - this.jaxbManager = jaxbManager; - this.getMapTranslator = getMapTranslator; - } - - @Override - public OgcResponse getCapabilities(BaseRequest req) { - OgcResponse rval; - try { - WMSCapabilities capabilities = new WMSCapabilities(); - OgcServiceInfo serviceinfo = req.getServiceinfo(); - capabilities.setService(getServiceInfo(serviceinfo)); - capabilities.setCapability(getMainCapability(req)); - rval = marshalResponse(capabilities); - } catch (WmsException e) { - rval = getError(e, req.getExceptionFormat()); - } - return rval; - } - - /** - * @return - */ - protected Service getServiceInfo(OgcServiceInfo serviceInfo) { - Service rval = new Service(); - rval.setName(wmsName); - rval.setTitle(svcTitle); - rval.setOnlineResource(getOLR(serviceInfo.getOnlineResource())); - return rval; - } - - protected OnlineResource getOLR(String href) { - OnlineResource rval = new OnlineResource(); - rval.setHref(href); - return rval; - } - - protected Capability getMainCapability(BaseRequest req) - throws WmsException { - Capability rval = new Capability(); - OgcServiceInfo serviceinfo = req.getServiceinfo(); - rval.setRequest(getValidRequests(serviceinfo.getOperations())); - rval.setException(getExceptionInfo()); - rval.setLayer(getLayerInfo(req)); - return rval; - } - - /** - * @return - * @throws WmsException - */ - protected Layer getLayerInfo(BaseRequest req) - throws WmsException { - Layer rval = new Layer(); - rval.setTitle(svcTitle); - rval.setLayer(getAuthorizedLayers(req)); - return rval; - } - - protected List getAuthorizedLayers(BaseRequest req) - throws WmsException { - // List rval; - // if (req.getUserName() == null) { - // // we aren't doing authorization - // rval = layerManager.getLayers(); - // } else { - // Set userRoles = OgcAuthUtils.getAsSet(req.getRoles()); - // rval = layerManager.getAuthorizedLayers(userRoles); - // } - return layerManager.getLayers(req.getServiceinfo()); - } - - /** - * @return - */ - protected Exception getExceptionInfo() { - Exception rval = new Exception(); - rval.setFormat(Arrays.asList("XML")); - return rval; - } - - /** - * @param operations - * @return - */ - protected Request getValidRequests( - List> operations) { - Request rval = new Request(); - for (OgcOperationInfo op : operations) { - OperationType opType = new OperationType(); - populateOpType(opType, op); - switch (op.getType()) { - case GetCapabilities: - rval.setGetCapabilities(opType); - break; - case GetFeatureInfo: - rval.setGetFeatureInfo(opType); - break; - case GetMap: - rval.setGetMap(opType); - break; - } - } - return rval; - } - - protected void populateOpType(OperationType opType, - OgcOperationInfo info) { - opType.setFormat(info.getFormats()); - DCPType dcpt = new DCPType(); - HTTP http = new HTTP(); - if (info.hasHttpGet()) { - Get get = new Get(); - get.setOnlineResource(getOLR(info.getHttpGetRes())); - http.setGet(get); - } - if (info.hasHttpPost()) { - Post post = new Post(); - post.setOnlineResource(getOLR(info.getHttpPostRes())); - http.setPost(post); - } - dcpt.setHTTP(http); - opType.setDCPType(Arrays.asList(dcpt)); - } - - protected OgcResponse marshalResponse(Object jaxbobject) - throws WmsException { - OgcResponse rval; - try { - String xml = jaxbManager.marshal(jaxbobject); - rval = new OgcResponse(xml, OgcResponse.TEXT_XML_MIME, TYPE.TEXT); - } catch (JAXBException e) { - log.error("Unable to marshal WFS response", e); - throw new WmsException(Code.InternalServerError); - } - return rval; - } - - @Override - public OgcResponse handlePost(InputStream in) { - Element root; - try { - SAXReader reader = new SAXReader(); - Document doc = reader.read(in); - root = doc.getRootElement(); - } catch (java.lang.Exception e) { - log.error("Unable to read post data", e); - return getError(new WmsException(Code.InternalServerError), - OgcResponse.TEXT_XML_MIME); - } - if (root.getQName().equals(getMapName)) { - return getMapPost(root); - } else { - return getError(new WmsException(Code.InvalidParameterValue, - "Post method only supported for GetMap operation"), - OgcResponse.TEXT_XML_MIME); - } - } - - protected OgcResponse getMapPost(Element root) { - GetMapRequest translated; - try { - translated = getMapTranslator.translate(root); - } catch (Throwable e) { - log.error("Unable to converted getmap request", e); - return getError(new WmsException(Code.InternalServerError), - OgcResponse.TEXT_XML_MIME); - } - return getMap(translated); - } - - @Override - public OgcResponse getMap(GetMapRequest req) { - OgcResponse rval = null; - StyledLayerDescriptor sld = req.getSld(); - String[] layers = req.getLayers(); - String[] styles = req.getStyles(); - String time = req.getTime(); - String elevation = req.getElevation(); - Map dimensions = req.getDimensions(); - Integer width = req.getWidth(); - Integer height = req.getHeight(); - boolean sldOnly = sld != null && layers == null; - if ((rval = checkGetMapArgs(req)) != null) { - // there was a problem, return the error - return rval; - } - boolean clear = parseTransparent(req.getTransparent()); - List images; - try { - Iterator it = ImageIO.getImageWritersByMIMEType(req.getFormat()); - if (!it.hasNext()) { - throw new WmsException(Code.InvalidFormat, - "Format not supported: " + req.getFormat()); - } - Color color = parseColor(req.getBgcolor()); - CoordinateReferenceSystem targetCrs = parseCrs(req.getCrs()); - Envelope env = parseEnvString(req.getBbox(), targetCrs); - if (req.getWidth() <= 0 || req.getHeight() <= 0) { - throw new WmsException(Code.InvalidParameterValue, - "Invalid resolution"); - } - String username = req.getUserName(); - String[] roles = req.getRoles(); - double scale = getScale(env, width, height); - GetMapProcessor proc = new GetMapProcessor(layerManager, targetCrs, - env, time, elevation, dimensions, width, height, scale, - username, roles); - if (sld == null) { - images = proc.getMap(layers, styles); - } else if (sldOnly) { - images = proc.getMapSld(sld); - } else { - images = proc.getMapStyleLib(layers, styles, sld); - } - BufferedImage map = mergeWmsImages(images, clear, color, width, - height, env, targetCrs); - rval = new OgcResponse(map, req.getFormat(), TYPE.IMAGE); - } catch (WmsException e) { - rval = getError(e, req.getExceptionFormat()); - } - return rval; - } - - protected Map getStyleMap(StyledLayerDescriptor sld) { - if (sld == null) { - return null; - } - StyledLayer[] layers = sld.getStyledLayers(); - Map rval = new HashMap(); - for (StyledLayer l : layers) { - if (l instanceof NamedLayer) { - NamedLayer nl = (NamedLayer) l; - Style[] styles = nl.getStyles(); - if (styles != null) { - for (Style s : styles) { - rval.put(s.getName(), s); - } - } - } - } - return rval; - } - - protected static boolean isEpsgGeoCrs(CoordinateReferenceSystem crs) { - try { - String auth = crs.getName().getCodeSpace(); - return "epsg".equalsIgnoreCase(auth) - && crs instanceof GeographicCRS; - } catch (NullPointerException e) { - return false; - } - } - - protected Envelope parseEnvString(String str, CoordinateReferenceSystem crs) - throws WmsException { - Envelope rval = null; - try { - if (str != null) { - String[] parts = str.split(","); - if (parts.length >= 4) { - double minx = Double.parseDouble(parts[0]); - double miny = Double.parseDouble(parts[1]); - double maxx = Double.parseDouble(parts[2]); - double maxy = Double.parseDouble(parts[3]); - if (minx > maxx || miny > maxy) { - throw new java.lang.Exception(); - } - if (isEpsgGeoCrs(crs)) { - // EPSG GeoCRS uses lat/lon axis order. Switch to match - // framework order of lon/lat - rval = new Envelope(miny, maxy, minx, maxx); - } else { - rval = new Envelope(minx, maxx, miny, maxy); - } - } else { - throw new java.lang.Exception(); - } - } - } catch (Throwable e) { - throw new WmsException(Code.InvalidParameterValue, "Invalid bbox"); - } - return rval; - } - - /** - * @param crs - * @return - * @throws WmsException - */ - protected CoordinateReferenceSystem parseCrs(String crs) - throws WmsException { - try { - return CrsLookup.lookup(crs); - } catch (Throwable e) { - throw new WmsException(Code.InvalidCRS); - } - } - - protected Color parseColor(String color) throws WmsException { - if (color == null) { - return Color.white; - } - try { - return Color.decode(color); - } catch (NumberFormatException e) { - throw new WmsException(Code.InvalidParameterValue, - "Invalid bgcolor: " + color); - } - } - - protected BufferedImage resize(BufferedImage input, int width, int height) { - BufferedImage rval = input; - // int type = transparent ? BufferedImage.TYPE_INT_ARGB - // : BufferedImage.TYPE_INT_RGB; - int type = BufferedImage.TYPE_INT_ARGB; - boolean quality = !resizeHint.equalsIgnoreCase("speed"); - Object hint = quality ? RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR - : RenderingHints.VALUE_INTERPOLATION_BILINEAR; - int h = quality ? input.getHeight() : height; - int w = quality ? input.getWidth() : width; - - do { - if (quality && w > width) { - w /= 2; - if (w < width) { - w = width; - } - } else { - w = width; - } - if (quality && h > height) { - h /= 2; - if (h < height) { - h = height; - } - } else { - h = height; - } - BufferedImage tmp = new BufferedImage(w, h, type); - Graphics2D g = tmp.createGraphics(); - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); - g.drawImage(rval, 0, 0, w, h, null); - g.dispose(); - rval = tmp; - } while (w != width || h != height); - return rval; - } - - /** - * @param width - * @param height - * @return - */ - protected BufferedImage createBlank(Integer width, Integer height) { - return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); - } - - public static BufferedImage mergeWmsImages(List images, - boolean clear, Color bgcolor, int width, int height, Envelope env, - CoordinateReferenceSystem crs) throws WmsException { - GeneralEnvelope bounds = new GeneralEnvelope(crs); - bounds.setEnvelope(env.getMinX(), env.getMinY(), env.getMaxX(), - env.getMaxY()); - DefaultMapContext map = new DefaultMapContext(); - try { - populateMap(map, images, bounds); - Rectangle dims = new Rectangle(width, height); - ReferencedEnvelope re = new ReferencedEnvelope(env, crs); - if (clear) { - bgcolor = null; - } - return StyleUtility.mapToImage(map, dims, re, bgcolor); - } finally { - if (map != null) { - // map.dispose(); - } - } - } - - protected static void populateMap(MapContext map, List images, - GeneralEnvelope bounds) { - for (WmsImage i : images) { - switch (i.getType()) { - case COVERAGE: - map.addLayer(i.getCoverage(), i.getStyle()); - break; - case FEATURE: - map.addLayer(i.getFeatures(), i.getStyle()); - break; - case STYLE_EMBEDDED_FEATURE: - handleStyledFeatures(map, i.getFeatures()); - break; - case BLANK: - // skip - break; - default: - throw new IllegalStateException("Unkown WMS data type: " - + i.getType()); - } - } - } - - /** - * @param map - * @param features - */ - protected static void handleStyledFeatures(MapContext map, - FeatureCollection features) { - Iterator i = features.iterator(); - StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null); - while (i.hasNext()) { - SimpleFeature feature = i.next(); - Style style = extractStyle(feature, styleFactory); - MemoryFeatureCollection coll = new MemoryFeatureCollection( - feature.getFeatureType()); - coll.addAll(features); - map.addLayer(coll, style); - } - } - - protected static Style extractStyle(SimpleFeature feature, - StyleFactory factory) { - Object styleObj = feature.getAttribute("Style"); - Style style = null; - if (styleObj == null) { - return null; - } - if (styleObj instanceof FeatureTypeStyle) { - style = factory.createStyle(); - style.featureTypeStyles().add((FeatureTypeStyle) styleObj); - } else if (styleObj instanceof Style) { - style = (Style) styleObj; - } - return style; - } - - @Deprecated - protected BufferedImage mergeImages(List images, - boolean clear, Color bgcolor, int width, int height) - throws WmsException { - Iterator i = images.iterator(); - BufferedImage rval = createBlank(width, height); - Graphics2D graphics = rval.createGraphics(); - if (!clear) { - graphics.setColor(bgcolor); - graphics.fillRect(0, 0, width, height); - } - while (i.hasNext()) { - graphics.drawImage(i.next(), 0, 0, null); - } - graphics.dispose(); - return rval; - } - - protected boolean parseTransparent(Boolean transparent) { - if (transparent == null) { - return false; - } - return transparent; - } - - @Override - public OgcResponse getError(WmsException e, String exceptionFormat) { - if (exceptionFormat == null) { - exceptionFormat = "text/xml"; - } - - String rval = ""; - String mimeType = "text/xml"; - if (exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_HTML_MIME)) { - rval = ""; - rval += "
An error occurred performing the request:
"; - rval += "
Error Code: " + e.getCode().toString(); - rval += "
Message: " + e.getMessage() + ""; - mimeType = OgcResponse.TEXT_HTML_MIME; - } else if (exceptionFormat.equalsIgnoreCase(OgcResponse.TEXT_XML_MIME) - || exceptionFormat - .equalsIgnoreCase(OgcResponse.APP_VND_OGC_SE_XML)) { - rval = wmsExceptionToXml(e); - mimeType = OgcResponse.TEXT_XML_MIME; - } - OgcResponse resp = new OgcResponse(rval, mimeType, TYPE.TEXT); - switch (e.getCode()) { - case InternalServerError: - resp.setError(ErrorType.INT_ERR); - break; - case OperationNotSupported: - resp.setError(ErrorType.NOT_IMPLEMENTED); - break; - default: - resp.setError(ErrorType.BAD_REQ); - } - return resp; - } - - private String wmsExceptionToXml(WmsException e) { - ServiceExceptionType exType = new ServiceExceptionType(); - exType.setCode(e.getCode().toString()); - exType.setValue(e.getMessage()); - ServiceExceptionReport report = new ServiceExceptionReport(); - report.setServiceException(Arrays.asList(exType)); - String rval = ""; - try { - JAXBContext context = JAXBContext - .newInstance(ServiceExceptionReport.class); - Marshaller marshaller = context.createMarshaller(); - - StringWriter writer = new StringWriter(); - marshaller.marshal(report, writer); - rval = writer.toString(); - } catch (JAXBException e1) { - log.error(e1); - return fallbackXmlError(e); - } - return rval; - } - - private String fallbackXmlError(WmsException e) { - String rval = ""; - rval += ""; - rval += ""; - rval += ""; - rval += e.getMessage(); - rval += ""; - return rval; - } - - protected OgcResponse checkGetMapArgs(GetMapRequest req) { - StyledLayerDescriptor sld = req.getSld(); - String[] layers = req.getLayers(); - boolean sldOnly = sld != null && layers == null; - OgcResponse rval = null; - List missing = new LinkedList(); - if (!sldOnly && (layers == null || layers.length < 1)) { - missing.add(WmsHttpHandler.LAYERS_HEADER); - } - String[] styles = req.getStyles(); - if (!sldOnly && (styles == null || styles.length < 1)) { - missing.add(WmsHttpHandler.STYLES_HEADER); - } - String crs = req.getCrs(); - if (crs == null || crs.isEmpty()) { - missing.add(WmsHttpHandler.CRS_HEADER); - } - if (req.getBbox() == null) { - missing.add(WmsHttpHandler.BBOX_HEADER); - } - if (req.getWidth() == null) { - missing.add(WmsHttpHandler.WIDTH_HEADER); - } - if (req.getHeight() == null) { - missing.add(WmsHttpHandler.HEIGHT_HEADER); - } - String format = req.getFormat(); - if (format == null || format.isEmpty()) { - missing.add(WmsHttpHandler.FORMAT_HEADER); - } - if (!missing.isEmpty()) { - Iterator i = missing.iterator(); - String msg = "Missing the following parameter(s): " + i.next(); - while (i.hasNext()) { - msg += ", " + i.next(); - } - WmsException e = new WmsException(Code.MissingParameterValue, msg); - rval = getError(e, req.getExceptionFormat()); - } else if (!sldOnly && (layers.length != styles.length)) { - WmsException e = new WmsException(Code.MissingParameterValue, - "must have the same number of layers and styles"); - rval = getError(e, req.getExceptionFormat()); - } - return rval; - } - - public String getResizeHint() { - return resizeHint; - } - - public void setResizeHint(String resizeHint) { - this.resizeHint = resizeHint; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.WmsProvider#getFeatureInfo(com.raytheon.uf.edex - * .wms.GetFeatureInfoRequest) - */ - @Override - public OgcResponse getFeatureInfo(GetFeatureInfoRequest req) { - GetMapRequest mapReq = req.getMapRequest(); - OgcResponse rval; - if ((rval = checkGetMapArgs(mapReq)) != null) { - // problem - return rval; - } - try { - String[] layers = req.getReqLayers(); - if (layers == null || layers.length < 1) { - throw new WmsException(Code.MissingParameterValue, - "Missing query_layers parameter"); - } - if (req.getInfoFormat() == null) { - throw new WmsException(Code.MissingParameterValue, - "Missing info_format parameter"); - } - GridGeometry2D geom = createGridGeometry(mapReq); - Coordinate coord = getCrsCoord(geom, req); - CoordinateReferenceSystem crs = geom.getCoordinateReferenceSystem(); - Envelope bbox = parseEnvString(mapReq.getBbox(), crs); - List> features = new ArrayList>(); - double scale = getScale(bbox, req.getWidth(), req.getHeight()); - for (String layer : layers) { - WmsSource source = layerManager.getSource(layer); - List res = source.getFeatureInfo(layer, - geom.getCoordinateReferenceSystem(), bbox, - mapReq.getTime(), mapReq.getElevation(), - mapReq.getDimensions(), coord, scale); - if (!res.isEmpty()) { - features.add(res); - } - } - rval = formatFeatures(features, req.getInfoFormat()); - } catch (WmsException e) { - rval = getError(e, req.getExceptionFormat()); - } - return rval; - } - - public static double getScale(Envelope env, int width, int height) { - double xscale = Math.abs((double) env.getMaxX() - env.getMinX()) - / width; - double yscale = Math.abs((double) env.getMaxY() - env.getMinY()) - / height; - double average = (xscale + yscale) / 2; - return average; - } - - protected OgcResponse formatFeatures(List> features, - String format) throws WmsException { - SimpleFeatureFormatter formatter = getFormatter(format); - if (formatter == null) { - throw new WmsException(Code.InvalidFormat, "Unknown format " - + format); - } - try { - return formatter.format(features); - } catch (java.lang.Exception e) { - log.error("Problem formatting features", e); - throw new WmsException(Code.InternalServerError); - } - } - - public static SimpleFeatureFormatter getFormatter(String format) { - ApplicationContext ctx = EDEXUtil.getSpringContext(); - String[] beans = ctx.getBeanNamesForType(SimpleFeatureFormatter.class); - for (String bean : beans) { - SimpleFeatureFormatter sff = (SimpleFeatureFormatter) ctx.getBean(bean); - if ( sff.matchesFormat(format) ){ - return sff; - } - } - return null; - } - - protected Coordinate getCrsCoord(GridGeometry2D geom, - GetFeatureInfoRequest req) throws WmsException { - Integer i = req.getI(); - Integer j = req.getJ(); - if (i == null || j == null) { - throw new WmsException(Code.MissingParameterValue, - "Missing I or J parameter"); - } - try { - return getCrsCoord(geom, i, j); - } catch (Throwable e) { - log.error("Problem getting CRS coordinates", e); - throw new WmsException(Code.InternalServerError); - } - } - - public static Coordinate getCrsCoord(GridGeometry2D geom, Integer i, - Integer j) throws Throwable { - MathTransform2D gridToCRS2D = geom.getGridToCRS2D(); - DirectPosition grid = new DirectPosition2D(i, j); - DirectPosition origCrs = new DirectPosition2D(); - gridToCRS2D.transform(grid, origCrs); - return new Coordinate(origCrs.getOrdinate(0), origCrs.getOrdinate(1)); - } - - protected GridGeometry2D createGridGeometry(GetMapRequest mapReq) - throws WmsException { - CoordinateReferenceSystem crs = parseCrs(mapReq.getCrs()); - Envelope bbox = parseEnvString(mapReq.getBbox(), crs); - GeneralEnvelope env = new GeneralEnvelope(crs); - env.setEnvelope(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), - bbox.getMaxY()); - GridEnvelope gridRange = new GeneralGridEnvelope(new int[] { 0, 0 }, - new int[] { mapReq.getWidth(), mapReq.getHeight() }); - GridGeometry2D rval = new GridGeometry2D(gridRange, env); - return rval; - } - - protected OgcResponse checkGetLegendGraphicArgs(GetLegendGraphicRequest req) { - StyledLayerDescriptor sld = req.getSld(); - String layer = req.getLayer(); - boolean sldOnly = sld != null && layer == null; - OgcResponse rval = null; - List missing = new LinkedList(); - if (!sldOnly && layer == null) { - missing.add(WmsHttpHandler.LAYER_HEADER); - } - String format = req.getFormat(); - if (format == null || format.isEmpty()) { - missing.add(WmsHttpHandler.FORMAT_HEADER); - } - if (!missing.isEmpty()) { - Iterator i = missing.iterator(); - String msg = "Missing the following parameter(s): " + i.next(); - while (i.hasNext()) { - msg += ", " + i.next(); - } - WmsException e = new WmsException(Code.MissingParameterValue, msg); - rval = getError(e, req.getExceptionFormat()); - } - return rval; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.wms.WmsProvider#getFeatureInfo(com.raytheon.uf.edex - * .wms.GetFeatureInfoRequest) - */ - @Override - public OgcResponse getLegendGraphic(GetLegendGraphicRequest req) { - OgcResponse rval = null; - StyledLayerDescriptor sld = req.getSld(); - String layer = req.getLayer(); - String style = req.getStyle(); - String time = req.getTime(); - String elevation = req.getElevation(); - Map dimensions = req.getDimensions(); - Integer width = req.getWidth(); - Integer height = req.getHeight(); - boolean sldOnly = sld != null && layer == null; - if ((rval = checkGetLegendGraphicArgs(req)) != null) { - // problem - return rval; - } - String username = req.getUserName(); - String[] roles = req.getRoles(); - try { - BufferedImage legend = null; - GetLegendProcessor proc = new GetLegendProcessor(layerManager, - time, elevation, dimensions, width, height, username, roles); - if (sld == null) { - legend = proc.getLegend(layer, style, true); - } else if (sldOnly) { - // This should never happen because layers is a required. - legend = proc.getLegendSld(sld); - } else { - legend = proc.getLegendStyleLib(layer, style, sld); - } - if (!parseTransparent(req.getTransparent())) { - String bgString = req.getBgcolor(); - legend = GetLegendProcessor.applyBackground(legend, - parseColor(bgString)); - } - rval = new OgcResponse(legend, req.getFormat(), TYPE.IMAGE); - } catch (WmsException e) { - rval = getError(e, req.getExceptionFormat()); - } - - return rval; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/WmsLayerManager.java b/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/WmsLayerManager.java deleted file mode 100644 index 01f24a4f63..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.wms/src/com/raytheon/uf/edex/wms/provider/WmsLayerManager.java +++ /dev/null @@ -1,354 +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.wms.provider; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.opengis.wms.v_1_3_0.BoundingBox; -import net.opengis.wms.v_1_3_0.Dimension; -import net.opengis.wms.v_1_3_0.EXGeographicBoundingBox; -import net.opengis.wms.v_1_3_0.Keyword; -import net.opengis.wms.v_1_3_0.KeywordList; -import net.opengis.wms.v_1_3_0.Layer; -import net.opengis.wms.v_1_3_0.LegendURL; -import net.opengis.wms.v_1_3_0.OnlineResource; -import net.opengis.wms.v_1_3_0.Style; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -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.OgcOperationInfo; -import com.raytheon.uf.edex.ogc.common.OgcServiceInfo; -import com.raytheon.uf.edex.ogc.common.OgcStyle; -import com.raytheon.uf.edex.wms.WmsException; -import com.raytheon.uf.edex.wms.WmsException.Code; -import com.raytheon.uf.edex.wms.WmsProvider.WmsOpType; -import com.raytheon.uf.edex.wms.reg.WmsSource; -import com.raytheon.uf.edex.wms.reg.WmsSourceAccessor; - -/** - * @author bclement - * - */ -public class WmsLayerManager { - - protected HashMap> layermap = new HashMap>(); - - protected WmsSourceAccessor registry = new WmsSourceAccessor(); - - protected boolean caching = false; - - protected String componentPrefix = "wms"; - - private OgcOperationInfo _getLegendOp = null; - - protected Log log = LogFactory.getLog(this.getClass()); - - public WmsSource getSource(String layer) throws WmsException { - return getSource(layer, null, null); - } - - public WmsSource getSource(String layer, String username, Set roles) - throws WmsException { - String key = OgcLayer.getKey(layer); - WmsSource rval = registry.getSources().get(key); - if (rval != null && username != null) { - // if (!OgcAuthUtils.isAuthorized(roles, getSourceRoles(key))) { - // // act like the layer doesn't exist - // rval = null; - // } - } - if (rval == null) { - throw new WmsException(Code.LayerNotDefined, - "No layer registered: " + layer); - } - - return rval; - } - - public List getLayers(OgcServiceInfo ogcServiceInfo) { - if (caching) { - return getLayersCache(ogcServiceInfo); - } else { - return getLayersDirect(ogcServiceInfo); - } - } - - protected List getLayersCache( - OgcServiceInfo ogcServiceInfo) { - List rval = new LinkedList(); - Map sources = registry.getSources(); - for (String key : sources.keySet()) { - WmsSource source = sources.get(key); - List layers; - if (layermap.isEmpty() || source.hasUpdated()) { - layers = getPluginLayers(source, ogcServiceInfo); - layermap.put(key, layers); - } else { - layers = layermap.get(key); - } - rval.addAll(layers); - } - return rval; - } - - protected List getLayersDirect( - OgcServiceInfo ogcServiceInfo) { - List rval = new LinkedList(); - Map sources = registry.getSources(); - for (WmsSource source : sources.values()) { - rval.addAll(getPluginLayers(source, ogcServiceInfo)); - } - return rval; - } - - /** - * @param source - * @param ogcServiceInfo - * @return - */ - protected List getPluginLayers(WmsSource source, - OgcServiceInfo ogcServiceInfo) { - List rval = new LinkedList(); - for (OgcLayer layer : source.listLayers()) { - rval.add(getLayerRecursive(layer, ogcServiceInfo)); - } - return rval; - } - - /** - * @param layer - * @param ogcServiceInfo - * @return - */ - protected Layer getLayerRecursive(OgcLayer layer, - OgcServiceInfo ogcServiceInfo) { - Layer rval = new Layer(); - rval.setTitle(layer.getTitle()); - rval.setName(layer.getName()); - rval.setAbstract(layer.getAbs()); - rval.setKeywordList(getAsKeywordList(layer.getKeywords())); - List crs = layer.getCrs(); - if (crs != null) { - rval.setCRS(crs); - } - rval.setEXGeographicBoundingBox(getExBB(layer.getGeoBoundingBox())); - rval.setBoundingBox(getBB(layer.getBoundingBox())); - rval.setDimension(getDimensions(layer.getDimensions())); - rval.setStyle(getAsStyles(layer.getStyles(), ogcServiceInfo)); - setScaleDenom(rval, layer.getMinScaleDenom(), layer.getMaxScaleDenom()); - List children = new LinkedList(); - if (layer.getChildren() != null) { - for (OgcLayer child : layer.getChildren()) { - children.add(getLayerRecursive(child, ogcServiceInfo)); - } - } - rval.setLayer(children); - return rval; - } - - protected void setScaleDenom(Layer layer, double min, double max) { - if (!Double.isNaN(min)) { - layer.setMinScaleDenominator(min); - } - if (!Double.isNaN(max)) { - layer.setMaxScaleDenominator(max); - } - } - - /** - * @param styles - * @param ogcServiceInfo - * @return - */ - private List