From c2375590d3b2ccc25f9fb9736a0692c4753feab9 Mon Sep 17 00:00:00 2001 From: AWIPS User Date: Tue, 23 Jun 2015 16:18:27 -0600 Subject: [PATCH] copy constructCRSfromWKT from McidasCRSBuilder because eclipse PDE build fails to import gov.noaa.nws.ncep.edex.common Former-commit-id: bd223f5edcbe9ff05e8e07b3bf9fba4f643eb03e [formerly 270312e06b632315022d545c2a353254c704d02e] [formerly bc759b5222b6bb473e2c1f86a49e45a732d88269 [formerly c0cc9e88c6f196585a7316b49941aef648e505b9]] Former-commit-id: a12c497703f7cb8ad53b34b62eb64a02eccfdae0 [formerly dcd3c56bf3281e8f4718636c3d951c404198be2e] Former-commit-id: c5185e7a52236bd249d29b0002fb6f4748de1827 --- .../META-INF/MANIFEST.MF | 5 +- .../util/satellite/SatSpatialFactory.java | 7 +- .../META-INF/MANIFEST.MF | 5 +- .../dataplugin/satellite/SatMapCoverage.java | 80 ++++++++++++++++--- .../META-INF/MANIFEST.MF | 4 +- .../META-INF/MANIFEST.MF | 4 +- 6 files changed, 80 insertions(+), 25 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.satellite/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.plugin.satellite/META-INF/MANIFEST.MF index 6329481bb6..e964b17191 100644 --- a/edexOsgi/com.raytheon.edex.plugin.satellite/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.plugin.satellite/META-INF/MANIFEST.MF @@ -9,7 +9,7 @@ Export-Package: com.raytheon.edex.plugin.satellite, com.raytheon.edex.util.satellite Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", - com.raytheon.uf.common.dataplugin.satellite;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin.satellite;bundle-version="1.14.0", com.raytheon.uf.common.serialization;bundle-version="1.12.1174", com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", com.raytheon.uf.common.geospatial;bundle-version="1.14.1", @@ -23,6 +23,3 @@ Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", com.raytheon.uf.edex.database;bundle-version="1.0.0", com.raytheon.uf.edex.menus;bundle-version="1.0.0", com.raytheon.uf.common.numeric;bundle-version="1.14.0" -Import-Package: gov.noaa.nws.ncep.common.tools, - gov.noaa.nws.ncep.edex.util, - org.apache.commons.codec.binary diff --git a/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/util/satellite/SatSpatialFactory.java b/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/util/satellite/SatSpatialFactory.java index 00a8d142fc..0cda26c158 100644 --- a/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/util/satellite/SatSpatialFactory.java +++ b/edexOsgi/com.raytheon.edex.plugin.satellite/src/com/raytheon/edex/util/satellite/SatSpatialFactory.java @@ -21,7 +21,6 @@ package com.raytheon.edex.util.satellite; import java.awt.geom.Rectangle2D; -import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN; import org.geotools.geometry.DirectPosition2D; import org.opengis.referencing.crs.ProjectedCRS; @@ -376,9 +375,9 @@ public class SatSpatialFactory { int upperLeftLine, int xres, int yres, ProjectedCRS crs, Geometry geometry) { - // do your shit here. - float dx = IDecoderConstantsN.FLOAT_MISSING; - float dy = IDecoderConstantsN.FLOAT_MISSING; + // do your stuff here. + float dx = 999999.f; + float dy = 999999.f; double minX, minY; //if (crsType == PROJ_GVAR) { // for native projection diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/META-INF/MANIFEST.MF index 121389dec4..4a47cfba31 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/META-INF/MANIFEST.MF @@ -15,7 +15,8 @@ Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", com.raytheon.uf.common.dataquery;bundle-version="1.0.0", com.raytheon.uf.common.datastorage;bundle-version="1.12.1174", org.hibernate;bundle-version="1.0.0", - com.raytheon.uf.common.numeric;bundle-version="1.14.0" + com.raytheon.uf.common.numeric;bundle-version="1.14.0", + com.raytheon.uf.edex.decodertools;bundle-version="1.14.0" Export-Package: com.raytheon.uf.common.dataplugin.satellite, com.raytheon.uf.common.dataplugin.satellite.units, com.raytheon.uf.common.dataplugin.satellite.units.counts, @@ -24,5 +25,3 @@ Export-Package: com.raytheon.uf.common.dataplugin.satellite, com.raytheon.uf.common.dataplugin.satellite.units.goes.convert, com.raytheon.uf.common.dataplugin.satellite.units.ir, com.raytheon.uf.common.dataplugin.satellite.units.water -Import-Package: gov.noaa.nws.ncep.common.dataplugin.mcidas, - gov.noaa.nws.ncep.common.tools diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java index 4d750e4330..deafeab968 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/SatMapCoverage.java @@ -20,12 +20,13 @@ package com.raytheon.uf.common.dataplugin.satellite; -import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasMapCoverage; -import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasRecord; -import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasSpatialFactory; -import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN; +//import gov.noaa.nws.ncep.edex.util.McidasCRSBuilder; + +import com.raytheon.uf.edex.decodertools.core.IDecoderConstants; import java.awt.geom.Rectangle2D; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.persistence.Column; import javax.persistence.Entity; @@ -48,16 +49,21 @@ import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.geometry.Envelope2D; import org.geotools.geometry.GeneralEnvelope; import org.geotools.referencing.crs.DefaultGeographicCRS; +import org.geotools.referencing.operation.DefaultMathTransformFactory; import org.hibernate.annotations.Type; import org.opengis.coverage.grid.GridEnvelope; import org.opengis.geometry.Envelope; +import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.FactoryException; +import org.opengis.referencing.NoSuchIdentifierException; import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.crs.ProjectedCRS; import com.raytheon.uf.common.dataplugin.annotations.DataURI; import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject; import com.raytheon.uf.common.geospatial.CRSCache; import com.raytheon.uf.common.geospatial.IGridGeometryProvider; +import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.geospatial.adapter.GeometryAdapter; import com.raytheon.uf.common.geospatial.util.EnvelopeIntersection; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; @@ -90,6 +96,8 @@ import com.vividsolutions.jts.geom.Polygon; * May 19, 2015 mjames@ucar Added decoding of GVAR native projection products, * increased crsWKT to 5120 for GVAR the_geom * May 21, 2015 mjames@ucar Added display capability for GVAR projection products + * Jun 23, 2015 mjames@ucar Copied constructCRSfromWKT and constructCRS from + * McidasCRSBuilder because PDE build dependency failed * */ @Entity @@ -233,10 +241,10 @@ public class SatMapCoverage extends PersistableDataObject implements this.ny = ny; this.dx = dx; this.dy = dy; - this.upperLeftElement = IDecoderConstantsN.INTEGER_MISSING; - this.upperLeftLine = IDecoderConstantsN.INTEGER_MISSING; - this.elementRes = IDecoderConstantsN.INTEGER_MISSING; - this.lineRes = IDecoderConstantsN.INTEGER_MISSING; + this.upperLeftElement = IDecoderConstants.VAL_MISSING; + this.upperLeftLine = IDecoderConstants.VAL_MISSING; + this.elementRes = IDecoderConstants.VAL_MISSING; + this.lineRes = IDecoderConstants.VAL_MISSING; this.crsObject = crs; Geometry latLonGeometry = null; try { @@ -483,8 +491,7 @@ public class SatMapCoverage extends PersistableDataObject implements if (crsObject == null && crsWKT != null) { try { if (this.projection == PROJ_GVAR) { - crsObject = McidasSpatialFactory.getInstance() - .constructCRSfromWKT(crsWKT); + crsObject = constructCRSfromWKT(crsWKT); } else { crsObject = CRSCache.getInstance() @@ -584,5 +591,58 @@ public class SatMapCoverage extends PersistableDataObject implements return false; return true; } + + public static ProjectedCRS constructCRSfromWKT(String crsWKT) { + Pattern p = Pattern.compile("PROJCS\\[\"MCIDAS\\sAREA\\s(.*)\""); + Matcher m = p.matcher(crsWKT); + m.find(); + ProjectedCRS crsObject = null; + if (m.groupCount() == 1) { + String type = m.group(1); + p = Pattern.compile("\\[\"NAV_BLOCK_BASE64\",\\s\"(.*)\"\\],"); + m = p.matcher(crsWKT); + boolean found = m.find(); + if (found) { + String navBlock = m.group(1); + crsObject = constructCRS(type, navBlock); + } + } + + return crsObject; + } + + public static ProjectedCRS constructCRS(String type, String encoded) { + + ParameterValueGroup pvg = null; + + DefaultMathTransformFactory dmtFactory = new DefaultMathTransformFactory(); + try { + pvg = dmtFactory.getDefaultParameters("MCIDAS_AREA_NAV"); + } catch (NoSuchIdentifierException e1) { + e1.printStackTrace(); + } + /* + * semi_major and semi_minor parameters are set to 1, so that no global + * scaling is performed during coordinate transforms by + * org.geotools.referencing.operation.projection.MapProjection based on + * the radius of earth + */ + pvg.parameter("semi_major").setValue(1.0); + pvg.parameter("semi_minor").setValue(1.0); + pvg.parameter("central_meridian").setValue(0.0); + pvg.parameter("NAV_BLOCK_BASE64").setValue(encoded); + + String projectionName = "MCIDAS AREA " + type; + ProjectedCRS mcidasCRS = null; + try { + mcidasCRS = MapUtil.constructProjection(projectionName, pvg); + } catch (NoSuchIdentifierException e) { + e.printStackTrace(); + } catch (FactoryException e) { + e.printStackTrace(); + } + + return mcidasCRS; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.satellite.gini/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.satellite.gini/META-INF/MANIFEST.MF index 8d67243128..eb4ab5d2f7 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.satellite.gini/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.satellite.gini/META-INF/MANIFEST.MF @@ -5,11 +5,11 @@ Bundle-SymbolicName: com.raytheon.uf.edex.plugin.satellite.gini Bundle-Version: 1.14.0.qualifier Bundle-Vendor: RAYTHEON Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Require-Bundle: com.raytheon.edex.plugin.satellite;bundle-version="1.14.1", +Require-Bundle: com.raytheon.edex.plugin.satellite, com.raytheon.uf.common.status;bundle-version="1.14.1", com.raytheon.uf.common.time;bundle-version="1.14.0", com.raytheon.uf.common.dataplugin;bundle-version="1.14.0", - com.raytheon.uf.common.dataplugin.satellite;bundle-version="1.14.0", + com.raytheon.uf.common.dataplugin.satellite, com.raytheon.uf.common.serialization;bundle-version="1.14.2", com.raytheon.uf.common.localization;bundle-version="1.14.1", com.raytheon.uf.common.util;bundle-version="1.14.1", diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.satellite.mcidas/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.plugin.satellite.mcidas/META-INF/MANIFEST.MF index d6433c7784..2f496a3f4c 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.satellite.mcidas/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.plugin.satellite.mcidas/META-INF/MANIFEST.MF @@ -10,8 +10,8 @@ Require-Bundle: com.raytheon.edex.common, javax.measure, org.apache.commons.lang, javax.persistence, - com.raytheon.uf.common.dataplugin.satellite;bundle-version="1.0.0", - com.raytheon.edex.plugin.satellite;bundle-version="1.12.1174" + com.raytheon.uf.common.dataplugin.satellite, + com.raytheon.edex.plugin.satellite Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: com.raytheon.uf.common.localization, com.raytheon.uf.common.menus,