diff --git a/cave/com.raytheon.uf.viz.core.maps.feature/feature.xml b/cave/com.raytheon.uf.viz.core.maps.feature/feature.xml index 39966a4120..f1bbdb3371 100644 --- a/cave/com.raytheon.uf.viz.core.maps.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.core.maps.feature/feature.xml @@ -48,11 +48,4 @@ install-size="0" version="0.0.0"/> - - diff --git a/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/DirectoryDataStorePlugin.java b/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/DirectoryDataStorePlugin.java index b96f4a1fe6..bc181c7b93 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/DirectoryDataStorePlugin.java +++ b/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/DirectoryDataStorePlugin.java @@ -40,7 +40,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Label; import org.geotools.data.DataStore; -import org.geotools.data.directory.DirectoryDataStoreFactory; +import org.geotools.data.shapefile.ShapefileDirectoryFactory; import com.raytheon.uf.viz.gisdatastore.IGisDataStorePlugin; import com.raytheon.uf.viz.gisdatastore.directory.rsc.DirectoryDataStoreResourceData; @@ -57,7 +57,8 @@ import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Dec 6, 2012 randerso Initial creation + * Dec 6, 2012 randerso Initial creation + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -161,7 +162,7 @@ public class DirectoryDataStorePlugin implements IGisDataStorePlugin { URL url = new File(dir).toURI().toURL(); Map params = new HashMap(); - params.put(DirectoryDataStoreFactory.URLP.key, url); + params.put(ShapefileDirectoryFactory.URLP.key, url); DataStoreResourceData rd = constructResourceData(null, params); DataStore dataStore = rd.getDataStore(); diff --git a/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/rsc/DirectoryDataStoreResourceData.java b/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/rsc/DirectoryDataStoreResourceData.java index 8d70b2a3b4..3efe0e2336 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/rsc/DirectoryDataStoreResourceData.java +++ b/cave/com.raytheon.uf.viz.gisdatastore.directory/src/com/raytheon/uf/viz/gisdatastore/directory/rsc/DirectoryDataStoreResourceData.java @@ -29,7 +29,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import org.geotools.data.DataStore; -import org.geotools.data.directory.DirectoryDataStoreFactory; +import org.geotools.data.shapefile.ShapefileDirectoryFactory; import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData; @@ -43,6 +43,7 @@ import com.raytheon.uf.viz.gisdatastore.rsc.DataStoreResourceData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 31, 2012 #1326 randerso Initial creation + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -62,7 +63,7 @@ public class DirectoryDataStoreResourceData extends DataStoreResourceData { @Override protected DataStore constructDataStore() throws IOException { - DirectoryDataStoreFactory factory = new DirectoryDataStoreFactory(); + ShapefileDirectoryFactory factory = new ShapefileDirectoryFactory(); Map params = new HashMap(); for (Entry entry : getConnectionParameters().entrySet()) { if (entry.getValue() instanceof Serializable) { diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java index b66a290b8a..363825fe35 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/DataStoreResource.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -37,11 +36,12 @@ import org.eclipse.swt.graphics.Rectangle; import org.geotools.coverage.grid.GeneralGridEnvelope; import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.data.DataStore; -import org.geotools.data.DefaultQuery; -import org.geotools.data.FeatureSource; +import org.geotools.data.Query; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.GeoTools; -import org.geotools.feature.FeatureCollection; import org.geotools.geometry.GeneralEnvelope; import org.geotools.geometry.jts.JTS; import org.geotools.referencing.operation.DefaultMathTransformFactory; @@ -114,6 +114,7 @@ import com.vividsolutions.jts.geom.Point; * Jul 24, 2013 #1907 randerso Fixed sampling when cropped * Jul 24, 2013 #1908 randerso Update attributes when cropped * Feb 18, 2014 #2819 randerso Removed unnecessary clones of geometries + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -626,7 +627,7 @@ public class DataStoreResource extends private void loadAttributes() { ITimer timer = TimeUtil.getTimer(); timer.start(); - DefaultQuery query = new DefaultQuery(); + Query query = new Query(); query.setTypeName(typeName); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools @@ -654,17 +655,17 @@ public class DataStoreResource extends } query.setFilter(ff.or(filterList)); - FeatureCollection featureCollection = null; - Iterator featureIterator = null; + SimpleFeatureCollection featureCollection = null; + SimpleFeatureIterator featureIterator = null; try { - FeatureSource featureSource = dataStore + SimpleFeatureSource featureSource = dataStore .getFeatureSource(typeName); featureCollection = featureSource.getFeatures(query); int size = featureCollection.size(); attributes = new Object[size][attributeNames.length]; - featureIterator = featureCollection.iterator(); + featureIterator = featureCollection.features(); int i = 0; while (featureIterator.hasNext()) { int index = i++; @@ -686,7 +687,7 @@ public class DataStoreResource extends e.getLocalizedMessage(), e); } finally { if (featureIterator != null) { - featureCollection.close(featureIterator); + featureIterator.close(); } } timer.stop(); @@ -1264,7 +1265,7 @@ public class DataStoreResource extends // ITimer timer = TimeUtil.getTimer(); // timer.start(); - DefaultQuery query = new DefaultQuery(); + Query query = new Query(); query.setTypeName(typeName); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools @@ -1315,16 +1316,16 @@ public class DataStoreResource extends // query.setFilter(ff.and(clickFilter, boundingFilter)); query.setFilter(clickFilter); - FeatureCollection featureCollection = null; - Iterator featureIterator = null; + SimpleFeatureCollection featureCollection = null; + SimpleFeatureIterator featureIterator = null; List features; try { - FeatureSource featureSource = dataStore + SimpleFeatureSource featureSource = dataStore .getFeatureSource(typeName); featureCollection = featureSource.getFeatures(query); features = new ArrayList(featureCollection.size()); - featureIterator = featureCollection.iterator(); + featureIterator = featureCollection.features(); while (featureIterator.hasNext()) { SimpleFeature f = featureIterator.next(); @@ -1339,7 +1340,7 @@ public class DataStoreResource extends features = Collections.emptyList(); } finally { if (featureIterator != null) { - featureCollection.close(featureIterator); + featureIterator.close(); } } diff --git a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/ReloadJob.java b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/ReloadJob.java index f200aa8df6..8c9683006b 100644 --- a/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/ReloadJob.java +++ b/cave/com.raytheon.uf.viz.gisdatastore/src/com/raytheon/uf/viz/gisdatastore/rsc/ReloadJob.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; @@ -17,11 +16,12 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.graphics.RGB; -import org.geotools.data.DefaultQuery; -import org.geotools.data.FeatureSource; +import org.geotools.data.Query; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.GeoTools; -import org.geotools.feature.FeatureCollection; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.filter.Filter; @@ -57,6 +57,7 @@ import com.vividsolutions.jts.geom.Point; * Feb 22, 2013 #1641 randerso Added checks for using ID as label or shading attribute * Jul 24, 2014 #1908 randerso Removed debug sysouts * Feb 18, 2014 #2819 randerso Removed unnecessary clones of geometries + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -206,8 +207,8 @@ class ReloadJob extends Job { // System.out.println("Processing request: " + req.number); Result result = new Result(); - FeatureCollection featureCollection = null; - Iterator featureIterator = null; + SimpleFeatureCollection featureCollection = null; + SimpleFeatureIterator featureIterator = null; try { if (pendingRequest != null) { // System.out.println("Canceling request: " + req.number); @@ -262,7 +263,7 @@ class ReloadJob extends Job { String shapeField = schema.getGeometryDescriptor() .getLocalName(); - DefaultQuery query = new DefaultQuery(); + Query query = new Query(); String typeName = req.rsc.getTypeName(); query.setTypeName(typeName); @@ -285,11 +286,11 @@ class ReloadJob extends Job { query.setFilter(ff.or(filterList)); } - FeatureSource featureSource = req.rsc - .getDataStore().getFeatureSource(typeName); + SimpleFeatureSource featureSource = req.rsc.getDataStore() + .getFeatureSource(typeName); featureCollection = featureSource.getFeatures(query); - featureIterator = featureCollection.iterator(); + featureIterator = featureCollection.features(); // TODO: do we need to implement the GeometryCache/gidMap // stuff like in DbMapResource? @@ -467,7 +468,7 @@ class ReloadJob extends Job { result.cause = e; } finally { if (featureIterator != null) { - featureCollection.close(featureIterator); + featureIterator.close(); } if (result != null) { // System.out.println("Completed request: " + req.number); diff --git a/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/spatial/ShapefileQuery.java b/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/spatial/ShapefileQuery.java deleted file mode 100644 index 3c8f0f76f8..0000000000 --- a/cave/com.raytheon.viz.core/src/com/raytheon/viz/core/spatial/ShapefileQuery.java +++ /dev/null @@ -1,212 +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.viz.core.spatial; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.geotools.data.DefaultQuery; -import org.geotools.data.shapefile.indexed.IndexType; -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.factory.GeoTools; -import org.geotools.feature.FeatureIterator; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; - -import com.raytheon.uf.common.dataquery.requests.RequestConstraint; -import com.raytheon.uf.common.geospatial.AbstractSpatialQuery; -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.geospatial.SpatialException; -import com.raytheon.uf.common.geospatial.SpatialQueryResult; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.util.FileUtil; -import com.raytheon.uf.viz.core.VizApp; -import com.vividsolutions.jts.geom.Geometry; - -/** - * ShapefileQuery - * - *
- * 
- *    SOFTWARE HISTORY
- *   
- *    Date         Ticket#     Engineer    Description
- *    ------------ ----------  ----------- --------------------------
- *    Nov 15, 2007             chammack    Initial Creation.
- * 
- * 
- * - * @author chammack - * @version 1 - */ -public class ShapefileQuery extends AbstractSpatialQuery { - - protected ShapefileQuery() { - - } - - private SpatialQueryResult[] wrap(List features) { - SpatialQueryResult[] results = new SpatialQueryResult[features.size()]; - - for (int i = 0; i < results.length; i++) { - SimpleFeature f = features.get(i); - results[i] = new SpatialQueryResult(); - results[i].geometry = (Geometry) f.getDefaultGeometry(); - results[i].attributes = new HashMap(); - - List types = f.getFeatureType() - .getAttributeDescriptors(); - - for (int k = 0; k < types.size(); k++) { - String name = types.get(k).getLocalName(); - Object value = f.getAttribute(k); - results[i].attributes.put(name, value); - } - - } - - return results; - - } - - @Override - public Object[] dbRequest(String sql, String dbname) - throws SpatialException { - // TODO Auto-generated method stub - return null; - } - - @Override - public SpatialQueryResult[] query(String dataSet, String theGeomField, - String[] attributes, Geometry areaGeometry, - Map filter, SearchMode mode) - throws SpatialException { - File shapeFile = null; - LocalizationFile[] files = PathManagerFactory.getPathManager() - .listStaticFiles(FileUtil.join(VizApp.getMapsDir(), dataSet), - null, false, true); - for (LocalizationFile file : files) { - File f = file.getFile(); - if (f.getName().endsWith(".shp")) { - shapeFile = f; - // we don't break so we make sure all needed shapefiles are - // downloaded - } - } - - if (shapeFile == null) { - throw new SpatialException("Shapefile Not Found: " + dataSet); - } - - FeatureIterator featureIterator = null; - try { - IndexedShapefileDataStore ds = new IndexedShapefileDataStore( - shapeFile.toURI().toURL(), null, true, true, IndexType.QIX); - - String[] types = ds.getTypeNames(); - - DefaultQuery query = new DefaultQuery(); - query.setTypeName(types[0]); - - FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools - .getDefaultHints()); - - Filter shpFilter = null; - if (areaGeometry != null) { - ReferencedEnvelope bbox = new ReferencedEnvelope( - areaGeometry.getEnvelopeInternal(), - MapUtil.LATLON_PROJECTION); - - shpFilter = ff.bbox(ff.property(theGeomField), bbox); - } - if (filter != null) { - Set keySet = filter.keySet(); - for (String key : keySet) { - RequestConstraint constraint = filter.get(key); - Filter compare = null; - switch (constraint.getConstraintType()) { - case EQUALS: { - compare = ff.equal(ff.property(key), - ff.literal(constraint.getConstraintValue()), - false); - break; - } - case NOT_EQUALS: { - compare = ff.notEqual(ff.property(key), - ff.literal(constraint.getConstraintValue()), - false); - break; - } - } - if (shpFilter == null) { - shpFilter = compare; - } else { - shpFilter = ff.and(shpFilter, compare); - } - } - } - - query.setFilter(shpFilter); - - featureIterator = ds.getFeatureSource().getFeatures(query) - .features(); - - List featureList = new ArrayList(); - while (featureIterator.hasNext()) { - SimpleFeature feature = featureIterator.next(); - Geometry geometry = (Geometry) feature.getDefaultGeometry(); - if (areaGeometry == null - || (mode == SearchMode.CONTAINS && areaGeometry - .contains(geometry))) { - featureList.add(feature); - } else if (mode == SearchMode.INTERSECTS - && areaGeometry.intersects(geometry)) { - featureList.add(feature); - } - } - - return wrap(featureList); - } catch (Exception e) { - throw new SpatialException("Error Querying Shapefile", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - } - - @Override - public SpatialQueryResult[] query(String dataSet, String theGeomField, - String[] attributes, Geometry areaGeometry, - Map filter, SearchMode mode, - Integer limit) throws SpatialException { - // not implemented - return null; - } -} diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java index 43a0fee298..2f22180ef4 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java @@ -41,6 +41,7 @@ import org.geotools.coverage.grid.GridEnvelope2D; import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.geometry.DirectPosition2D; import org.geotools.geometry.Envelope2D; +import org.opengis.geometry.DirectPosition; import org.opengis.referencing.FactoryException; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.MathTransform; @@ -94,6 +95,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Aug 19, 2011 bsteffen Initial creation * Jun 07, 2013 2070 bsteffen Add geospatial constraints to metar * precip requests. + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -197,8 +199,8 @@ public class MetarPrecipResource extends IExtent extent = paintProps.getView().getExtent(); - double threshold = PLOT_PIXEL_SIZE * magnification / density; - threshold = threshold * extent.getWidth() + double threshold = (PLOT_PIXEL_SIZE * magnification) / density; + threshold = (threshold * extent.getWidth()) / paintProps.getCanvasBounds().width; for (RenderablePrecipData data : precips) { @@ -294,7 +296,7 @@ public class MetarPrecipResource extends List precips = getPrecipData(descriptor .getTimeForResource(this)); - if (precips == null || precips.isEmpty()) { + if ((precips == null) || precips.isEmpty()) { return null; } @@ -401,7 +403,7 @@ public class MetarPrecipResource extends .doubleValue(); DirectPosition2D dp = new DirectPosition2D(lon, lat); toDescriptor.transform(dp, dp); - if (envelope.contains(dp)) { + if (envelope.contains((DirectPosition) dp)) { newStations.add(map.get("location.stationId").toString()); long validTime = pdo.getDataTime().getMatchValid(); if (validTime < earliestTime) { @@ -481,7 +483,7 @@ public class MetarPrecipResource extends int curIndex = frameInfo.getFrameIndex(); int count = frameInfo.getFrameCount(); // This will generate the number series 0, -1, 1, -2, 2, -3, 3... - for (int i = 0; i < count / 2 + 1; i = i < 0 ? -i : -i - 1) { + for (int i = 0; i < ((count / 2) + 1); i = i < 0 ? -i : -i - 1) { int index = (count + curIndex + i) % count; DataTime next = times[index]; if (next != null) { diff --git a/cave/com.raytheon.viz.shapefile/.classpath b/cave/com.raytheon.viz.shapefile/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/cave/com.raytheon.viz.shapefile/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/cave/com.raytheon.viz.shapefile/.project b/cave/com.raytheon.viz.shapefile/.project deleted file mode 100644 index ab260a358b..0000000000 --- a/cave/com.raytheon.viz.shapefile/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.raytheon.viz.shapefile - - - - - - 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/cave/com.raytheon.viz.shapefile/.settings/org.eclipse.jdt.core.prefs b/cave/com.raytheon.viz.shapefile/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index d282f1e0f5..0000000000 --- a/cave/com.raytheon.viz.shapefile/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Thu Mar 26 11:04:31 CDT 2009 -eclipse.preferences.version=1 -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/cave/com.raytheon.viz.shapefile/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.shapefile/META-INF/MANIFEST.MF deleted file mode 100644 index dd8cfbe976..0000000000 --- a/cave/com.raytheon.viz.shapefile/META-INF/MANIFEST.MF +++ /dev/null @@ -1,19 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Shapefile Plug-in -Bundle-SymbolicName: com.raytheon.viz.shapefile;singleton:=true -Bundle-Version: 1.12.1174.qualifier -Bundle-Activator: com.raytheon.viz.shapefile.rsc.Activator -Bundle-Vendor: Raytheon -Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.viz.ui -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.geotools, - com.raytheon.viz.core, - com.raytheon.viz.ui, - org.apache.commons.lang, - com.raytheon.uf.viz.core.maps;bundle-version="1.0.0" -Bundle-ActivationPolicy: lazy -Export-Package: com.raytheon.viz.shapefile.rsc, - com.raytheon.viz.shapefile.wizard -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/cave/com.raytheon.viz.shapefile/build.properties b/cave/com.raytheon.viz.shapefile/build.properties deleted file mode 100644 index e9863e281e..0000000000 --- a/cave/com.raytheon.viz.shapefile/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/cave/com.raytheon.viz.shapefile/com.raytheon.viz.shapefile.ecl b/cave/com.raytheon.viz.shapefile/com.raytheon.viz.shapefile.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cave/com.raytheon.viz.shapefile/plugin.xml b/cave/com.raytheon.viz.shapefile/plugin.xml deleted file mode 100644 index 5b4b2c3543..0000000000 --- a/cave/com.raytheon.viz.shapefile/plugin.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/action/ShapefileImportAction.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/action/ShapefileImportAction.java deleted file mode 100644 index 27fa32083f..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/action/ShapefileImportAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ - -/** - * - */ -package com.raytheon.viz.shapefile.action; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.wizard.WizardDialog; - -import com.raytheon.viz.shapefile.wizard.ShapefileWizard; -import com.raytheon.viz.ui.VizWorkbenchManager; - -/** - * Import a shapefile, using the shapefile wizard - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 7/1/06                   chammack    Initial Creation.
- * 
- * 
- * - * @author chammack - * @version 1 - */ -public class ShapefileImportAction extends AbstractHandler { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands - * .ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent arg0) throws ExecutionException { - ShapefileWizard wizard = new ShapefileWizard(); - WizardDialog dialog = new WizardDialog(VizWorkbenchManager - .getInstance().getCurrentWindow().getShell(), wizard); - dialog.create(); - dialog.open(); - return null; - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/Activator.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/Activator.java deleted file mode 100644 index f234b2e16f..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/Activator.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.shapefile.rsc; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.raytheon.viz.shapefile.rsc"; - - // The shared instance - private static Activator plugin; - - /** - * The constructor - */ - public Activator() { - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileResource.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileResource.java deleted file mode 100644 index 039495e6db..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileResource.java +++ /dev/null @@ -1,991 +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.viz.shapefile.rsc; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.swt.graphics.RGB; -import org.geotools.coverage.grid.GeneralGridGeometry; -import org.geotools.data.DefaultQuery; -import org.geotools.data.shapefile.ShapefileDataStore; -import org.geotools.data.shapefile.indexed.IndexType; -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; -import org.geotools.factory.CommonFactoryFinder; -import org.geotools.factory.GeoTools; -import org.geotools.feature.FeatureIterator; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.feature.IllegalAttributeException; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.filter.Filter; -import org.opengis.filter.FilterFactory2; -import org.opengis.filter.expression.Expression; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import com.raytheon.uf.common.geospatial.MapUtil; -import com.raytheon.uf.common.geospatial.ReferencedCoordinate; -import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; -import com.raytheon.uf.viz.core.PixelExtent; -import com.raytheon.uf.viz.core.datastructure.WireframeCache; -import com.raytheon.uf.viz.core.drawables.IFont; -import com.raytheon.uf.viz.core.drawables.IShadedShape; -import com.raytheon.uf.viz.core.drawables.IWireframeShape; -import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.map.MapDescriptor; -import com.raytheon.uf.viz.core.maps.rsc.AbstractMapResource; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; -import com.raytheon.uf.viz.core.rsc.capabilities.LabelableCapability; -import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; -import com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability; -import com.raytheon.viz.core.rsc.jts.JTSCompiler; -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Envelope; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.MultiPoint; -import com.vividsolutions.jts.geom.Point; -import com.vividsolutions.jts.geom.Polygonal; -import com.vividsolutions.jts.index.strtree.STRtree; - -/** - * Shapefile resource - * - * Provides shapefile rendering support - * - *
- * 
- *      SOFTWARE HISTORY
- *     
- *      Date            Ticket#     Engineer    Description
- *      ------------	----------	-----------	--------------------------
- *      7/1/06                      chammack    Initial Creation.
- *      02/11/09                    njensen     Refactored to new rsc architecture
- * 
- * 
- * - * @author chammack - * - * - */ -public class ShapefileResource extends - AbstractMapResource { - - protected ShapefileResource(ShapefileResourceData resourceData, - LoadProperties props) { - super(resourceData, props); - } - - protected static final double INQUIRY_TOLERANCE = 0.001; - - protected static final double POINT_INQUIRY_TOLERANCE = 0.01; - - protected String shapeField = null; - - protected IndexedShapefileDataStore dataStore; - - protected GeneralGridGeometry initializedGridGeometry; - - protected IWireframeShape outlineShape; - - protected IShadedShape shadedShape; - - protected Map colorMap; - - protected boolean isShadedCalculated; - - protected String colorMapAttribute; - - protected float simplificationLevel; - - protected String[] theShapefileAttributes; - - protected boolean isRegularPolygon; - - protected boolean isSpatiallySplit; - - protected STRtree rTree; - - protected IGraphicsTarget lastTarget; - - protected IFont font; - - private static final int MAX_DISPLAYED_LABELS = 150; - - protected class LabelNode { - public String label; - - public Coordinate c; - } - - /** *********************** Move colormaps to better location **** */ - static final int[] rgbRed = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 23, 39, 55, 71, 87, 103, 119, 135, - 151, 167, 183, 199, 215, 231, 247, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 246, 228, 211, - 193, 175, 158, 140 }; - - static final int[] rgbGreen = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 27, 43, 59, - 75, 91, 107, 123, 139, 155, 171, 187, 203, 219, 235, 251, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 247, 231, 215, 199, 183, 167, 151, 135, 119, 103, 87, 71, 55, - 39, 23, 7, 0, 0, 0, 0, 0, 0, 0 }; - - static final int[] rgbBlue = { 0, 143, 159, 175, 191, 207, 223, 239, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 247, 231, 215, 199, 183, 167, 151, 135, 119, 103, - 87, 71, 55, 39, 23, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }; - - /* - * (non-Javadoc) - * - * @seecom.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core. - * IGraphicsTarget) - */ - @Override - protected void initInternal(IGraphicsTarget target) throws VizException { - super.initInternal(target); - getCapability(LabelableCapability.class).setAvailableLabelFields( - resourceData.getLabelFields()); - - loadSDS(); - - if (colorMapAttribute != null) { - getCapability(ShadeableCapability.class).setShadingField( - colorMapAttribute); - } else { - colorMapAttribute = getCapability(ShadeableCapability.class) - .getShadingField(); - } - if (colorMapAttribute != null) { - getCapability(ShadeableCapability.class).setAvailableShadingFields( - new String[] { colorMapAttribute }); - } else { - getCapability(ShadeableCapability.class).setAvailableShadingFields( - new String[] {}); - } - if (this.colorMapAttribute != null && this.colorMap == null) { - generateUniqueColorMap(colorMapAttribute); - } - - IWireframeShape cachedShape = WireframeCache.getInstance() - .checkWireframe(resourceData.getFilename(), - descriptor.getGridGeometry()); - if (cachedShape != null) { - this.outlineShape = cachedShape; - } else { - long t0 = System.currentTimeMillis(); - if (simplificationLevel > 0.0f) { - - outlineShape = target.createWireframeShape(false, descriptor, - 0.0f, isSpatiallySplit, new PixelExtent(descriptor - .getGridGeometry().getGridRange().getLow(0), - descriptor.getGridGeometry().getGridRange() - .getHigh(0), descriptor - .getGridGeometry().getGridRange() - .getLow(1), descriptor - .getGridGeometry().getGridRange() - .getHigh(1))); - } else { - outlineShape = target.createWireframeShape(false, descriptor); - } - - shadedShape = target.createShadedShape(false, descriptor, - !isRegularPolygon); - - loadShp(); - - WireframeCache.getInstance().registerWireframe( - resourceData.getFilename(), descriptor.getGridGeometry(), - this.outlineShape); - System.out.println("Shapefile load took: " - + (System.currentTimeMillis() - t0) + "ms"); - } - - this.initializedGridGeometry = this.descriptor.getGridGeometry(); - this.lastTarget = target; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.rsc.IVizResource#isApplicable(com.raytheon.viz. - * core.PixelExtent) - */ - public boolean isApplicable(PixelExtent extent) { - return true; - } - - /* - * (non-Javadoc) - * - * @seecom.raytheon.viz.core.rsc.IVizResource#paint(com.raytheon.viz.core. - * IGraphicsTarget, com.raytheon.viz.core.PixelExtent, double, float) - */ - @Override - @SuppressWarnings("unchecked") - protected void paintInternal(IGraphicsTarget aTarget, - PaintProperties paintProps) throws VizException { - float alpha = paintProps.getAlpha(); - - if (isShadedCalculated - && getCapability(ShadeableCapability.class).getShadingField() != null - && shadedShape != null && shadedShape.isDrawable()) { - float opacity = getCapability(ShadeableCapability.class) - .getOpacity(); - aTarget.drawShadedShape(shadedShape, alpha * opacity); - } - - if (getCapability(OutlineCapability.class).isOutlineOn() - && outlineShape != null && outlineShape.isDrawable()) { - aTarget.drawWireframeShape(outlineShape, - getCapability(ColorableCapability.class).getColor(), - getCapability(OutlineCapability.class).getOutlineWidth(), - getCapability(OutlineCapability.class).getLineStyle(), - alpha); - } - - if (getCapability(LabelableCapability.class).getLabelField() != null - && this.rTree != null && this.rTree.size() > 0) { - - Envelope env = this.descriptor.pixelToWorld(paintProps.getView() - .getExtent()); - - List results = this.rTree.query(env); - - if (results.size() < MAX_DISPLAYED_LABELS) { - if (font == null) { - font = aTarget.initializeFont(aTarget.getDefaultFont() - .getFontName(), 10, null); - } - - double screenToWorldRatio = paintProps.getCanvasBounds().width - / paintProps.getView().getExtent().getWidth(); - - for (LabelNode n : results) { - double[] pixel = descriptor.worldToPixel(new double[] { - n.c.x, n.c.y }); - if (pixel == null) { - continue; - } - - double offsetX = getCapability(LabelableCapability.class) - .getxOffset() / screenToWorldRatio; - double offsetY = getCapability(LabelableCapability.class) - .getyOffset() / screenToWorldRatio; - - aTarget.drawString( - font, - n.label, - pixel[0] + offsetX, - pixel[1] + offsetY, - 0.0, - IGraphicsTarget.TextStyle.NORMAL, - getCapability(ColorableCapability.class).getColor(), - HorizontalAlignment.CENTER, null); - - } - font.dispose(); - } - } - } - - protected void loadSDS() throws VizException { - try { - File file = resourceData.getShapeFile(); - - // Use GRX -- RTree index - // takes longer to build initially, but faster queries than QuadTree - - dataStore = new IndexedShapefileDataStore(file.toURI().toURL(), - null, false, true, IndexType.QIX); - - theShapefileAttributes = ShapefileUtil.getAttributes(dataStore, - true); - - } catch (Exception e) { - throw new VizException("Error loading shapefile: ", e); - } - - } - - protected void loadShp() throws VizException { - - // use a temporary tree until it's built - STRtree rTree = new STRtree(); - - FeatureIterator featureIterator = null; - try { - - // TODO: pass the crs on to JTSCompiler to indicate projection of - // shapefile data. - CoordinateReferenceSystem crs = dataStore.getFeatureSource() - .getSchema().getGeometryDescriptor() - .getCoordinateReferenceSystem(); - - shapeField = dataStore.getFeatureSource().getSchema() - .getGeometryDescriptor().getLocalName(); - - String[] types = dataStore.getTypeNames(); - - DefaultQuery query = new DefaultQuery(); - - query.setTypeName(types[0]); - - if (isShadedCalculated) { - Set valSet = new HashSet(); - valSet.add(resourceData.getLabelFields()[0]); - valSet.add(colorMapAttribute); - valSet.add(shapeField); - query.setPropertyNames(valSet.toArray(new String[valSet.size()])); - } else { - query.setPropertyNames(new String[] { - resourceData.getLabelFields()[0], shapeField }); - } - - featureIterator = dataStore.getFeatureSource().getFeatures(query) - .features(); - - JTSCompiler jtsCompiler = new JTSCompiler(shadedShape, - outlineShape, descriptor); - - StringBuffer sb = new StringBuffer(); - - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - Geometry o = (Geometry) f.getDefaultGeometry(); - sb.setLength(0); - - Point center = o.getCentroid(); - if (resourceData.getLabelFields() != null) { - - sb.append(f.getAttribute(0)); - - } - - LabelNode node = new LabelNode(); - node.c = center.getCoordinate(); - node.label = sb.toString(); - - rTree.insert(new Envelope(center.getCoordinate()), node); - - RGB color = null; - - if (isShadedCalculated) { - Object attrib = f.getAttribute(0); - color = colorMap.get(attrib); - } - try { - jtsCompiler.handle(o, color); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - rTree.build(); - - // assign into the rTree attribute for use by the paint method - // don't do this until after finished inserting or the next insert - // after a paint call will fail - this.rTree = rTree; - - outlineShape.compile(); - - if (isShadedCalculated) { - shadedShape.compile(); - } - - } catch (Exception e) { - throw new VizException("Error reading shapefile " - + resourceData.getFilename().toString() + "", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - - } - - } - - @Override - public Map interrogate(ReferencedCoordinate coord) - throws VizException { - Map retVal = new HashMap(); - FeatureIterator featureIterator = null; - - try { - Coordinate latLon = coord.asLatLon(); - String[] types = dataStore.getTypeNames(); - - DefaultQuery query = new DefaultQuery(); - query.setTypeName(types[0]); - query.setPropertyNames(theShapefileAttributes); - - FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools - .getDefaultHints()); - ReferencedEnvelope bbox = new ReferencedEnvelope(latLon.x - - INQUIRY_TOLERANCE, latLon.x + INQUIRY_TOLERANCE, latLon.y - - INQUIRY_TOLERANCE, latLon.y + INQUIRY_TOLERANCE, - MapUtil.LATLON_PROJECTION); - Filter bboxFilter = ff.bbox(ff.property(shapeField), bbox); - - query.setFilter(bboxFilter); - featureIterator = dataStore.getFeatureSource().getFeatures(query) - .features(); - - GeometryFactory gf = new GeometryFactory(); - boolean done = false; - String geomName = dataStore.getSchema().getGeometryDescriptor() - .getLocalName(); - Class geomType = dataStore.getSchema().getGeometryDescriptor() - .getType().getBinding(); - boolean pointType = false; - if (geomType == Point.class || geomType == MultiPoint.class) { - pointType = true; - } - - while (featureIterator.hasNext() && !done) { - SimpleFeature f = featureIterator.next(); - - if (pointType == false - && !((Geometry) f.getDefaultGeometry()).intersects(gf - .toGeometry(bbox))) { - continue; - } - - for (int k = 0; k < theShapefileAttributes.length; k++) { - - if (!theShapefileAttributes[k].equals(geomName)) { - retVal.put(theShapefileAttributes[k], f.getAttribute(k) - .toString()); - } - - } - done = true; - } - } catch (Exception e) { - throw new VizException("Error interrogating resource: ", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - - return retVal; - } - - @Override - @SuppressWarnings("unchecked") - public String inspect(ReferencedCoordinate coord) throws VizException { - FeatureIterator featureIterator = null; - - StringBuffer sb = new StringBuffer(); - try { - Coordinate latLon = coord.asLatLon(); - String[] types = dataStore.getTypeNames(); - - DefaultQuery query = new DefaultQuery(); - query.setTypeName(types[0]); - - String[] fields = new String[resourceData.getLabelFields().length + 1]; - System.arraycopy(resourceData.getLabelFields(), 0, fields, 0, - resourceData.getLabelFields().length); - fields[resourceData.getLabelFields().length] = shapeField; - - query.setPropertyNames(fields); - FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools - .getDefaultHints()); - Class geomType = dataStore.getSchema().getGeometryDescriptor() - .getType().getBinding(); - boolean polygonal = Polygonal.class.isAssignableFrom(geomType); - - GeometryFactory gf = new GeometryFactory(); - Point llPoint = gf.createPoint(latLon); - Filter filter; - if (polygonal) { - filter = ff.contains(ff.property(shapeField), - ff.literal(llPoint)); - } else { - // TODO: make the box sized in screen pixels not degrees - ReferencedEnvelope bbox = new ReferencedEnvelope(latLon.x - - POINT_INQUIRY_TOLERANCE, latLon.x - + POINT_INQUIRY_TOLERANCE, latLon.y - - POINT_INQUIRY_TOLERANCE, latLon.y - + POINT_INQUIRY_TOLERANCE, MapUtil.LATLON_PROJECTION); - Geometry envelopeGeometry = gf.toGeometry(bbox); - filter = ff.intersects(ff.literal(envelopeGeometry), - ff.property(shapeField)); - // filter = ff.dwithin(ff.property(shapeField), ff - // .literal(llPoint), 1.0, "km"); - } - - query.setFilter(filter); - featureIterator = dataStore.getFeatureSource().getFeatures(query) - .features(); - - boolean done = false; - while (featureIterator.hasNext() && !done) { - SimpleFeature f = featureIterator.next(); - - for (int k = 0; k < resourceData.getLabelFields().length; k++) { - - if (k != 0) { - sb.append(" "); - } - String s = f.getAttribute(k).toString(); - sb.append(StringUtils.isBlank(s) ? "unknown" : s); - - } - done = true; - } - - } catch (Throwable e) { - throw new VizException("Error inspecting resource: ", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - return sb.toString(); - } - - protected void useColorMap(int number, String attribute) { - - colorMap = new HashMap(); - switch (number) { - case -22: - colorMap.put(-3, new RGB(0, 0, 0)); - colorMap.put(-2, new RGB(50, 79, 79)); - colorMap.put(-1, new RGB(0, 236, 236)); - colorMap.put(0, new RGB(1, 160, 246)); - colorMap.put(1, new RGB(0, 0, 246)); - colorMap.put(2, new RGB(0, 255, 0)); - colorMap.put(3, new RGB(0, 200, 0)); - colorMap.put(4, new RGB(0, 144, 0)); - colorMap.put(5, new RGB(255, 255, 0)); - colorMap.put(6, new RGB(231, 192, 0)); - colorMap.put(7, new RGB(255, 144, 0)); - colorMap.put(8, new RGB(255, 0, 0)); - colorMap.put(9, new RGB(214, 0, 0)); - colorMap.put(10, new RGB(192, 0, 0)); - colorMap.put(11, new RGB(255, 0, 255)); - colorMap.put(12, new RGB(153, 85, 201)); - colorMap.put(13, new RGB(235, 235, 235)); - break; - } - isShadedCalculated = true; - getCapability(ShadeableCapability.class).setShadingField(attribute); - colorMapAttribute = attribute; - } - - protected void generateUniqueColorMap(String attribute) throws VizException { - - FeatureIterator featureIterator = null; - try { - String[] types = dataStore.getTypeNames(); - DefaultQuery dq = new DefaultQuery(); - dq.setTypeName(types[0]); - dq.setPropertyNames(new String[] { attribute }); - featureIterator = dataStore.getFeatureSource().getFeatures(dq) - .features(); - - Random rand = new Random(System.currentTimeMillis()); - - colorMap = new HashMap(); - - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - Object attrib = f.getAttribute(0); - RGB c = colorMap.get(attrib); - if (c == null) { - c = new RGB(rand.nextInt(255), rand.nextInt(255), - rand.nextInt(255)); - colorMap.put(attrib, c); - } - } - isShadedCalculated = true; - getCapability(ShadeableCapability.class).setShadingField(attribute); - colorMapAttribute = attribute; - } catch (Exception e) { - throw new VizException("Error generating colormap: ", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - - } - - public static HashMap generateRandomAttributeMap( - String attribute, File theShape) throws VizException { - FeatureIterator featureIterator = null; - try { - - ShapefileDataStore theSDS = new ShapefileDataStore(theShape.toURI() - .toURL(), null, true); - - String[] types = theSDS.getTypeNames(); - DefaultQuery dq = new DefaultQuery(); - dq.setTypeName(types[0]); - dq.setPropertyNames(new String[] { attribute }); - featureIterator = theSDS.getFeatureSource().getFeatures(dq) - .features(); - - Random rand = new Random(System.currentTimeMillis()); - - HashMap theColorMap = new HashMap(); - - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - Object attrib = f.getAttribute(0); - RGB c = theColorMap.get(attrib); - if (c == null) { - c = new RGB(rand.nextInt(255), rand.nextInt(255), - rand.nextInt(255)); - theColorMap.put(attrib, c); - } - } - - return theColorMap; - } catch (Exception e) { - throw new VizException("Error generating colormap: ", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - } - - public static HashMap generateRGBColorMap(String attribute, - File theShape) throws VizException { - FeatureIterator featureIterator = null; - try { - - ShapefileDataStore theSDS = new ShapefileDataStore(theShape.toURI() - .toURL(), null, true); - - String[] types = theSDS.getTypeNames(); - DefaultQuery dq = new DefaultQuery(); - dq.setTypeName(types[0]); - dq.setPropertyNames(new String[] { attribute }); - featureIterator = theSDS.getFeatureSource().getFeatures(dq) - .features(); - - HashMap theColorMap = new HashMap(); - - // Calc max/min - float max = Float.MIN_VALUE; - float min = Float.MAX_VALUE; - - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - float attrib; - Object o = f.getAttribute(0); - if (o instanceof String) { - attrib = Float.parseFloat((String) o); - } else { - attrib = ((Number) o).floatValue(); - } - if (max < attrib) { - max = attrib; - } - - if (min > attrib) { - min = attrib; - } - } - - float diff = max - min; - - // Second pass, assign colors - featureIterator = theSDS.getFeatureSource().getFeatures(dq) - .features(); - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - Object o = f.getAttribute(0); - float attrib; - if (o instanceof String) { - attrib = Float.parseFloat((String) o); - } else { - attrib = ((Number) o).floatValue(); - } - - RGB c = theColorMap.get(o); - if (c == null) { - int idx = (int) ((attrib - min) / diff * 63); - c = new RGB(rgbRed[idx], rgbGreen[idx], rgbBlue[idx]); - theColorMap.put(o, c); - } - - } - - return theColorMap; - } catch (IOException e) { - throw new VizException("Error generating colormap: ", e); - } catch (IllegalAttributeException e) { - throw new VizException("Error generating colormap: ", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.rsc.IVizResource#dispose() - */ - @Override - protected void disposeInternal() { - - WireframeCache.getInstance().unregisterWireframe( - resourceData.getFilename(), descriptor.getGridGeometry()); - - if (shadedShape != null) { - shadedShape.dispose(); - } - shadedShape = null; - - if (colorMap != null) { - colorMap.clear(); - } - - if (font != null) { - font.dispose(); - } - - lastTarget = null; - - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.rsc.IVizResource#getCoordinateReferenceSystem() - */ - public CoordinateReferenceSystem getCoordinateReferenceSystem() { - return null; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.rsc.capabilities.IAnalyzableResource#intersection - * (com.vividsolutions.jts.geom.Geometry) - */ - public Geometry intersection(Geometry geom) throws VizException { - FeatureIterator featureIterator = null; - List geomList = new ArrayList(); - - try { - - String[] types = dataStore.getTypeNames(); - - DefaultQuery query = new DefaultQuery(); - query.setTypeName(types[0]); - - String[] fields = new String[resourceData.getLabelFields().length + 1]; - for (int i = 0; i < resourceData.getLabelFields().length; i++) { - fields[i] = resourceData.getLabelFields()[i]; - } - fields[resourceData.getLabelFields().length] = shapeField; - - query.setPropertyNames(fields); - FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(GeoTools - .getDefaultHints()); - ReferencedEnvelope bbox = new ReferencedEnvelope( - geom.getEnvelopeInternal(), MapUtil.LATLON_PROJECTION); - Expression geometry = ff.property(shapeField); - - Filter bboxFilter = ff.bbox(geometry, bbox); - - query.setFilter(bboxFilter); - featureIterator = dataStore.getFeatureSource().getFeatures(query) - .features(); - - GeometryFactory gf = new GeometryFactory(); - - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - - Geometry g = (Geometry) f.getDefaultGeometry(); - if (!g.intersects(gf.toGeometry(bbox))) { - continue; - } - - Geometry intersection = g.intersection(geom); - geomList.add(intersection); - } - - if (geomList.size() == 0) { - return null; - } - if (geomList.size() == 1) { - return geomList.get(0); - } - - Geometry[] geomArray = geomList.toArray(new Geometry[geomList - .size()]); - return gf.createGeometryCollection(geomArray); - - } catch (Exception e) { - throw new VizException("Error inspecting resource: ", e); - } finally { - if (featureIterator != null) { - featureIterator.close(); - } - } - - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.core.rsc.capabilities.IAnalyzableResource#union(com. - * vividsolutions.jts.geom.Geometry) - */ - public Geometry union(Geometry geom) { - // TODO Auto-generated method stub - return null; - } - - /** - * @return the isRegularPolygon - */ - public boolean isRegularPolygon() { - return isRegularPolygon; - } - - /** - * @return the colorMap - */ - public Map getColorMap() { - return colorMap; - } - - /** - * @param colorMap - * the colorMap to set - */ - public void setColorMap(Map colorMap) { - this.colorMap = colorMap; - this.isShadedCalculated = true; - } - - /** - * @param colorMap - * the colorMap to set - */ - public void setColorMapId(int colormapId) { - useColorMap(colormapId, colorMapAttribute); - } - - /** - * @return the colorMapAttribute - */ - public String getColorMapAttribute() { - return colorMapAttribute; - } - - /** - * @param colorMapAttribute - * the colorMapAttribute to set - */ - public void setColorMapAttribute(String colorMapAttribute) - throws VizException { - this.colorMapAttribute = colorMapAttribute; - } - - /** - * @return the isSpatiallySplit - */ - public boolean isSpatiallySplit() { - return isSpatiallySplit; - } - - /** - * @param isSpatiallySplit - * the isSpatiallySplit to set - */ - public void setSpatiallySplit(boolean isSpatiallySplit) { - this.isSpatiallySplit = isSpatiallySplit; - } - - /** - * @return the simplificationLevel - */ - public float getSimplificationLevel() { - return simplificationLevel; - } - - /** - * @param simplificationLevel - * the simplificationLevel to set - */ - public void setSimplificationLevel(float simplificationLevel) { - this.simplificationLevel = simplificationLevel; - } - - /** - * @param isRegularPolygon - * the isRegularPolygon to set - */ - public void setRegularPolygon(boolean isRegularPolygon) { - this.isRegularPolygon = isRegularPolygon; - } - - @Override - public void project(CoordinateReferenceSystem mapData) throws VizException { - - if (this.outlineShape != null) { - WireframeCache.getInstance().unregisterWireframe( - resourceData.getFilename(), initializedGridGeometry); - - } - if (this.shadedShape != null) { - this.shadedShape.reset(); - this.shadedShape = null; - } - - this.initInternal(this.lastTarget); - } - - public IndexedShapefileDataStore getShapefileObject() { - return dataStore; - } -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileResourceData.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileResourceData.java deleted file mode 100644 index 5a912510b5..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileResourceData.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.viz.shapefile.rsc; - -import java.io.File; -import java.io.FileNotFoundException; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; - -import org.eclipse.swt.graphics.RGB; - -import com.raytheon.uf.viz.core.drawables.IDescriptor; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator; -import com.raytheon.uf.viz.core.rsc.AbstractResourceData; -import com.raytheon.uf.viz.core.rsc.AbstractVizResource; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 11, 2009            njensen     Initial creation
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -@XmlAccessorType(XmlAccessType.NONE) -public class ShapefileResourceData extends AbstractResourceData { - - private static final RGB COLOR = new RGB(155, 155, 155); - - @XmlElement - private String filename; - - @XmlElement - protected String[] labelFields; - - /** The human readable name */ - @XmlElement - private String mapName = null; - - private File shapeFile; - - public ShapefileResourceData() { - super(); - this.nameGenerator = new AbstractNameGenerator() { - - @Override - public String getName(AbstractVizResource resource) { - if (mapName != null) { - return mapName; - } - - return filename; - } - - }; - } - - public ShapefileResourceData(String filename, String[] labelFields) { - this(); - this.filename = filename; - this.labelFields = labelFields; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon - * .uf.viz.core.comm.LoadProperties, - * com.raytheon.uf.viz.core.drawables.IDescriptor) - */ - @Override - public ShapefileResource construct(LoadProperties loadProperties, - IDescriptor descriptor) throws VizException { - shapeFile = new File(filename); - if (shapeFile == null || shapeFile.exists() == false) { - throw new VizException("Could not find shapefile", - new FileNotFoundException(String.valueOf(shapeFile))); - } - ShapefileResource rsc = new ShapefileResource(this, loadProperties); - rsc.getCapability(ColorableCapability.class).setColor(COLOR); - - return rsc; - } - - protected File getShapeFile() { - return shapeFile; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object - * ) - */ - @Override - public void update(Object updateData) { - // TODO Auto-generated method stub - - } - - /** - * @return the filename - */ - public String getFilename() { - return filename; - } - - /** - * @param filename - * the filename to set - */ - public void setFilename(String filename) { - this.filename = filename; - } - - /** - * @return the labelFields - */ - public String[] getLabelFields() { - return labelFields; - } - - /** - * @param labelFields - * the labelFields to set - */ - public void setLabelFields(String[] labelFields) { - this.labelFields = labelFields; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || obj instanceof ShapefileResourceData == false) { - return false; - } - ShapefileResourceData other = (ShapefileResourceData) obj; - - if (this.mapName != null && other.mapName == null) { - return false; - } else if (this.mapName == null && other.mapName != null) { - return false; - } else if (this.mapName != null - && this.mapName.equals(other.mapName) == false) { - return false; - } - - if (this.filename != null && other.filename == null) { - return false; - } else if (this.filename == null && other.filename != null) { - return false; - } else if (this.filename != null - && this.filename.equals(other.filename) == false) { - return false; - } - - return true; - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileUtil.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileUtil.java deleted file mode 100644 index 4c9ef241d4..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/ShapefileUtil.java +++ /dev/null @@ -1,95 +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.viz.shapefile.rsc; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.List; - -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; -import org.opengis.feature.type.AttributeDescriptor; - -import com.raytheon.uf.viz.core.exception.VizException; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Feb 11, 2009            njensen     Initial creation
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class ShapefileUtil { - - public static String[] getAttributes(File shapefile) throws VizException { - return getAttributes(shapefile, true); - } - - public static String[] getAttributes(File aShapeFile, - boolean includeGeometry) throws VizException { - - try { - IndexedShapefileDataStore ds = new IndexedShapefileDataStore( - aShapeFile.toURI().toURL(), false, true); - - return getAttributes(ds, includeGeometry); - - } catch (MalformedURLException e) { - throw new VizException("Bad file", e); - } catch (IOException e) { - throw new VizException("Error reading shapefile ", e); - } - } - - public static String[] getAttributes(IndexedShapefileDataStore ds, - boolean includeGeometry) throws IOException { - String[] retVal = null; - List at = ds.getSchema().getAttributeDescriptors(); - if (at == null || at.size() == 0) { - return null; - } - - if (includeGeometry) { - retVal = new String[at.size()]; - } else { - retVal = new String[at.size() - 1]; - } - - int j = 0; - - for (int i = 0; i < at.size(); i++) { - if (includeGeometry || !at.get(i).getLocalName().equals("the_geom")) { - retVal[j] = at.get(i).getLocalName(); - j++; - } - } - return retVal; - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/package-info.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/package-info.java deleted file mode 100644 index 42191fa827..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/rsc/package-info.java +++ /dev/null @@ -1,23 +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. - **/ -/** - * Shapefile support - */ -package com.raytheon.viz.shapefile.rsc; \ No newline at end of file diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizard.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizard.java deleted file mode 100644 index 326bb521f7..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizard.java +++ /dev/null @@ -1,270 +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.viz.shapefile.wizard; - -import java.io.File; -import java.util.HashMap; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -import com.raytheon.uf.viz.core.IDisplayPaneContainer; -import com.raytheon.uf.viz.core.drawables.IDescriptor; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.rsc.LoadProperties; -import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; -import com.raytheon.uf.viz.core.rsc.capabilities.ShadeableCapability; -import com.raytheon.viz.shapefile.rsc.ShapefileResource; -import com.raytheon.viz.shapefile.rsc.ShapefileResourceData; -import com.raytheon.viz.ui.EditorUtil; - -/** - * Shapefile Wizard - * - *
- * SOFTWARE HISTORY
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 7/1/06                   chammack    Initial Creation.
- * 
- * 
- * - * @author chammack - * @version 1 - */ -public class ShapefileWizard extends Wizard implements INewWizard { - - private String theShpFile; - - private String theLabelAttribute; - - private ShapefileWizardFilePage theFilePage; - - private ShapefileWizardLayerPage theLayerPage; - - private ShapefileWizardColorPage theColorPage; - - private boolean isShaded; - - private boolean isRegularPolygon; - - private String theShadedAttribute; - - private HashMap colorMap; - - // private boolean isFinished; - - public ShapefileWizard() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ - @Override - public void addPages() { - theFilePage = new ShapefileWizardFilePage(); - addPage(theFilePage); - theLayerPage = new ShapefileWizardLayerPage(); - addPage(theLayerPage); - theColorPage = new ShapefileWizardColorPage(); - addPage(theColorPage); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ - @Override - public boolean performFinish() { - Job j = new Job(theLabelAttribute) { - - @Override - protected IStatus run(IProgressMonitor anMonitor) { - IDisplayPaneContainer editor = EditorUtil - .getActiveVizContainer(); - if (editor != null) { - IDescriptor desc = editor.getActiveDisplayPane() - .getRenderableDisplay().getDescriptor(); - ShapefileResource vector = null; - File f = new File(theShpFile); - boolean spatiallySplit = false; - long sz = f.length(); - if (sz > (10 * 1024 * 1024)) { - // split the file - spatiallySplit = true; - } - try { - ShapefileResourceData data = new ShapefileResourceData( - theShpFile.toString(), - new String[] { theLabelAttribute }); - vector = data.construct(new LoadProperties(), desc); - vector.getCapability(ColorableCapability.class) - .setColor(new RGB(255, 255, 255)); - vector.setSpatiallySplit(spatiallySplit); - if (isShaded) { - vector.getCapability(ShadeableCapability.class) - .setShadingField(theShadedAttribute); - vector.setColorMapAttribute(theShadedAttribute); - vector.setColorMap(colorMap); - vector.setRegularPolygon(isRegularPolygon); - - } - - desc.getResourceList().add(vector); - } catch (VizException e) { - return new Status(Status.ERROR, "com.raytheon.viz", - Status.OK, "Error loading shapefile", e); - } - editor.refresh(); - } - - return Status.OK_STATUS; - } - - }; - j.schedule(); - - return true; - } - - public void init(IWorkbench anWorkbench, IStructuredSelection anSelection) { - - } - - /** - * @return the shpFile - */ - public String getShpFile() { - return theShpFile; - } - - /** - * @param anShpFile - * the shpFile to set - */ - public void setShpFile(String anShpFile) { - theShpFile = anShpFile; - } - - // /* - // * (non-Javadoc) - // * - // * @see org.eclipse.jface.wizard.Wizard#canFinish() - // */ - // @Override - // public boolean canFinish() { - // return isFinished; - // } - // - // public void setFinished(boolean isFinished) { - // this.isFinished = isFinished; - // } - // - /** - * @return the labelAttribute - */ - public String getLabelAttribute() { - return theLabelAttribute; - } - - /** - * @param anLabelAttribute - * the labelAttribute to set - */ - public void setLabelAttribute(String anLabelAttribute) { - theLabelAttribute = anLabelAttribute; - } - - /** - * @return the isShaded - */ - public boolean isShaded() { - return isShaded; - } - - /** - * @param isShaded - * the isShaded to set - */ - public void setShaded(boolean isShaded) { - this.isShaded = isShaded; - } - - /** - * @return the shadedAttribute - */ - public String getShadedAttribute() { - return theShadedAttribute; - } - - /** - * @param anShadedAttribute - * the shadedAttribute to set - */ - public void setShadedAttribute(String anShadedAttribute) { - theShadedAttribute = anShadedAttribute; - } - - /** - * @return the colorMap - */ - public HashMap getColorMap() { - return colorMap; - } - - /** - * @param colorMap - * the colorMap to set - */ - public void setColorMap(HashMap colorMap) { - this.colorMap = colorMap; - } - - /** - * @return the isRegularPolygon - */ - public boolean isRegularPolygon() { - return isRegularPolygon; - } - - /** - * @param isRegularPolygon - * the isRegularPolygon to set - */ - public void setRegularPolygon(boolean isRegularPolygon) { - this.isRegularPolygon = isRegularPolygon; - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardColorPage.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardColorPage.java deleted file mode 100644 index 36ef4bd983..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardColorPage.java +++ /dev/null @@ -1,345 +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.viz.shapefile.wizard; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; - -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.ColorDialog; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; - -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.shapefile.rsc.ShapefileResource; -import com.raytheon.viz.shapefile.rsc.ShapefileUtil; - -/** - * Shapefile Wizard: select coloring of the data - * - *
- * 
- *  SOFTWARE HISTORY
- * 
- *  Date            Ticket#     Engineer    Description
- *  ------------    ----------  ----------- --------------------------
- *  7/1/06                      chammack    Initial Creation.
- * 
- * 
- * - * @author chammack - * @version 1 - */ -public class ShapefileWizardColorPage extends WizardPage { - - private ListViewer theList; - - private TableViewer theValueList; - - private Button randomColorButton; - - private Button rgbColorButton; - - private Button regularCheckBox; - - public ShapefileWizardColorPage() { - super("Shapefile Wizard: Select Coloring"); - this.setTitle("Shapefile Wizard: Select Coloring"); - this.setDescription("Select the method of coloring the data"); - - setPageComplete(true); - } - - public void createControl(Composite aParent) { - - Composite composite = new Composite(aParent, SWT.NONE); - GridLayout gl = new GridLayout(1, false); - composite.setLayout(gl); - - Group buttonGroup = new Group(composite, SWT.SHADOW_OUT); - buttonGroup.setLayout(new GridLayout(3, true)); - Button button1 = new Button(buttonGroup, SWT.RADIO); - button1.setText("Wireframe Only"); - button1.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, - true, false, 1, 1)); - button1.setSelection(true); - randomColorButton = new Button(buttonGroup, SWT.RADIO); - randomColorButton.setText("Unique Value Color Map"); - randomColorButton.setLayoutData(new GridData(GridData.FILL, - GridData.CENTER, true, false, 1, 1)); - rgbColorButton = new Button(buttonGroup, SWT.RADIO); - rgbColorButton.setText("RGB Dynamic Color Map"); - rgbColorButton.setLayoutData(new GridData(GridData.FILL, - GridData.CENTER, true, false, 1, 1)); - - button1.addSelectionListener(new SelectionAdapter() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent anE) { - ((ShapefileWizard) getWizard()).setShaded(false); - theList.getList().setEnabled(false); - setPageComplete(true); - } - - }); - - randomColorButton.addSelectionListener(new SelectionAdapter() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent anE) { - ((ShapefileWizard) getWizard()).setShaded(true); - theList.getList().setEnabled(true); - setPageComplete(theList.getList().getSelectionCount() > 0); - } - - }); - - rgbColorButton.addSelectionListener(new SelectionAdapter() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent anE) { - ((ShapefileWizard) getWizard()).setShaded(true); - theList.getList().setEnabled(true); - setPageComplete(theList.getList().getSelectionCount() > 0); - } - - }); - - theList = new ListViewer(composite, SWT.V_SCROLL | SWT.BORDER - | SWT.SINGLE); - theList.getList().setLayoutData(new GridData(GridData.FILL_BOTH)); - theList.getList().setEnabled(false); - - theValueList = new TableViewer(composite, SWT.V_SCROLL | SWT.BORDER - | SWT.SINGLE); - theValueList.getControl().setLayoutData( - new GridData(GridData.FILL_BOTH)); - - theValueList.setLabelProvider(new ColorProvider()); - composite.addPaintListener(new PaintListener() { - - public void paintControl(PaintEvent anE) { - if (theList.getList().getItemCount() == 0) { - try { - String shpName = ((ShapefileWizard) getWizard()) - .getShpFile(); - File f = new File(shpName); - String[] attribs = ShapefileUtil - .getAttributes(f, false); - theList.getList().removeAll(); - theList.add(attribs); - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - }); - - theList.addSelectionChangedListener(new ISelectionChangedListener() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged - * (org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - String attribute = (String) ((IStructuredSelection) theList - .getSelection()).getFirstElement(); - ((ShapefileWizard) getWizard()).setShadedAttribute(attribute); - - // Call the generation routine - String shpName = ((ShapefileWizard) getWizard()).getShpFile(); - File f = new File(shpName); - try { - theValueList.getTable().removeAll(); - HashMap map = null; - if (randomColorButton.getSelection()) { - map = ShapefileResource.generateRandomAttributeMap( - attribute, f); - } else if (rgbColorButton.getSelection()) { - map = ShapefileResource.generateRGBColorMap(attribute, - f); - } - - ((ShapefileWizard) getWizard()).setColorMap(map); - - refreshLabels(); - setPageComplete(true); - - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - }); - - theValueList.addDoubleClickListener(new IDoubleClickListener() { - - public void doubleClick(DoubleClickEvent event) { - Object o = ((IStructuredSelection) event.getSelection()) - .getFirstElement(); - - ColorDialog cd = new ColorDialog(theList.getControl() - .getShell()); - cd.setRGB(((ShapefileWizard) getWizard()).getColorMap().get(o)); - RGB newColor = cd.open(); - ((ShapefileWizard) getWizard()).getColorMap().put(o, newColor); - - theValueList.update(o, null); - - } - - }); - - regularCheckBox = new Button(composite, SWT.CHECK); - regularCheckBox.setText("Regular Polygon (check only for grids)"); - - regularCheckBox.addSelectionListener(new SelectionListener() { - - public void widgetDefaultSelected(SelectionEvent e) { - - } - - public void widgetSelected(SelectionEvent e) { - ((ShapefileWizard) getWizard()) - .setRegularPolygon(regularCheckBox.getSelection()); - } - - }); - setControl(composite); - - } - - private void refreshLabels() { - HashMap map = ((ShapefileWizard) getWizard()) - .getColorMap(); - Set objSet = map.keySet(); - - objSet = new TreeSet(objSet); - Iterator objIterator = objSet.iterator(); - - while (objIterator.hasNext()) { - Object o = objIterator.next(); - theValueList.add(o); - } - } - - public class ColorProvider implements IColorProvider, ILabelProvider { - - ArrayList allocatedColors = new ArrayList(); - - public Color getBackground(Object element) { - return null; - } - - public Color getForeground(Object element) { - RGB rgb = ((ShapefileWizard) getWizard()).getColorMap() - .get(element); - - if (rgb == null) { - return null; - } - - Color c = new Color(getControl().getDisplay(), rgb); - allocatedColors.add(c); - return c; - } - - public void addListener(ILabelProviderListener listener) { - - } - - public void dispose() { - for (Color c : allocatedColors) { - c.dispose(); - } - } - - public boolean isLabelProperty(Object element, String property) { - return true; - } - - public void removeListener(ILabelProviderListener listener) { - } - - public Image getImage(Object element) { - return null; - } - - public String getText(Object element) { - return element.toString(); - } - - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardFilePage.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardFilePage.java deleted file mode 100644 index ab25890be5..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardFilePage.java +++ /dev/null @@ -1,122 +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.viz.shapefile.wizard; - -import java.io.File; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * Shapefile Wizard: select the file - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 7/1/06                   chammack    Initial Creation.
- * 
- * 
- * - * @author chammack - * @version 1 - */ -public class ShapefileWizardFilePage extends WizardPage { - - private Text theDirectory; - - public ShapefileWizardFilePage() { - super("Shapefile Wizard: Select File"); - this.setTitle("Shapefile Wizard: Select File"); - this.setDescription("Import a Shapefile into Viz"); - - setPageComplete(false); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets - * .Composite) - */ - public void createControl(final Composite aParent) { - - Composite composite = new Composite(aParent, SWT.None); - GridLayout gl = new GridLayout(3, false); - composite.setLayout(gl); - - Label label = new Label(composite, SWT.None); - label.setText("&Filename: "); - theDirectory = new Text(composite, SWT.BORDER); - theDirectory.setText(""); - theDirectory.setEditable(false); - theDirectory.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Button browse = new Button(composite, SWT.None); - browse.setText("&Browse"); - browse.addSelectionListener(new SelectionAdapter() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent anE) { - FileDialog selectDialog = new FileDialog(aParent.getShell(), - SWT.OPEN); - selectDialog.setFilterExtensions(new String[] { "*.shp" }); - String filePath = selectDialog.open(); - if (filePath != null) { - File file = new File(filePath); - if (file.exists() && file.canRead()) { - theDirectory.setText(filePath); - ((ShapefileWizard) getWizard()).setShpFile(filePath); - setPageComplete(true); - } - - } - - } - - }); - - setControl(composite); - - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardLayerPage.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardLayerPage.java deleted file mode 100644 index c47b90a2c1..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/ShapefileWizardLayerPage.java +++ /dev/null @@ -1,131 +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.viz.shapefile.wizard; - -import java.io.File; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; - -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.shapefile.rsc.ShapefileUtil; - -/** - * Shapefile Wizard: select the layer - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date       	Ticket#		Engineer	Description
- * ------------	----------	-----------	--------------------------
- * 7/1/06                   chammack    Initial Creation.
- * 
- * 
- * - * @author chammack - * @version 1 - */ -public class ShapefileWizardLayerPage extends WizardPage { - - private List theResourceList; - - public ShapefileWizardLayerPage() { - super("Shapefile Wizard: Select Label Attribute"); - this.setTitle("Shapefile Wizard: Select Label Attribute"); - this.setDescription("Select the labelling attribute"); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets - * .Composite) - */ - public void createControl(Composite aParent) { - setPageComplete(false); - - Composite composite = new Composite(aParent, SWT.NONE); - GridLayout gl = new GridLayout(1, false); - composite.setLayout(gl); - - Label label = new Label(composite, SWT.NONE); - label.setText("&Attributes:"); - theResourceList = new List(composite, SWT.V_SCROLL | SWT.BORDER - | SWT.SINGLE); - theResourceList.setLayoutData(new GridData(GridData.FILL_BOTH)); - - composite.addPaintListener(new PaintListener() { - - public void paintControl(PaintEvent anE) { - if (theResourceList.getItemCount() == 0) { - try { - String shpName = ((ShapefileWizard) getWizard()) - .getShpFile(); - File f = new File(shpName); - String[] attribs = ShapefileUtil - .getAttributes(f, false); - theResourceList.setItems(attribs); - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - }); - - theResourceList.addSelectionListener(new SelectionAdapter() { - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse - * .swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent anE) { - int idx = theResourceList.getSelectionIndex(); - ((ShapefileWizard) getWizard()) - .setLabelAttribute(theResourceList.getItem(idx)); - - setPageComplete(true); - - } - - }); - - setControl(composite); - - } - -} diff --git a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/package-info.java b/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/package-info.java deleted file mode 100644 index 51f5e12eca..0000000000 --- a/cave/com.raytheon.viz.shapefile/src/com/raytheon/viz/shapefile/wizard/package-info.java +++ /dev/null @@ -1,23 +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. - **/ -/** - * Contains the shapefile wizard - */ -package com.raytheon.viz.shapefile.wizard; \ No newline at end of file diff --git a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java index a18dab0e6f..40ec1ea7de 100644 --- a/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java +++ b/cave/com.raytheon.viz.volumebrowser/src/com/raytheon/viz/volumebrowser/datacatalog/GridDataCatalog.java @@ -33,6 +33,7 @@ import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.geometry.DirectPosition2D; import org.geotools.geometry.Envelope2D; import org.geotools.geometry.jts.ReferencedEnvelope; +import org.opengis.geometry.BoundingBox; import org.opengis.referencing.operation.MathTransform; import com.raytheon.uf.common.comm.CommunicationException; @@ -84,8 +85,9 @@ import com.vividsolutions.jts.geom.LineString; * Jul 31, 2012 875 rferrel Now uses points. * May 30, 2013 2055 bsteffen Remove modelName from sounding pointName. * Dec 06, 2013 2271 mpduff Added check for null coordinate. - * Jan 30, 2014 #2725 ekladstrup updated exception handling during move of derived + * Jan 30, 2014 #2725 ekladstrup updated exception handling during move of derived * parameters to common + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -305,7 +307,7 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { statusHandler.handle(Priority.PROBLEM, "Error occured during perturbation query.", e); } - if (ensemebles != null && ensemebles.size() > 1) { + if ((ensemebles != null) && (ensemebles.size() > 1)) { Collections.sort(ensemebles); Collection requests = new ArrayList(); for (String ensemble : ensemebles) { @@ -455,7 +457,7 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { lineEnv.add(dp.x, dp.y); } } - if (lineEnv.intersects(env)) { + if (lineEnv.intersects((BoundingBox) env)) { fileredSources.add(source); break; } @@ -464,13 +466,13 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { gridGeom.getCoordinateReferenceSystem()); rEnv = rEnv.transform(MapUtil.getLatLonProjection(), true); for (Double lat : lats) { - if (rEnv.getMinY() < lat && rEnv.getMaxY() > lat) { + if ((rEnv.getMinY() < lat) && (rEnv.getMaxY() > lat)) { fileredSources.add(source); break; } } for (Double lon : lons) { - if (rEnv.getMinX() < lon && rEnv.getMaxX() > lon) { + if ((rEnv.getMinX() < lon) && (rEnv.getMaxX() > lon)) { fileredSources.add(source); break; } @@ -489,9 +491,9 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { protected Collection get3DPlanes(Collection sources) { ViewMenu viewSelection = VolumeBrowserAction.getVolumeBrowserDlg() .getDialogSettings().getViewSelection(); - if (sources == null || sources.isEmpty() - || viewSelection == ViewMenu.PLANVIEW - || viewSelection == ViewMenu.TIMESERIES) { + if ((sources == null) || sources.isEmpty() + || (viewSelection == ViewMenu.PLANVIEW) + || (viewSelection == ViewMenu.TIMESERIES)) { Set results = new HashSet(); results.addAll(MenuItemManager.getInstance().getLatLonKeys()); results.addAll(getPointLineKeys()); @@ -539,7 +541,7 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { lineEnv.add(dp.x, dp.y); } } - if (lineEnv.intersects(env)) { + if (lineEnv.intersects((BoundingBox) env)) { validPlanes.add("Line" + letter); } } @@ -551,13 +553,15 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog { if (llKey.startsWith("Lat")) { double lat = Double.parseDouble(llKey.replace( "Lat", "")); - if (rEnv.getMinY() < lat && rEnv.getMaxY() > lat) { + if ((rEnv.getMinY() < lat) + && (rEnv.getMaxY() > lat)) { validPlanes.add(llKey); } } else if (llKey.startsWith("Lon")) { double lon = Double.parseDouble(llKey.replace( "Lon", "")); - if (rEnv.getMinX() < lon && rEnv.getMaxX() > lon) { + if ((rEnv.getMinX() < lon) + && (rEnv.getMaxX() > lon)) { validPlanes.add(llKey); } } else { diff --git a/cots/org.geotools/.classpath b/cots/org.geotools/.classpath index b1413ba381..1d2e7841b6 100644 --- a/cots/org.geotools/.classpath +++ b/cots/org.geotools/.classpath @@ -1,52 +1,47 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + - diff --git a/cots/org.geotools/META-INF/MANIFEST.MF b/cots/org.geotools/META-INF/MANIFEST.MF index 0dbc864b54..af74e62651 100644 --- a/cots/org.geotools/META-INF/MANIFEST.MF +++ b/cots/org.geotools/META-INF/MANIFEST.MF @@ -2,54 +2,49 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Geotools Plug-in Bundle-SymbolicName: org.geotools -Bundle-Version: 2.6.4 -Bundle-ClassPath: common-2.2.1.jar, +Bundle-Version: 10.5 +Bundle-ClassPath: common-2.6.0.jar, commons-beanutils-1.7.0.jar, commons-collections-3.1.jar, - commons-dbcp-1.2.2.jar, - commons-jxpath-1.2.jar, + commons-dbcp-1.3.jar, + commons-jxpath-1.3.jar, commons-lang-2.3.jar, - commons-pool-1.5.3.jar, - ecore-2.2.2.jar, - geoapi-2.3-M1.jar, - geoapi-pending-2.3-M1.jar, - gt-api-2.6.4.jar, - gt-coverage-2.6.4.jar, - gt-cql-2.6.4.jar, - gt-epsg-wkt-2.6.4.jar, - gt-geotiff-2.6.4.jar, - gt-graph-2.6.4.jar, - gt-gtopo30-2.6.4.jar, - gt-image-2.6.4.jar, - gt-jdbc-2.6.4.jar, - gt-jdbc-postgis-2.6.4.jar, - gt-main-2.6.4.jar, - gt-metadata-2.6.4.jar, - gt-referencing-2.6.4.jar, - gt-referencing3D-2.6.4.jar, - gt-render-2.6.4.jar, - gt-shapefile-2.6.4.jar, - gt-xml-2.6.4.jar, - gt-xsd-core-2.6.4.jar, - gt-xsd-filter-2.6.4.jar, - gt-xsd-gml2-2.6.4.jar, - gt-xsd-gml3-2.6.4.jar, - gt-xsd-kml-2.6.4.jar, - gt-xsd-sld-2.6.4.jar, + commons-pool-1.5.4.jar, + ecore-2.6.1.jar, + gt-api-10.5.jar, + gt-coverage-10.5.jar, + gt-cql-10.5.jar, + gt-data-10.5.jar, + gt-epsg-wkt-10.5.jar, + gt-geotiff-10.5.jar, + gt-graph-10.5.jar, + gt-gtopo30-10.5.jar, + gt-image-10.5.jar, + gt-jdbc-10.5.jar, + gt-jdbc-postgis-10.5.jar, + gt-main-10.5.jar, + gt-metadata-10.5.jar, + gt-opengis-10.5.jar, + gt-referencing-10.5.jar, + gt-referencing3D-10.5.jar, + gt-render-10.5.jar, + gt-shapefile-10.5.jar, + gt-xml-10.5.jar, + gt-xsd-core-10.5.jar, + gt-xsd-filter-10.5.jar, + gt-xsd-gml2-10.5.jar, + gt-xsd-gml3-10.5.jar, + gt-xsd-kml-10.5.jar, + gt-xsd-ows-10.5.jar, + gt-xsd-sld-10.5.jar, + gt-xsd-wfs-10.5.jar, + gt-wfs-10.5.jar, jdom-1.0.jar, - gt-postgis-2.6.4.jar, - gt-wfs-2.6.4.jar, - jts-1.10.jar, + jts-1.13.jar, + net.opengis.ows-10.5.jar, + net.opengis.wfs-10.5.jar, picocontainer-1.2.jar, - xercesImpl-2.7.1.jar, - xsd-2.2.2.jar, - gt-xsd-wfs-2.6.4.jar, - gt-xsd-ows-2.6.4.jar, - net.opengis.ows-2.6.4.jar, - net.opengis.wfs-2.6.4.jar, - net.opengis.wfsv-2.6.4.jar, - gt-directory-2.6.4.jar, - gt-data-2.6.4.jar + xsd-2.6.0.jar Bundle-Vendor: Raytheon-bundled OSS Export-Package: com.vividsolutions.jts, com.vividsolutions.jts.algorithm, @@ -105,24 +100,21 @@ Export-Package: com.vividsolutions.jts, org.geotools.data.crs, org.geotools.data.directory, org.geotools.data.jdbc, - org.geotools.data.jdbc.attributeio, org.geotools.data.jdbc.datasource, org.geotools.data.jdbc.fidmapper, - org.geotools.data.jdbc.referencing, org.geotools.data.memory, org.geotools.data.ows, org.geotools.data.postgis, - org.geotools.data.postgis.attributeio, - org.geotools.data.postgis.collection, - org.geotools.data.postgis.fidmapper, - org.geotools.data.postgis.referencing, org.geotools.data.shapefile, org.geotools.data.shapefile.dbf, - org.geotools.data.shapefile.indexed, - org.geotools.data.shapefile.indexed.attribute, - org.geotools.data.shapefile.prj, + org.geotools.data.shapefile.fid, + org.geotools.data.shapefile.files, + org.geotools.data.shapefile.index, + org.geotools.data.shapefile.index.quadtree, + org.geotools.data.shapefile.index.quadtree.fs, org.geotools.data.shapefile.shp, org.geotools.data.shapefile.shp.xml, + org.geotools.data.simple, org.geotools.data.store, org.geotools.data.view, org.geotools.data.wfs, @@ -150,8 +142,6 @@ Export-Package: com.vividsolutions.jts, org.geotools.filter.v1_1.capabilities, org.geotools.filter.visitor, org.geotools.gce.geotiff, - org.geotools.gce.geotiff.adapters, - org.geotools.gce.geotiff.codes, org.geotools.gce.gtopo30, org.geotools.gce.image, org.geotools.geometry, @@ -198,9 +188,6 @@ Export-Package: com.vividsolutions.jts, org.geotools.image.io, org.geotools.image.jai, org.geotools.image.palette, - org.geotools.index, - org.geotools.index.quadtree, - org.geotools.index.quadtree.fs, org.geotools.io, org.geotools.jdbc, org.geotools.kml, @@ -280,11 +267,7 @@ Export-Package: com.vividsolutions.jts, org.opengis.annotation, org.opengis.coverage, org.opengis.coverage.grid, - org.opengis.coverage.grid.quadrilateral, org.opengis.coverage.processing, - org.opengis.display.canvas, - org.opengis.display.container, - org.opengis.display.primitive, org.opengis.feature, org.opengis.feature.simple, org.opengis.feature.type, @@ -310,23 +293,15 @@ Export-Package: com.vividsolutions.jts, org.opengis.metadata.maintenance, org.opengis.metadata.quality, org.opengis.metadata.spatial, - org.opengis.observation, - org.opengis.observation.coverage, - org.opengis.observation.sampling, org.opengis.parameter, org.opengis.referencing, org.opengis.referencing.crs, org.opengis.referencing.cs, org.opengis.referencing.datum, org.opengis.referencing.operation, - org.opengis.sld, org.opengis.style, - org.opengis.style.portrayal, org.opengis.temporal, - org.opengis.util, - org.opengis.webservice, - org.opengis.webservice.capability, - org.opengis.webservice.feature + org.opengis.util Require-Bundle: javax.vecmath;bundle-version="1.3.1", javax.measure;bundle-version="1.0.0", org.postgres;bundle-version="1.0.0", diff --git a/cots/org.geotools/build.properties b/cots/org.geotools/build.properties index 48abbaf081..1da7ba7212 100644 --- a/cots/org.geotools/build.properties +++ b/cots/org.geotools/build.properties @@ -1,58 +1,48 @@ bin.includes = META-INF/,\ .,\ - common-2.2.1.jar,\ + common-2.6.0.jar,\ commons-beanutils-1.7.0.jar,\ commons-collections-3.1.jar,\ - commons-dbcp-1.2.2.jar,\ - commons-jxpath-1.2.jar,\ + commons-dbcp-1.3.jar,\ + commons-jxpath-1.3.jar,\ commons-lang-2.3.jar,\ - commons-pool-1.5.3.jar,\ - ecore-2.2.2.jar,\ - geoapi-2.3-M1.jar,\ - geoapi-pending-2.3-M1.jar,\ - gt-api-2.6.4.jar,\ - gt-coverage-2.6.4.jar,\ - gt-cql-2.6.4.jar,\ - gt-epsg-wkt-2.6.4.jar,\ - gt-geotiff-2.6.4.jar,\ - gt-graph-2.6.4.jar,\ - gt-gtopo30-2.6.4.jar,\ - gt-image-2.6.4.jar,\ - gt-main-2.6.4.jar,\ - gt-metadata-2.6.4.jar,\ - gt-referencing-2.6.4.jar,\ - gt-referencing3D-2.6.4.jar,\ - gt-render-2.6.4.jar,\ - gt-shapefile-2.6.4.jar,\ - gt-xml-2.6.4.jar,\ - gt-xsd-core-2.6.4.jar,\ - gt-xsd-filter-2.6.4.jar,\ - gt-xsd-gml2-2.6.4.jar,\ - gt-xsd-gml3-2.6.4.jar,\ - gt-xsd-kml-2.6.4.jar,\ - gt-xsd-sld-2.6.4.jar,\ + commons-pool-1.5.4.jar,\ + ecore-2.6.1.jar,\ + gt-api-10.5.jar,\ + gt-coverage-10.5.jar,\ + gt-cql-10.5.jar,\ + gt-data-10.5.jar,\ + gt-epsg-wkt-10.5.jar,\ + gt-geotiff-10.5.jar,\ + gt-graph-10.5.jar,\ + gt-gtopo30-10.5.jar,\ + gt-image-10.5.jar,\ + gt-jdbc-10.5.jar,\ + gt-jdbc-postgis-10.5.jar,\ + gt-main-10.5.jar,\ + gt-metadata-10.5.jar,\ + gt-opengis-10.5.jar,\ + gt-referencing-10.5.jar,\ + gt-referencing3D-10.5.jar,\ + gt-render-10.5.jar,\ + gt-shapefile-10.5.jar,\ + gt-wfs-10.5.jar,\ + gt-xml-10.5.jar,\ + gt-xsd-core-10.5.jar,\ + gt-xsd-filter-10.5.jar,\ + gt-xsd-gml2-10.5.jar,\ + gt-xsd-gml3-10.5.jar,\ + gt-xsd-kml-10.5.jar,\ + gt-xsd-ows-10.5.jar,\ + gt-xsd-sld-10.5.jar,\ + gt-xsd-wfs-10.5.jar,\ jdom-1.0.jar,\ - jts-1.10.jar,\ - commons-beanutils-1.7.0.jar,\ - commons-collections-3.1.jar,\ - commons-dbcp-1.2.2.jar,\ - commons-jxpath-1.2.jar,\ - commons-lang-2.3.jar,\ - commons-pool-1.5.3.jar,\ - common-2.2.1.jar,\ - jdom-1.0.jar,\ - gt-postgis-2.6.4.jar,\ - gt-jdbc-2.6.4.jar,\ - gt-jdbc-postgis-2.6.4.jar,\ + jts-1.13.jar,\ + jts-1.13-sources.jar,\ + net.opengis.ows-10.5.jar,\ + net.opengis.wfs-10.5.jar,\ picocontainer-1.2.jar,\ xercesImpl-2.7.1.jar,\ - xsd-2.2.2.jar,\ - gt-wfs-2.6.4.jar,\ - gt-xsd-wfs-2.6.4.jar,\ - gt-xsd-ows-2.6.4.jar,\ - net.opengis.ows-2.6.4.jar,\ - net.opengis.wfs-2.6.4.jar,\ - net.opengis.wfsv-2.6.4.jar,\ - gt-data-2.6.4.jar,\ - gt-directory-2.6.4.jar - + xml-apis-1.0.b2.jar,\ + xml-apis-xerces-2.7.1.jar,\ + xsd-2.6.0.jar diff --git a/cots/org.geotools/common-2.2.1.jar b/cots/org.geotools/common-2.2.1.jar deleted file mode 100644 index 8f4e4f278c..0000000000 Binary files a/cots/org.geotools/common-2.2.1.jar and /dev/null differ diff --git a/cots/org.geotools/common-2.6.0.jar b/cots/org.geotools/common-2.6.0.jar new file mode 100644 index 0000000000..e3317d5fea Binary files /dev/null and b/cots/org.geotools/common-2.6.0.jar differ diff --git a/cots/org.geotools/commons-dbcp-1.2.2.jar b/cots/org.geotools/commons-dbcp-1.2.2.jar deleted file mode 100644 index faea05626b..0000000000 Binary files a/cots/org.geotools/commons-dbcp-1.2.2.jar and /dev/null differ diff --git a/cots/org.geotools/commons-dbcp-1.3.jar b/cots/org.geotools/commons-dbcp-1.3.jar new file mode 100644 index 0000000000..d29339738e Binary files /dev/null and b/cots/org.geotools/commons-dbcp-1.3.jar differ diff --git a/cots/org.geotools/commons-jxpath-1.2.jar b/cots/org.geotools/commons-jxpath-1.2.jar deleted file mode 100644 index 2336988d8d..0000000000 Binary files a/cots/org.geotools/commons-jxpath-1.2.jar and /dev/null differ diff --git a/cots/org.geotools/commons-jxpath-1.3.jar b/cots/org.geotools/commons-jxpath-1.3.jar new file mode 100644 index 0000000000..e344a1e66d Binary files /dev/null and b/cots/org.geotools/commons-jxpath-1.3.jar differ diff --git a/cots/org.geotools/commons-pool-1.5.3.jar b/cots/org.geotools/commons-pool-1.5.4.jar similarity index 61% rename from cots/org.geotools/commons-pool-1.5.3.jar rename to cots/org.geotools/commons-pool-1.5.4.jar index b31287a48c..43edf99635 100644 Binary files a/cots/org.geotools/commons-pool-1.5.3.jar and b/cots/org.geotools/commons-pool-1.5.4.jar differ diff --git a/cots/org.geotools/ecore-2.2.2.jar b/cots/org.geotools/ecore-2.2.2.jar deleted file mode 100644 index d472c76b77..0000000000 Binary files a/cots/org.geotools/ecore-2.2.2.jar and /dev/null differ diff --git a/cots/org.geotools/ecore-2.6.1.jar b/cots/org.geotools/ecore-2.6.1.jar new file mode 100644 index 0000000000..ddf761b766 Binary files /dev/null and b/cots/org.geotools/ecore-2.6.1.jar differ diff --git a/cots/org.geotools/geoapi-2.3-M1.jar b/cots/org.geotools/geoapi-2.3-M1.jar deleted file mode 100644 index d0b32270d2..0000000000 Binary files a/cots/org.geotools/geoapi-2.3-M1.jar and /dev/null differ diff --git a/cots/org.geotools/geoapi-pending-2.3-M1.jar b/cots/org.geotools/geoapi-pending-2.3-M1.jar deleted file mode 100644 index 54b7ca1e6d..0000000000 Binary files a/cots/org.geotools/geoapi-pending-2.3-M1.jar and /dev/null differ diff --git a/cots/org.geotools/geotools-source-10.5.zip b/cots/org.geotools/geotools-source-10.5.zip new file mode 100644 index 0000000000..49f559fc5c Binary files /dev/null and b/cots/org.geotools/geotools-source-10.5.zip differ diff --git a/cots/org.geotools/gt-api-10.5.jar b/cots/org.geotools/gt-api-10.5.jar new file mode 100644 index 0000000000..f94aaedfb3 Binary files /dev/null and b/cots/org.geotools/gt-api-10.5.jar differ diff --git a/cots/org.geotools/gt-api-2.6.4-sources.jar b/cots/org.geotools/gt-api-2.6.4-sources.jar deleted file mode 100644 index 7c35a2fbd8..0000000000 Binary files a/cots/org.geotools/gt-api-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-api-2.6.4.jar b/cots/org.geotools/gt-api-2.6.4.jar deleted file mode 100644 index 4075e15448..0000000000 Binary files a/cots/org.geotools/gt-api-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-coverage-10.5.jar b/cots/org.geotools/gt-coverage-10.5.jar new file mode 100644 index 0000000000..97656ad12c Binary files /dev/null and b/cots/org.geotools/gt-coverage-10.5.jar differ diff --git a/cots/org.geotools/gt-coverage-2.6.4-sources.jar b/cots/org.geotools/gt-coverage-2.6.4-sources.jar deleted file mode 100644 index 1e3211dbbb..0000000000 Binary files a/cots/org.geotools/gt-coverage-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-coverage-2.6.4.jar b/cots/org.geotools/gt-coverage-2.6.4.jar deleted file mode 100644 index ac21898fe6..0000000000 Binary files a/cots/org.geotools/gt-coverage-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-cql-10.5.jar b/cots/org.geotools/gt-cql-10.5.jar new file mode 100644 index 0000000000..9feba2b6a7 Binary files /dev/null and b/cots/org.geotools/gt-cql-10.5.jar differ diff --git a/cots/org.geotools/gt-cql-2.6.4.jar b/cots/org.geotools/gt-cql-2.6.4.jar deleted file mode 100644 index 50cb35cb7f..0000000000 Binary files a/cots/org.geotools/gt-cql-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-data-10.5.jar b/cots/org.geotools/gt-data-10.5.jar new file mode 100644 index 0000000000..3116de2219 Binary files /dev/null and b/cots/org.geotools/gt-data-10.5.jar differ diff --git a/cots/org.geotools/gt-data-2.6.4-sources.zip b/cots/org.geotools/gt-data-2.6.4-sources.zip deleted file mode 100644 index 262cfc153f..0000000000 Binary files a/cots/org.geotools/gt-data-2.6.4-sources.zip and /dev/null differ diff --git a/cots/org.geotools/gt-data-2.6.4.jar b/cots/org.geotools/gt-data-2.6.4.jar deleted file mode 100644 index 42e1586c4d..0000000000 Binary files a/cots/org.geotools/gt-data-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-directory-2.6.4-sources.zip b/cots/org.geotools/gt-directory-2.6.4-sources.zip deleted file mode 100644 index 938a797616..0000000000 Binary files a/cots/org.geotools/gt-directory-2.6.4-sources.zip and /dev/null differ diff --git a/cots/org.geotools/gt-directory-2.6.4.jar b/cots/org.geotools/gt-directory-2.6.4.jar deleted file mode 100644 index d3f9c871a5..0000000000 Binary files a/cots/org.geotools/gt-directory-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-epsg-wkt-10.5.jar b/cots/org.geotools/gt-epsg-wkt-10.5.jar new file mode 100644 index 0000000000..4d8fe566a5 Binary files /dev/null and b/cots/org.geotools/gt-epsg-wkt-10.5.jar differ diff --git a/cots/org.geotools/gt-epsg-wkt-2.6.4-sources.jar b/cots/org.geotools/gt-epsg-wkt-2.6.4-sources.jar deleted file mode 100644 index 70a6a606ef..0000000000 Binary files a/cots/org.geotools/gt-epsg-wkt-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-epsg-wkt-2.6.4.jar b/cots/org.geotools/gt-epsg-wkt-2.6.4.jar deleted file mode 100644 index 2ba2cc6e2b..0000000000 Binary files a/cots/org.geotools/gt-epsg-wkt-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-geotiff-10.5.jar b/cots/org.geotools/gt-geotiff-10.5.jar new file mode 100644 index 0000000000..3d4e2a51db Binary files /dev/null and b/cots/org.geotools/gt-geotiff-10.5.jar differ diff --git a/cots/org.geotools/gt-geotiff-2.6.4-sources.jar b/cots/org.geotools/gt-geotiff-2.6.4-sources.jar deleted file mode 100644 index 9503210e98..0000000000 Binary files a/cots/org.geotools/gt-geotiff-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-geotiff-2.6.4.jar b/cots/org.geotools/gt-geotiff-2.6.4.jar deleted file mode 100644 index 8b8d86c576..0000000000 Binary files a/cots/org.geotools/gt-geotiff-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-graph-10.5.jar b/cots/org.geotools/gt-graph-10.5.jar new file mode 100644 index 0000000000..a213c06efa Binary files /dev/null and b/cots/org.geotools/gt-graph-10.5.jar differ diff --git a/cots/org.geotools/gt-graph-2.6.4-sources.jar b/cots/org.geotools/gt-graph-2.6.4-sources.jar deleted file mode 100644 index 15df8d4f09..0000000000 Binary files a/cots/org.geotools/gt-graph-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-graph-2.6.4.jar b/cots/org.geotools/gt-graph-2.6.4.jar deleted file mode 100644 index 50bdcdcd2e..0000000000 Binary files a/cots/org.geotools/gt-graph-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-gtopo30-10.5.jar b/cots/org.geotools/gt-gtopo30-10.5.jar new file mode 100644 index 0000000000..29b5cfa825 Binary files /dev/null and b/cots/org.geotools/gt-gtopo30-10.5.jar differ diff --git a/cots/org.geotools/gt-gtopo30-2.6.4-sources.jar b/cots/org.geotools/gt-gtopo30-2.6.4-sources.jar deleted file mode 100644 index acf7f4e946..0000000000 Binary files a/cots/org.geotools/gt-gtopo30-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-gtopo30-2.6.4.jar b/cots/org.geotools/gt-gtopo30-2.6.4.jar deleted file mode 100644 index 285a3c07f6..0000000000 Binary files a/cots/org.geotools/gt-gtopo30-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-image-10.5.jar b/cots/org.geotools/gt-image-10.5.jar new file mode 100644 index 0000000000..d3ac52bb21 Binary files /dev/null and b/cots/org.geotools/gt-image-10.5.jar differ diff --git a/cots/org.geotools/gt-image-2.6.4-sources.jar b/cots/org.geotools/gt-image-2.6.4-sources.jar deleted file mode 100644 index f2ff98c743..0000000000 Binary files a/cots/org.geotools/gt-image-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-image-2.6.4.jar b/cots/org.geotools/gt-image-2.6.4.jar deleted file mode 100644 index d79e0ee3ef..0000000000 Binary files a/cots/org.geotools/gt-image-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-jdbc-10.5.jar b/cots/org.geotools/gt-jdbc-10.5.jar new file mode 100644 index 0000000000..2008f9aa2d Binary files /dev/null and b/cots/org.geotools/gt-jdbc-10.5.jar differ diff --git a/cots/org.geotools/gt-jdbc-2.6.4-sources.zip b/cots/org.geotools/gt-jdbc-2.6.4-sources.zip deleted file mode 100644 index 54dc72f508..0000000000 Binary files a/cots/org.geotools/gt-jdbc-2.6.4-sources.zip and /dev/null differ diff --git a/cots/org.geotools/gt-jdbc-2.6.4.jar b/cots/org.geotools/gt-jdbc-2.6.4.jar deleted file mode 100644 index 21b9ae477f..0000000000 Binary files a/cots/org.geotools/gt-jdbc-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-jdbc-postgis-10.5.jar b/cots/org.geotools/gt-jdbc-postgis-10.5.jar new file mode 100644 index 0000000000..8d0eb6d818 Binary files /dev/null and b/cots/org.geotools/gt-jdbc-postgis-10.5.jar differ diff --git a/cots/org.geotools/gt-jdbc-postgis-2.6.4-sources.zip b/cots/org.geotools/gt-jdbc-postgis-2.6.4-sources.zip deleted file mode 100644 index 51f520cfed..0000000000 Binary files a/cots/org.geotools/gt-jdbc-postgis-2.6.4-sources.zip and /dev/null differ diff --git a/cots/org.geotools/gt-jdbc-postgis-2.6.4.jar b/cots/org.geotools/gt-jdbc-postgis-2.6.4.jar deleted file mode 100644 index 199529c592..0000000000 Binary files a/cots/org.geotools/gt-jdbc-postgis-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-main-10.5.jar b/cots/org.geotools/gt-main-10.5.jar new file mode 100644 index 0000000000..14c4828ae0 Binary files /dev/null and b/cots/org.geotools/gt-main-10.5.jar differ diff --git a/cots/org.geotools/gt-main-2.6.4-sources.jar b/cots/org.geotools/gt-main-2.6.4-sources.jar deleted file mode 100644 index 110c873937..0000000000 Binary files a/cots/org.geotools/gt-main-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-main-2.6.4.jar b/cots/org.geotools/gt-main-2.6.4.jar deleted file mode 100644 index 351bf4d47a..0000000000 Binary files a/cots/org.geotools/gt-main-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-metadata-10.5.jar b/cots/org.geotools/gt-metadata-10.5.jar new file mode 100644 index 0000000000..c6740c9142 Binary files /dev/null and b/cots/org.geotools/gt-metadata-10.5.jar differ diff --git a/cots/org.geotools/gt-metadata-2.6.4-sources.jar b/cots/org.geotools/gt-metadata-2.6.4-sources.jar deleted file mode 100644 index f30c86b52c..0000000000 Binary files a/cots/org.geotools/gt-metadata-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-metadata-2.6.4.jar b/cots/org.geotools/gt-metadata-2.6.4.jar deleted file mode 100644 index fa7e85d0cf..0000000000 Binary files a/cots/org.geotools/gt-metadata-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-opengis-10.5.jar b/cots/org.geotools/gt-opengis-10.5.jar new file mode 100644 index 0000000000..d17d3e6851 Binary files /dev/null and b/cots/org.geotools/gt-opengis-10.5.jar differ diff --git a/cots/org.geotools/gt-postgis-2.6.4-sources.zip b/cots/org.geotools/gt-postgis-2.6.4-sources.zip deleted file mode 100644 index d6d3fbcbfd..0000000000 Binary files a/cots/org.geotools/gt-postgis-2.6.4-sources.zip and /dev/null differ diff --git a/cots/org.geotools/gt-postgis-2.6.4.jar b/cots/org.geotools/gt-postgis-2.6.4.jar deleted file mode 100644 index 95260bb280..0000000000 Binary files a/cots/org.geotools/gt-postgis-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-referencing-10.5.jar b/cots/org.geotools/gt-referencing-10.5.jar new file mode 100644 index 0000000000..6a72451862 Binary files /dev/null and b/cots/org.geotools/gt-referencing-10.5.jar differ diff --git a/cots/org.geotools/gt-referencing-2.6.4-sources.jar b/cots/org.geotools/gt-referencing-2.6.4-sources.jar deleted file mode 100644 index 331cbde088..0000000000 Binary files a/cots/org.geotools/gt-referencing-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-referencing-2.6.4.jar b/cots/org.geotools/gt-referencing-2.6.4.jar deleted file mode 100644 index 2353fc15e3..0000000000 Binary files a/cots/org.geotools/gt-referencing-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-referencing3D-2.6.4.jar b/cots/org.geotools/gt-referencing3D-10.5.jar similarity index 95% rename from cots/org.geotools/gt-referencing3D-2.6.4.jar rename to cots/org.geotools/gt-referencing3D-10.5.jar index bdf96f2c1b..9e85456bc4 100644 Binary files a/cots/org.geotools/gt-referencing3D-2.6.4.jar and b/cots/org.geotools/gt-referencing3D-10.5.jar differ diff --git a/cots/org.geotools/gt-referencing3D-2.6.4-sources.jar b/cots/org.geotools/gt-referencing3D-2.6.4-sources.jar deleted file mode 100644 index 8934104ffd..0000000000 Binary files a/cots/org.geotools/gt-referencing3D-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-render-10.5.jar b/cots/org.geotools/gt-render-10.5.jar new file mode 100644 index 0000000000..74cfca5bb8 Binary files /dev/null and b/cots/org.geotools/gt-render-10.5.jar differ diff --git a/cots/org.geotools/gt-render-2.6.4.jar b/cots/org.geotools/gt-render-2.6.4.jar deleted file mode 100644 index c6e0feb793..0000000000 Binary files a/cots/org.geotools/gt-render-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-shapefile-10.5.jar b/cots/org.geotools/gt-shapefile-10.5.jar new file mode 100644 index 0000000000..0475746db3 Binary files /dev/null and b/cots/org.geotools/gt-shapefile-10.5.jar differ diff --git a/cots/org.geotools/gt-shapefile-2.6.4-sources.jar b/cots/org.geotools/gt-shapefile-2.6.4-sources.jar deleted file mode 100644 index 49cf3c7aa4..0000000000 Binary files a/cots/org.geotools/gt-shapefile-2.6.4-sources.jar and /dev/null differ diff --git a/cots/org.geotools/gt-shapefile-2.6.4.jar b/cots/org.geotools/gt-shapefile-2.6.4.jar deleted file mode 100644 index b19ac8fd87..0000000000 Binary files a/cots/org.geotools/gt-shapefile-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-wfs-10.5.jar b/cots/org.geotools/gt-wfs-10.5.jar new file mode 100644 index 0000000000..a9c2a078b8 Binary files /dev/null and b/cots/org.geotools/gt-wfs-10.5.jar differ diff --git a/cots/org.geotools/gt-wfs-2.6.4.jar b/cots/org.geotools/gt-wfs-2.6.4.jar deleted file mode 100644 index 4e09d57d86..0000000000 Binary files a/cots/org.geotools/gt-wfs-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xml-10.5.jar b/cots/org.geotools/gt-xml-10.5.jar new file mode 100644 index 0000000000..dc8e64d01d Binary files /dev/null and b/cots/org.geotools/gt-xml-10.5.jar differ diff --git a/cots/org.geotools/gt-xml-2.6.4.jar b/cots/org.geotools/gt-xml-2.6.4.jar deleted file mode 100644 index 4a089f7b0b..0000000000 Binary files a/cots/org.geotools/gt-xml-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-core-10.5.jar b/cots/org.geotools/gt-xsd-core-10.5.jar new file mode 100644 index 0000000000..193d30d878 Binary files /dev/null and b/cots/org.geotools/gt-xsd-core-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-core-2.6.4.jar b/cots/org.geotools/gt-xsd-core-2.6.4.jar deleted file mode 100644 index a765c8c8af..0000000000 Binary files a/cots/org.geotools/gt-xsd-core-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-filter-10.5.jar b/cots/org.geotools/gt-xsd-filter-10.5.jar new file mode 100644 index 0000000000..673727cdd3 Binary files /dev/null and b/cots/org.geotools/gt-xsd-filter-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-filter-2.6.4.jar b/cots/org.geotools/gt-xsd-filter-2.6.4.jar deleted file mode 100644 index 5e0785b99f..0000000000 Binary files a/cots/org.geotools/gt-xsd-filter-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-gml2-10.5.jar b/cots/org.geotools/gt-xsd-gml2-10.5.jar new file mode 100644 index 0000000000..f6bce8c09e Binary files /dev/null and b/cots/org.geotools/gt-xsd-gml2-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-gml2-2.6.4.jar b/cots/org.geotools/gt-xsd-gml2-2.6.4.jar deleted file mode 100644 index d76751cd40..0000000000 Binary files a/cots/org.geotools/gt-xsd-gml2-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-gml3-10.5.jar b/cots/org.geotools/gt-xsd-gml3-10.5.jar new file mode 100644 index 0000000000..385c91707a Binary files /dev/null and b/cots/org.geotools/gt-xsd-gml3-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-gml3-2.6.4.jar b/cots/org.geotools/gt-xsd-gml3-2.6.4.jar deleted file mode 100644 index 7a60845970..0000000000 Binary files a/cots/org.geotools/gt-xsd-gml3-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-kml-2.6.4.jar b/cots/org.geotools/gt-xsd-kml-10.5.jar similarity index 59% rename from cots/org.geotools/gt-xsd-kml-2.6.4.jar rename to cots/org.geotools/gt-xsd-kml-10.5.jar index 8dcf45eea8..d9cd497725 100644 Binary files a/cots/org.geotools/gt-xsd-kml-2.6.4.jar and b/cots/org.geotools/gt-xsd-kml-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-ows-10.5.jar b/cots/org.geotools/gt-xsd-ows-10.5.jar new file mode 100644 index 0000000000..5313bccbd2 Binary files /dev/null and b/cots/org.geotools/gt-xsd-ows-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-ows-2.6.4.jar b/cots/org.geotools/gt-xsd-ows-2.6.4.jar deleted file mode 100644 index 07abbbf8b1..0000000000 Binary files a/cots/org.geotools/gt-xsd-ows-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-sld-10.5.jar b/cots/org.geotools/gt-xsd-sld-10.5.jar new file mode 100644 index 0000000000..fd9253b007 Binary files /dev/null and b/cots/org.geotools/gt-xsd-sld-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-sld-2.6.4.jar b/cots/org.geotools/gt-xsd-sld-2.6.4.jar deleted file mode 100644 index 22cf6802b1..0000000000 Binary files a/cots/org.geotools/gt-xsd-sld-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/gt-xsd-wfs-10.5.jar b/cots/org.geotools/gt-xsd-wfs-10.5.jar new file mode 100644 index 0000000000..6bdb14c924 Binary files /dev/null and b/cots/org.geotools/gt-xsd-wfs-10.5.jar differ diff --git a/cots/org.geotools/gt-xsd-wfs-2.6.4.jar b/cots/org.geotools/gt-xsd-wfs-2.6.4.jar deleted file mode 100644 index 0c60b58051..0000000000 Binary files a/cots/org.geotools/gt-xsd-wfs-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/jts-1.10.jar b/cots/org.geotools/jts-1.10.jar deleted file mode 100644 index 5821cd9304..0000000000 Binary files a/cots/org.geotools/jts-1.10.jar and /dev/null differ diff --git a/cots/org.geotools/jts-1.10.zip b/cots/org.geotools/jts-1.10.zip deleted file mode 100644 index ba4967491c..0000000000 Binary files a/cots/org.geotools/jts-1.10.zip and /dev/null differ diff --git a/cots/org.geotools/jts-1.13-sources.jar b/cots/org.geotools/jts-1.13-sources.jar new file mode 100644 index 0000000000..84ef480e46 Binary files /dev/null and b/cots/org.geotools/jts-1.13-sources.jar differ diff --git a/cots/org.geotools/jts-1.13.jar b/cots/org.geotools/jts-1.13.jar new file mode 100644 index 0000000000..bbaa20bfac Binary files /dev/null and b/cots/org.geotools/jts-1.13.jar differ diff --git a/cots/org.geotools/net.opengis.ows-10.5.jar b/cots/org.geotools/net.opengis.ows-10.5.jar new file mode 100644 index 0000000000..ac3204332a Binary files /dev/null and b/cots/org.geotools/net.opengis.ows-10.5.jar differ diff --git a/cots/org.geotools/net.opengis.ows-2.6.4.jar b/cots/org.geotools/net.opengis.ows-2.6.4.jar deleted file mode 100644 index 43f0d49ba9..0000000000 Binary files a/cots/org.geotools/net.opengis.ows-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/net.opengis.wfs-10.5.jar b/cots/org.geotools/net.opengis.wfs-10.5.jar new file mode 100644 index 0000000000..99f41f37ff Binary files /dev/null and b/cots/org.geotools/net.opengis.wfs-10.5.jar differ diff --git a/cots/org.geotools/net.opengis.wfs-2.6.4.jar b/cots/org.geotools/net.opengis.wfs-2.6.4.jar deleted file mode 100644 index cab8df7593..0000000000 Binary files a/cots/org.geotools/net.opengis.wfs-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/net.opengis.wfsv-2.6.4.jar b/cots/org.geotools/net.opengis.wfsv-2.6.4.jar deleted file mode 100644 index abc7e0d38c..0000000000 Binary files a/cots/org.geotools/net.opengis.wfsv-2.6.4.jar and /dev/null differ diff --git a/cots/org.geotools/xsd-2.2.2.jar b/cots/org.geotools/xsd-2.2.2.jar deleted file mode 100644 index 23487367f3..0000000000 Binary files a/cots/org.geotools/xsd-2.2.2.jar and /dev/null differ diff --git a/cots/org.geotools/xsd-2.6.0.jar b/cots/org.geotools/xsd-2.6.0.jar new file mode 100644 index 0000000000..28ff987cef Binary files /dev/null and b/cots/org.geotools/xsd-2.6.0.jar differ diff --git a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.dbf b/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.dbf deleted file mode 100644 index ce5fee3e3c..0000000000 Binary files a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.dbf and /dev/null differ diff --git a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.fix b/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.fix deleted file mode 100644 index 767ae20da3..0000000000 Binary files a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.fix and /dev/null differ diff --git a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.grx b/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.grx deleted file mode 100644 index 790f49ab44..0000000000 Binary files a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.grx and /dev/null differ diff --git a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.shp b/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.shp deleted file mode 100644 index af57b34b7c..0000000000 Binary files a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.shp and /dev/null differ diff --git a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.shx b/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.shx deleted file mode 100644 index 1e86a71ca9..0000000000 Binary files a/edexOsgi/build.edex/esb/data/static/spatial/stations/stations.shx and /dev/null differ diff --git a/edexOsgi/com.raytheon.edex.common/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.common/META-INF/MANIFEST.MF index 078ae9bef2..7443dd8238 100644 --- a/edexOsgi/com.raytheon.edex.common/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.common/META-INF/MANIFEST.MF @@ -21,8 +21,7 @@ Export-Package: com.raytheon.edex.colormap, com.raytheon.edex.topo, com.raytheon.edex.urifilter, com.raytheon.edex.util, - com.raytheon.edex.utility, - com.raytheon.edex.common.shapefiles + com.raytheon.edex.utility Require-Bundle: net.sf.ehcache, org.apache.commons.configuration, org.apache.velocity;bundle-version="1.6.0", diff --git a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/CreateStationShp.java b/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/CreateStationShp.java deleted file mode 100644 index 91ff1da143..0000000000 --- a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/util/CreateStationShp.java +++ /dev/null @@ -1,173 +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.edex.util; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; - -import org.geotools.data.FeatureStore; -import org.geotools.data.FeatureWriter; -import org.geotools.data.Transaction; -import org.geotools.data.shapefile.indexed.IndexType; -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.Point; - -/** - * Creates a station catalog shapefile - * - * @author chammack - * - */ -public class CreateStationShp { - - public static void main(String[] args) { - - File theShape = new File("D:/temp/stations.shp"); - GeometryFactory geomFactory = new GeometryFactory(); - try { - // Set up what our data schema will look like - SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); - builder.setName("stations"); - builder.add("the_geom", Point.class); - builder.add("icao", String.class); - builder.add("attrib2", String.class); - builder.add("attrib3", String.class); - builder.add("name", String.class); - builder.add("state", String.class); - builder.add("country", String.class); - builder.add("attrib7", String.class); - builder.add("attrib12", String.class); - builder.add("attrib13", String.class); - - SimpleFeatureType featureType = builder.buildFeatureType(); - - // Load up the indexed datastore - IndexedShapefileDataStore shpDS = new IndexedShapefileDataStore( - theShape.toURI().toURL(), null, true, true, IndexType.QIX); - - // Tell the datastore to create the dbf schema if it does not - // exist - shpDS.createSchema(featureType); - - // Get the transaction object - FeatureStore fs = (FeatureStore) shpDS - .getFeatureSource(); - Transaction trx = (fs).getTransaction(); - - // Open a feature writer with the transaction - FeatureWriter writer = shpDS - .getFeatureWriter(trx); - - // Open the textfile - BufferedReader br = new BufferedReader(new FileReader( - "D:/temp/nsd_cccc.txt")); - while (br.ready()) { - - // Read and parse the file - String line = br.readLine(); - String[] fields = line.split(";", -1); - if (fields.length < 12) { - System.out.println("Parse error on line " + line + " (" - + fields.length + ")"); - System.exit(0); - } - - // Load the feature to write, and set all of the properties by - // name - SimpleFeature feature = writer.next(); - feature.setAttribute("icao", fields[0]); - feature.setAttribute("attrib2", fields[1]); - feature.setAttribute("attrib3", fields[2]); - feature.setAttribute("name", fields[3]); - feature.setAttribute("state", fields[4]); - feature.setAttribute("country", fields[5]); - feature.setAttribute("attrib7", fields[6]); - - // Parse out dms - double lat1 = extractDegrees(fields[7]); - double lon1 = extractDegrees(fields[8]); - - // Construct the point geometry object and add to the feature - Coordinate pt1 = new Coordinate(lon1, lat1); - Point p = geomFactory.createPoint(pt1); - feature.setDefaultGeometry(p); - - feature.setAttribute("attrib12", fields[11]); - if (fields.length >= 13) { - feature.setAttribute("attrib13", fields[12]); - } - - writer.write(); - - } - - writer.close(); - System.out.println("Done"); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - private static double extractDegrees(String rawField) { - String[] dms = rawField.split("-"); - int deg = Integer.parseInt(dms[0].trim()); - - char dir; - - int min = 0; - int sec = 0; - if (dms.length == 2) { - dir = dms[1].charAt(dms[1].length() - 1); - min = Integer.parseInt(dms[1].substring(0, dms[1].length() - 1)); - - } else { - min = Integer.parseInt(dms[1]); - - dir = dms[2].charAt(dms[2].length() - 1); - String substr = dms[2].substring(0, dms[2].length() - 1); - if (substr.trim().length() > 0) { - sec = Integer.parseInt(substr); - } - - } - if (dir == 'S' || dir == 'W') { - return dmsToDecimal(deg, min, sec) * -1; - } else { - return dmsToDecimal(deg, min, sec); - } - - } - - private static double dmsToDecimal(int deg, int min, int sec) { - return ((min) / 60.0) + ((sec) / 3600.0) + deg; - } - -} diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java index 39ec233862..9e6440462a 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/reference/DbShapeSource.java @@ -24,19 +24,19 @@ 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.NoSuchElementException; import java.util.Properties; import org.geotools.data.DataStore; -import org.geotools.data.DefaultQuery; -import org.geotools.data.FeatureSource; -import org.geotools.data.postgis.PostgisDataStoreFactory; +import org.geotools.data.Query; +import org.geotools.data.postgis.PostgisNGDataStoreFactory; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; +import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.GeoTools; -import org.geotools.feature.FeatureCollection; import org.hibernate.engine.SessionFactoryImplementor; import org.opengis.feature.IllegalAttributeException; import org.opengis.feature.simple.SimpleFeature; @@ -70,6 +70,7 @@ import com.vividsolutions.jts.geom.Polygon; * Sep 18, 2012 #1091 randerso Initial creation * Mar 28, 2013 #1837 dgilling Change error handling in * getLastUpdated(). + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -107,9 +108,9 @@ public class DbShapeSource { private List attributeNames; - private FeatureCollection featureCollection; + private SimpleFeatureCollection featureCollection; - private Iterator featureIterator; + private SimpleFeatureIterator featureIterator; private String shapeField; @@ -119,7 +120,7 @@ public class DbShapeSource { private BoundingBox boundingBox; - private DefaultQuery query; + private Query query; private SimpleFeatureType schema; @@ -156,7 +157,7 @@ public class DbShapeSource { String port = props.getProperty("db.port"); String user = props.getProperty("connection.username"); String passwd = props.getProperty("connection.password"); - PostgisDataStoreFactory factory = new PostgisDataStoreFactory(); + PostgisNGDataStoreFactory factory = new PostgisNGDataStoreFactory(); Map params = new HashMap(); params.put("host", host); params.put("port", port); @@ -189,7 +190,7 @@ public class DbShapeSource { featureCollection = null; featureIterator = null; - query = new DefaultQuery(); + query = new Query(); query.setTypeName(this.tableName); List propNames = new ArrayList(getAttributeNames()); propNames.add(shapeField); @@ -212,10 +213,10 @@ public class DbShapeSource { query.setFilter(filter); } - FeatureSource featureSource = dataStore + SimpleFeatureSource featureSource = dataStore .getFeatureSource(this.tableName); featureCollection = featureSource.getFeatures(query); - featureIterator = featureCollection.iterator(); + featureIterator = featureCollection.features(); } /** @@ -233,7 +234,7 @@ public class DbShapeSource { */ public void close() throws IOException { if (featureIterator != null) { - featureCollection.close(featureIterator); + featureIterator.close(); featureIterator = null; featureCollection = null; } @@ -266,13 +267,14 @@ public class DbShapeSource { Class geometryType = schema.getGeometryDescriptor().getType() .getBinding(); - if (geometryType == Point.class || geometryType == MultiPoint.class) { + if ((geometryType == Point.class) + || (geometryType == MultiPoint.class)) { this.type = ShapeType.POINT; - } else if (geometryType == LineString.class - || geometryType == MultiLineString.class) { + } else if ((geometryType == LineString.class) + || (geometryType == MultiLineString.class)) { this.type = ShapeType.POLYLINE; - } else if (geometryType == Polygon.class - || geometryType == MultiPolygon.class) { + } else if ((geometryType == Polygon.class) + || (geometryType == MultiPolygon.class)) { this.type = ShapeType.POLYGON; } else { this.type = ShapeType.NONE; @@ -289,7 +291,7 @@ public class DbShapeSource { if (attributeNames == null) { List attrDesc = schema .getAttributeDescriptors(); - if (attrDesc == null || attrDesc.size() == 0) { + if ((attrDesc == null) || (attrDesc.size() == 0)) { return null; } diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Import88DLocationsUtil.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Import88DLocationsUtil.java index 573a0aadd5..cf6831fad5 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Import88DLocationsUtil.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Import88DLocationsUtil.java @@ -14,7 +14,6 @@ import java.util.Set; import org.opengis.feature.Property; import org.opengis.feature.simple.SimpleFeature; -import com.raytheon.edex.common.shapefiles.Shapefile; import com.raytheon.edex.plugin.radar.dao.RadarStationDao; import com.raytheon.uf.common.dataplugin.radar.RadarStation; import com.raytheon.uf.common.localization.IPathManager; diff --git a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/common/shapefiles/Shapefile.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Shapefile.java similarity index 95% rename from edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/common/shapefiles/Shapefile.java rename to edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Shapefile.java index 24878f72f1..f7a14fe356 100644 --- a/edexOsgi/com.raytheon.edex.common/src/com/raytheon/edex/common/shapefiles/Shapefile.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/util/Shapefile.java @@ -1,4 +1,4 @@ -package com.raytheon.edex.common.shapefiles; +package com.raytheon.edex.plugin.radar.util; import java.io.File; import java.io.IOException; @@ -15,13 +15,13 @@ import org.geotools.data.DataStore; import org.geotools.data.DataStoreFactorySpi; import org.geotools.data.DataStoreFinder; import org.geotools.data.DefaultTransaction; -import org.geotools.data.FeatureSource; import org.geotools.data.FeatureStore; import org.geotools.data.Transaction; import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.data.shapefile.ShapefileDataStoreFactory; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureCollections; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureSource; +import org.geotools.feature.DefaultFeatureCollection; import org.geotools.feature.FeatureIterator; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; @@ -37,7 +37,7 @@ import com.vividsolutions.jts.geom.Geometry; * Represents a shape file. Basically a convenience function to simplify the * tasks of reading/writing shapefiles (using GeoTools). Most of the shapefile * reading/writing/editing code has been copied or adapted from the GeoTools - * tutorials which come with the GeoToolssoftware. + * tutorials which come with the GeoTools software. *

* Typical usage (reads a shapefile, get an attribute, adds a new attribute * column, then writes it):
@@ -53,7 +53,8 @@ import com.vividsolutions.jts.geom.Geometry; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 10Oct2011 10520 JWork Initial check-in. + * 10Oct2011 10520 JWork Initial check-in. + * 11Mar2014 #2718 randerso Changes for GeoTools 10.5 * * */ @@ -81,7 +82,7 @@ public class Shapefile { * The FeatureSource for this shapefile, required as a template for writing * shapefiles */ - private FeatureSource theFeatureSource; + private SimpleFeatureSource theFeatureSource; /** Optional column used to store object ids (by default will use FID). */ private String theIDColumn = null; @@ -170,9 +171,11 @@ public class Shapefile { } // Check the input values are ok List badIDs = new ArrayList(); - for (String i : attributeValues.keySet()) - if (!this.theFeaturesMap.containsKey(i)) + for (String i : attributeValues.keySet()) { + if (!this.theFeaturesMap.containsKey(i)) { badIDs.add(i); + } + } if (badIDs.size() > 0) { if (statusHandler.isPriorityEnabled(Priority.PROBLEM)) { statusHandler.handle( @@ -245,8 +248,7 @@ public class Shapefile { String typeName = typeNames[0]; this.theFeatureSource = dataStore.getFeatureSource(typeName); - FeatureCollection collection = theFeatureSource - .getFeatures(); + SimpleFeatureCollection collection = theFeatureSource.getFeatures(); FeatureIterator iterator = collection.features(); try { @@ -255,11 +257,12 @@ public class Shapefile { // Set the feature's ID String id = null; try { - if (this.theIDColumn != null) + if (this.theIDColumn != null) { id = (String) feature .getAttribute(this.theIDColumn); - else + } else { id = feature.getID(); + } } catch (ClassCastException e) { if (statusHandler.isPriorityEnabled(Priority.PROBLEM)) { statusHandler @@ -335,8 +338,7 @@ public class Shapefile { // Check the output file can be written to File outFile = new File(anOutputFileName); // Create a feature collection to write the features out to - FeatureCollection outFeatures = FeatureCollections - .newCollection(); + DefaultFeatureCollection outFeatures = new DefaultFeatureCollection(); for (SimpleFeature simpleFeature : this.theFeaturesMap.values()) { outFeatures.add(simpleFeature); } @@ -459,10 +461,11 @@ public class Shapefile { * Make sure there are some features in this Shapefile, return false if not. */ private boolean checkFeatures() { - if (this.theFeaturesMap == null || this.theFeaturesMap.size() == 0) + if ((this.theFeaturesMap == null) || (this.theFeaturesMap.size() == 0)) { return false; - else + } else { return true; + } } /** diff --git a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/output/Shapefile.java b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/output/Shapefile.java index b8a0bebb2c..83a3fd986b 100644 --- a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/output/Shapefile.java +++ b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/output/Shapefile.java @@ -26,10 +26,10 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.data.FeatureStore; import org.geotools.data.FeatureWriter; import org.geotools.data.Transaction; import org.geotools.data.shapefile.ShapefileDataStore; +import org.geotools.data.store.ContentFeatureSource; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; @@ -44,9 +44,10 @@ import com.vividsolutions.jts.geom.Point; * *

  * SOFTWARE HISTORY
- * Date             PR#             Engineer            Description
- * -----------      ----------      ------------        --------------------------
- * Apr 11, 2007                     njensen             Initial Creation
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 11, 2007            njensen     Initial Creation
+ * Mar 11, 2014  #2718     randerso    Changes for GeoTools 10.5
  * 
* */ @@ -137,15 +138,15 @@ public class Shapefile extends ScriptTask { // Load up the datastore ShapefileDataStore shpDS = new ShapefileDataStore(theShape.toURI() - .toURL(), null, true); + .toURL()); + shpDS.setMemoryMapped(true); // Tell the datastore to create the dbf schema if it does not // exist shpDS.createSchema(featureType); // Get the transaction object - FeatureStore fs = (FeatureStore) shpDS - .getFeatureSource(); + ContentFeatureSource fs = shpDS.getFeatureSource(); Transaction trx = fs.getTransaction(); // Open a feature writer with the transaction @@ -161,8 +162,8 @@ public class Shapefile extends ScriptTask { // iterate through all for (Map.Entry> entry : shapefileAttributes .entrySet()) { - feature.setAttribute(entry.getKey(), entry.getValue().get( - counter)); + feature.setAttribute(entry.getKey(), + entry.getValue().get(counter)); } feature.setDefaultGeometry(collection.getGeometryN(counter)); diff --git a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/query/ShapefileQuery.java b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/query/ShapefileQuery.java index 52eacfe776..5107a906ec 100644 --- a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/query/ShapefileQuery.java +++ b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/tasks/query/ShapefileQuery.java @@ -29,9 +29,8 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import org.geotools.data.DefaultQuery; -import org.geotools.data.shapefile.indexed.IndexType; -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; +import org.geotools.data.Query; +import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.GeoTools; import org.geotools.feature.FeatureIterator; @@ -53,9 +52,10 @@ import com.raytheon.uf.common.geospatial.MapUtil; * *
  * SOFTWARE HISTORY
- * Date             PR#             Engineer            Description
- * -----------      ----------      ------------        --------------------------
- * Apr 11, 2007                     njensen             Initial Creation
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 11, 2007            njensen     Initial Creation
+ * Mar 11, 2014  #2718     randerso    Changes for GeoTools 10.5
  * 
* */ @@ -93,9 +93,8 @@ public class ShapefileQuery extends ScriptTask { logger.warn("Querying shapeFile: " + theShape.getAbsolutePath()); Map> resultMap = new HashMap>(); try { - IndexedShapefileDataStore shpDS; - shpDS = new IndexedShapefileDataStore(theShape.toURI().toURL(), - null, false, false, IndexType.QIX); + ShapefileDataStore shpDS; + shpDS = new ShapefileDataStore(theShape.toURI().toURL()); // Load up the schema attributes into memory List at = new ArrayList(); @@ -119,7 +118,7 @@ public class ShapefileQuery extends ScriptTask { // Get the types String[] types = shpDS.getTypeNames(); - DefaultQuery query = new DefaultQuery(); + Query query = new Query(); // Query geom query.setTypeName(types[0]); diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java index 4b8187b33b..4b663a11d0 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/EnvelopeUtils.java @@ -47,6 +47,7 @@ import com.vividsolutions.jts.geom.Coordinate; * ------------ ---------- ----------- -------------------------- * Dec 5, 2012 bsteffen Initial creation. * Jun 21, 2013 2132 mpduf createSubEnvelopeFromLatLon now uses East/West direction. + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -209,10 +210,10 @@ public class EnvelopeUtils { AbstractProvider.CENTRAL_MERIDIAN.getName().getCode()) .doubleValue(); } - while (latLon.x < centralMeridian - 180.0) { + while (latLon.x < (centralMeridian - 180.0)) { latLon.x += 360.0; } - while (latLon.x > centralMeridian + 180.0) { + while (latLon.x > (centralMeridian + 180.0)) { latLon.x -= 360.0; } return latLon; @@ -284,7 +285,7 @@ public class EnvelopeUtils { CoordinateReferenceSystem crs, Coordinate latLon1, Coordinate latLon2) { try { - ReferencedEnvelope e = new ReferencedEnvelope(crs); + ReferencedEnvelope e = ReferencedEnvelope.create(crs); latLon1 = normalizeLongitude(e, latLon1); latLon2 = normalizeLongitude(e, latLon2); @@ -308,7 +309,7 @@ public class EnvelopeUtils { } return e; } catch (FactoryException e) { - return new ReferencedEnvelope(crs); + return ReferencedEnvelope.create(crs); } } @@ -339,7 +340,8 @@ public class EnvelopeUtils { */ public static ReferencedEnvelope createLatLonEnvelope(Coordinate latLon1, Coordinate latLon2) { - ReferencedEnvelope e = new ReferencedEnvelope(MapUtil.LATLON_PROJECTION); + ReferencedEnvelope e = ReferencedEnvelope + .create(MapUtil.LATLON_PROJECTION); e.expandToInclude(latLon1); e.expandToInclude(latLon2); return e; diff --git a/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/GeoJsonMapUtil.java b/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/GeoJsonMapUtil.java index 6b06ac4b09..42510531d1 100644 --- a/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/GeoJsonMapUtil.java +++ b/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/GeoJsonMapUtil.java @@ -71,836 +71,848 @@ import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; /** + * GeoJson Map Utilities + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug  9, 2011            bclement    Initial creation
+ * Mar 11, 2014      #2718 randerso    Changes for GeoTools 10.5
+ * 
+ * 
* * @author bclement * @version 1.0 */ public class GeoJsonMapUtil { - public enum FeatureOpt { - ENCODE_CRS, ENCODE_BOUNDS - }; + public enum FeatureOpt { + ENCODE_CRS, ENCODE_BOUNDS + }; - public static final String TYPE_KEY = "type"; + public static final String TYPE_KEY = "type"; - public static final String GEOM_KEY = "geometry"; + public static final String GEOM_KEY = "geometry"; - public static final String PROP_KEY = "properties"; + public static final String PROP_KEY = "properties"; - public static final String COORD_KEY = "coordinates"; + public static final String COORD_KEY = "coordinates"; - public static final String POINT_TYPE = "Point"; + public static final String POINT_TYPE = "Point"; - public static final String LINE_STR_TYPE = "LineString"; - - public static final String POLY_TYPE = "Polygon"; - - public static final String MULT_POINT_TYPE = "Multi" + POINT_TYPE; - - public static final String MULT_LINE_STR_TYPE = "Multi" + LINE_STR_TYPE; - - public static final String MULT_POLY_TYPE = "Multi" + POLY_TYPE; - - public static final String GEOM_COLL_TYPE = "GeometryCollection"; - - public static final String FEATURE_TYPE = "Feature"; - - public static final String ID_KEY = "id"; - - public static final String FEATURE_COLL_TYPE = "FeatureCollection"; - - public static final String CRS_KEY = "crs"; - - public static final String NAME_KEY = "name"; - - public static final String LINK_KEY = "link"; - - public static final String HREF_KEY = "href"; - - public static final String BBOX_KEY = "bbox"; - - public static final String FEATURES_KEY = "features"; - - public static final String GEOMS_KEY = "geometries"; - - private GeometryFactory _geomFact; - - private Object _mutex = new Object(); - - protected GeometryFactory getGeomFact() { - if (_geomFact == null) { - synchronized (_mutex) { - // check again - if (_geomFact == null) { - _geomFact = new GeometryFactory(); - } - } - } - return _geomFact; - } - - public Map extract(Geometry geom) throws JsonException { - if (geom instanceof Point) { - return extractPoint((Point) geom); - } else if (geom instanceof LineString) { - return extractLineString((LineString) geom); - } else if (geom instanceof Polygon) { - return extractPolygon((Polygon) geom); - } else if (geom instanceof MultiPoint) { - return extractMultiPoint((MultiPoint) geom); - } else if (geom instanceof MultiLineString) { - return extractMultiLineString((MultiLineString) geom); - } else if (geom instanceof MultiPolygon) { - return extractMultiPolygon((MultiPolygon) geom); - } else if (geom instanceof GeometryCollection) { - return extractGeometryCollection((GeometryCollection) geom); - } else { - throw new JsonException("Unkown geometry type: " + geom.getClass()); - } - } - - public Geometry populateGeometry(Map jsonObj) - throws JsonException { - String type = (String) jsonObj.get(TYPE_KEY); - if (type == null) { - throw new JsonException("Unable to find type in json map"); - } - if (POINT_TYPE.equals(type)) { - return populatePoint(jsonObj); - } else if (LINE_STR_TYPE.equals(type)) { - return populateLineString(jsonObj); - } else if (POLY_TYPE.equals(type)) { - return populatePolygon(jsonObj); - } else if (MULT_POINT_TYPE.equals(type)) { - return populateMultiPoint(jsonObj); - } else if (MULT_LINE_STR_TYPE.equals(type)) { - return populateMultiLineString(jsonObj); - } else if (MULT_POLY_TYPE.equals(type)) { - return populateMultiPolygon(jsonObj); - } else if (GEOM_COLL_TYPE.equals(type)) { - return populateGeomCollection(jsonObj); - } else { - throw new JsonException("Unkown GeoJson geometry type: " + type); - } - } - - public Map extract(SimpleFeature feature) - throws JsonException { - return extract(feature, EnumSet.noneOf(FeatureOpt.class)); - } - - public Map extract(SimpleFeature feature, - EnumSet opts) throws JsonException { - Object geom = feature.getDefaultGeometry(); - Map rval = new LinkedHashMap(6); - rval.put(TYPE_KEY, FEATURE_TYPE); - SimpleFeatureType type = feature.getFeatureType(); - if (type == null) { - throw new JsonException("Feature type cannot be null"); - } - String id = feature.getID(); - if (id != null) { - rval.put(ID_KEY, id); - } - if (opts.contains(FeatureOpt.ENCODE_CRS)) { - CoordinateReferenceSystem crs = type.getCoordinateReferenceSystem(); - if (crs != null) { - rval.put(CRS_KEY, extract(crs)); - } - } - if (opts.contains(FeatureOpt.ENCODE_BOUNDS)) { - BoundingBox bounds = feature.getBounds(); - if (bounds != null) { - rval.put(BBOX_KEY, getBounds(bounds)); - } - } - int geomIndex = -1; - if (geom != null) { - rval.put(GEOM_KEY, extract((Geometry) geom)); - geomIndex = type.indexOf(feature.getDefaultGeometryProperty() - .getName()); - } - int count = type.getAttributeCount(); - Map props = new LinkedHashMap(count); - for (int i = 0; i < count; ++i) { - if (i == geomIndex) { - continue; - } - Object value = feature.getAttribute(i); - if (value == null) { - continue; - } - AttributeDescriptor desc = type.getDescriptor(i); - String name = desc.getLocalName(); - if (value instanceof Geometry) { - props.put(name, extract((Geometry) value)); - } else if (value instanceof Envelope) { - props.put(name, getEnv((Envelope) value)); - } else if (value instanceof BoundingBox) { - props.put(name, getBounds((BoundingBox) value)); - } else { - props.put(name, value); - } - } - rval.put(PROP_KEY, props); - return rval; - } - - public Map extract( - FeatureCollection coll) - throws JsonException { - return extract(coll, EnumSet.noneOf(FeatureOpt.class)); - } - - public Map extract( - FeatureCollection coll, - EnumSet opts) throws JsonException { - Map rval = new LinkedHashMap(4); - rval.put(TYPE_KEY, FEATURE_COLL_TYPE); - ReferencedEnvelope bounds = coll.getBounds(); - if (opts.contains(FeatureOpt.ENCODE_CRS) && bounds != null - && !bounds.isNull()) { - CoordinateReferenceSystem crs = bounds - .getCoordinateReferenceSystem(); - if (crs != null) { - rval.put(CRS_KEY, extract(crs)); - } - } - if (opts.contains(FeatureOpt.ENCODE_BOUNDS) && bounds != null - && !bounds.isNull()) { - rval.put(BBOX_KEY, getBounds(bounds)); - } - FeatureIterator iter = coll.features(); - Object[] features = new Object[coll.size()]; - for (int i = 0; iter.hasNext(); ++i) { - SimpleFeature feature = iter.next(); - features[i] = extract(feature, opts); - } - rval.put(FEATURES_KEY, features); - return rval; - } - - protected double[] getBounds(BoundingBox bbox) { - double minX = bbox.getMinX(); - double minY = bbox.getMinY(); - double maxX = bbox.getMaxX(); - double maxY = bbox.getMaxY(); - return new double[] { minX, minY, maxX, maxY }; - } - - protected double[] getEnv(Envelope bbox) { - double minX = bbox.getMinX(); - double minY = bbox.getMinY(); - double maxX = bbox.getMaxX(); - double maxY = bbox.getMaxY(); - return new double[] { minX, minY, maxX, maxY }; - } - - public Map extract(CoordinateReferenceSystem crs) - throws JsonException { - Map rval = new LinkedHashMap(2); - // TODO supported linked crs - rval.put(TYPE_KEY, NAME_KEY); - Map props = new LinkedHashMap(1); - try { - props.put(NAME_KEY, CRS.lookupIdentifier(crs, true)); - } catch (FactoryException e) { - throw new JsonException("Problem looking up CRS ID", e); - } - rval.put(PROP_KEY, props); - return rval; - } - - @SuppressWarnings("unchecked") - public FeatureCollection populateFeatureCollection( - Map jsonObj, SimpleFeatureType type) - throws JsonException { - Object obj = jsonObj.get(FEATURES_KEY); - if (obj == null) { - if (type == null) { - type = new SimpleFeatureTypeBuilder().buildFeatureType(); - } - return new EmptyFeatureCollection(type); - } - if (!(obj instanceof List)) { - throw new JsonException("Expected List for features, got " - + obj.getClass()); - } - List features = (List) obj; - List rval = new ArrayList(features.size()); - for (Object f : features) { - if (!(f instanceof Map)) { - throw new JsonException("Expected Map for feature got " - + f.getClass()); - } - Map fmap = (Map) f; - if (type == null) { - rval.add(populateFeature(fmap)); - } else { - rval.add(populateFeature(fmap, type)); - } - } - SimpleFeature sample = rval.get(0); - MemoryFeatureCollection coll = new MemoryFeatureCollection( - sample.getFeatureType()); - coll.addAll(rval); - return coll; - } - - protected FeatureCollection getCollection( - List features, SimpleFeatureType type) { - if (type != null) { - MemoryFeatureCollection coll = new MemoryFeatureCollection(type); - coll.addAll(features); - return coll; - } - Map> sorted = new HashMap>(); - - Iterator i = features.iterator(); - while (i.hasNext()) { - SimpleFeature next = i.next(); - List list = sorted.get(next.getFeatureType()); - if (list == null) { - list = new ArrayList(); - } - list.add(next); - } - if (sorted.size() == 1) { - SimpleFeatureType t = features.get(0).getFeatureType(); - MemoryFeatureCollection coll = new MemoryFeatureCollection(t); - coll.addAll(features); - return coll; - } else { - Set keySet = sorted.keySet(); - List> colls = new ArrayList>( - keySet.size()); - for (SimpleFeatureType key : keySet) { - MemoryFeatureCollection coll = new MemoryFeatureCollection(key); - coll.addAll(sorted.get(key)); - colls.add(coll); - } - return new MixedFeatureCollection(colls); - } - } - - public FeatureCollection populateFeatureCollection( - Map jsonObj) throws JsonException { - return populateFeatureCollection(jsonObj, null); - } - - public SimpleFeature populateFeature(Map jsonObj) - throws JsonException { - return populateFeature(jsonObj, "the_geom", "feature"); - } - - public SimpleFeature populateFeature(Map jsonObj, - SimpleFeatureType type) throws JsonException { - String id = (String) jsonObj.get(ID_KEY); - Geometry geom = getFeatureGeom(jsonObj); - SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); - if (geom != null) { - GeometryDescriptor geomDesc = type.getGeometryDescriptor(); - Name geomName = geomDesc.getName(); - builder.set(geomName, geom); - } - Map props = getProps(jsonObj.get(PROP_KEY)); - for (AttributeDescriptor desc : type.getAttributeDescriptors()) { - String name = desc.getLocalName(); - Object value = props.get(name); - if (value != null) { - builder.set(name, value); - } - } - return builder.buildFeature(id); - } - - @SuppressWarnings("unchecked") - protected Geometry getFeatureGeom(Map jsonObj) - throws JsonException { - Object obj = jsonObj.get(GEOM_KEY); - Geometry geom = null; - if (obj != null) { - if (obj instanceof Map) { - geom = populateGeometry((Map) obj); - } else { - throw new JsonException("Unexpected type for geometry: " - + obj.getClass()); - } - } - return geom; - } - - @SuppressWarnings("unchecked") - public SimpleFeature populateFeature(Map jsonObj, - String geomName, String featureName) throws JsonException { - String id = (String) jsonObj.get(ID_KEY); - SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); - typeBuilder.setName(featureName); - Geometry geom = getFeatureGeom(jsonObj); - if (geom != null) { - typeBuilder.setDefaultGeometry(geomName); - typeBuilder.add(geomName, geom.getClass()); - } - Object crsObj = jsonObj.get(CRS_KEY); - CoordinateReferenceSystem crs = null; - if (crsObj != null) { - if (crsObj instanceof Map) { - crs = populateCrs((Map) crsObj); - typeBuilder.setCRS(crs); - } else { - throw new JsonException( - "Expected Map for CRS got" - + crsObj.getClass()); - } - } - List values = new ArrayList(0); - Object propObj = jsonObj.get(PROP_KEY); - if (propObj != null) { - Map props = getProps(propObj); - Set keySet = props.keySet(); - values = new ArrayList(keySet.size()); - for (String key : keySet) { - Object val = props.get(key); - typeBuilder.add(key, val.getClass()); - values.add(val); - } - } - SimpleFeatureType type = typeBuilder.buildFeatureType(); - SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type); - if (geom != null) { - featureBuilder.add(geom); - } - featureBuilder.addAll(values); - return featureBuilder.buildFeature(id); - } - - @SuppressWarnings("unchecked") - protected Map getProps(Object propObj) throws JsonException { - if (!(propObj instanceof Map)) { - throw new JsonException( - "Expected Map for properties got " - + propObj.getClass()); - } - return (Map) propObj; - } - - public CoordinateReferenceSystem populateCrs(Map jsonObj) - throws JsonException { - String type = (String) jsonObj.get(TYPE_KEY); - if (!NAME_KEY.equals(type)) { - // TODO handle link crs - throw new JsonException("Only named CRS supported"); - } - Object propObj = jsonObj.get(PROP_KEY); - if (propObj == null) { - throw new JsonException("Properties required for CRS"); - } - Map props = getProps(propObj); - String name = (String) props.get(NAME_KEY); - try { - return CRS.decode(name); - } catch (Exception e) { - throw new JsonException("Unable to decode namded CRS", e); - } - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - public Point populatePoint(Map jsonObj) - throws JsonException { - Coordinate c = getCoord(jsonObj); - return getGeomFact().createPoint(c); - } - - protected Coordinate getSingleCoordinate(double[] c) throws JsonException { - Coordinate coord; - if (c.length == 3) { - coord = new Coordinate(c[0], c[1], c[2]); - } else if (c.length == 2) { - coord = new Coordinate(c[0], c[1]); - } else { - throw new JsonException("Unsupported coordinate dimention: " - + c.length); - } - return coord; - } - - protected Coordinate getSingleCoordinate(List l) throws JsonException { - Coordinate coord; - double x = (Double) l.get(0); - double y = (Double) l.get(1); - if (l.size() == 3) { - double z = (Double) l.get(2); - coord = new Coordinate(x, y, z); - } else if (l.size() == 2) { - coord = new Coordinate(x, y); - } else { - throw new JsonException("Unsupported coordinate dimention: " - + l.size()); - } - return coord; - } - - protected Coordinate getCoord(Map jsonObj) - throws JsonException { - Object obj = jsonObj.get(COORD_KEY); - if (obj == null) { - throw new JsonException("Unable to find coordinate array"); - } - if (obj instanceof List) { - return getSingleCoordinate((List) obj); - } else if (obj instanceof double[]) { - return getSingleCoordinate((double[]) obj); - } else { - throw new JsonException("Unexpected value for coordinates: " - + obj.getClass()); - } - } - - protected Coordinate[] get2DArr(Map jsonObj) - throws JsonException { - Object obj = jsonObj.get(COORD_KEY); - if (obj == null) { - throw new JsonException("Unable to find coordinate array"); - } - if (obj instanceof List) { - return wrap2D((List) obj); - } else if (obj instanceof double[][]) { - return wrap((double[][]) obj); - } else { - throw new JsonException("Unexpected value for coordinates: " - + obj.getClass()); - } - } - - protected Coordinate[][] get3DArr(Map jsonObj) - throws JsonException { - Object obj = jsonObj.get(COORD_KEY); - if (obj == null) { - throw new JsonException("Unable to find coordinate array"); - } - if (obj instanceof List) { - List list = (List) obj; - return wrap3D(list); - } else if (obj instanceof double[][][]) { - double[][][] arr = (double[][][]) obj; - Coordinate[][] rval = new Coordinate[arr.length][]; - for (int i = 0; i < arr.length; ++i) { - rval[i] = wrap(arr[i]); - } - return rval; - } else { - throw new JsonException("Unexpected value for coordinates: " - + obj.getClass()); - } - } - - protected Coordinate[][] wrap3D(List list) throws JsonException { - Coordinate[][] rval = new Coordinate[list.size()][]; - Iterator iterator = list.iterator(); - for (int i = 0; iterator.hasNext(); ++i) { - List next = (List) iterator.next(); - rval[i] = wrap2D(next); - } - return rval; - } - - protected Coordinate[][][] get4DArr(Map jsonObj) - throws JsonException { - Object obj = jsonObj.get(COORD_KEY); - if (obj == null) { - throw new JsonException("Unable to find coordinate array"); - } - if (obj instanceof List) { - List list = (List) obj; - Coordinate[][][] rval = new Coordinate[list.size()][][]; - Iterator iterator = list.iterator(); - for (int i = 0; iterator.hasNext(); ++i) { - List next = (List) iterator.next(); - rval[i] = wrap3D(next); - } - return rval; - } else { - throw new JsonException("Unexpected value for coordinates: " - + obj.getClass()); - } - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - public LineString populateLineString(Map jsonObj) - throws JsonException { - GeometryFactory geomFact = getGeomFact(); - Coordinate[] coordinates = get2DArr(jsonObj); - return geomFact.createLineString(coordinates); - } - - protected Coordinate[] wrap2D(List coords) throws JsonException { - int count = coords.size(); - Coordinate[] rval = new Coordinate[count]; - Iterator iterator = coords.iterator(); - for (int i = 0; iterator.hasNext(); ++i) { - List inner = (List) iterator.next(); - - rval[i] = getSingleCoordinate(inner); - } - return rval; - } - - protected Coordinate[] wrap(double[][] coords) throws JsonException { - int count = coords.length; - Coordinate[] rval = new Coordinate[count]; - for (int i = 0; i < count; ++i) { - rval[i] = getSingleCoordinate(coords[i]); - } - return rval; - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - public Geometry populatePolygon(Map jsonObj) - throws JsonException { - Coordinate[][] coords = get3DArr(jsonObj); - return getPolygon(coords); - } - - protected Polygon getPolygon(Coordinate[][] coords) throws JsonException { - GeometryFactory geomFact = getGeomFact(); - LinearRing shell = getLinearRing(coords[0]); - LinearRing[] holes = getInteriors(coords); - return geomFact.createPolygon(shell, holes); - } - - protected LinearRing[] getInteriors(Coordinate[][] coords) - throws JsonException { - LinearRing[] rval = new LinearRing[coords.length - 1]; - for (int i = 1; i < coords.length; ++i) { - rval[i - 1] = getLinearRing(coords[i]); - } - return rval; - } - - protected LinearRing getLinearRing(Coordinate[] coords) - throws JsonException { - GeometryFactory geomFact = getGeomFact(); - return geomFact.createLinearRing(coords); - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - public MultiPoint populateMultiPoint(Map jsonObj) - throws JsonException { - GeometryFactory geomFact = getGeomFact(); - return geomFact.createMultiPoint(get2DArr(jsonObj)); - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - public MultiLineString populateMultiLineString(Map jsonObj) - throws JsonException { - Coordinate[][] coords = get3DArr(jsonObj); - GeometryFactory geomFact = getGeomFact(); - LineString[] lines = new LineString[coords.length]; - for (int i = 0; i < lines.length; ++i) { - Coordinate[] wrap = coords[i]; - lines[i] = geomFact.createLineString(wrap); - } - return geomFact.createMultiLineString(lines); - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - public MultiPolygon populateMultiPolygon(Map jsonObj) - throws JsonException { - Coordinate[][][] coords = get4DArr(jsonObj); - Polygon[] polys = new Polygon[coords.length]; - for (int i = 0; i < coords.length; ++i) { - polys[i] = getPolygon(coords[i]); - } - return getGeomFact().createMultiPolygon(polys); - } - - /** - * @param jsonObj - * @return - * @throws JsonException - */ - @SuppressWarnings("unchecked") - public GeometryCollection populateGeomCollection(Map jsonObj) - throws JsonException { - Object obj = jsonObj.get(GEOMS_KEY); - if (obj == null) { - throw new JsonException("Unable to find geometries in collection"); - } - if (!(obj instanceof List)) { - throw new JsonException("Expected List for geometries got: " - + obj.getClass()); - } - List geoms = (List) obj; - Geometry[] rval = new Geometry[geoms.size()]; - Iterator iterator = geoms.iterator(); - for (int i = 0; iterator.hasNext(); ++i) { - Object o = iterator.next(); - if (o instanceof Map) { - rval[i] = populateGeometry((Map) o); - } else { - throw new JsonException( - "Expected Map for each geometry, got " - + o.getClass()); - } - } - return getGeomFact().createGeometryCollection(rval); - } - - /** - * @param geom - * @return - * @throws JsonException - */ - public Map extractGeometryCollection(GeometryCollection coll) - throws JsonException { - Map rval = new LinkedHashMap(2); - int count = coll.getNumGeometries(); - Object[] geoms = new Object[count]; - for (int i = 0; i < count; ++i) { - Geometry geom = coll.getGeometryN(i); - geoms[i] = extract(geom); - } - rval.put(TYPE_KEY, GEOM_COLL_TYPE); - rval.put(GEOMS_KEY, geoms); - return rval; - } - - /** - * @param geom - * @return - */ - public Map extractMultiPolygon(MultiPolygon mpoly) { - Map rval = new LinkedHashMap(2); - int count = mpoly.getNumGeometries(); - double[][][][] coords = new double[count][][][]; - for (int i = 0; i < count; ++i) { - Polygon poly = (Polygon) mpoly.getGeometryN(i); - coords[i] = getPolyCoords(poly); - } - rval.put(TYPE_KEY, MULT_POLY_TYPE); - rval.put(COORD_KEY, coords); - return rval; - } - - /** - * @param geom - * @return - */ - public Map extractMultiLineString(MultiLineString mlineStr) { - Map rval = new LinkedHashMap(2); - int count = mlineStr.getNumGeometries(); - double[][][] coords = new double[count][][]; - for (int i = 0; i < count; ++i) { - LineString lineStr = (LineString) mlineStr.getGeometryN(i); - coords[i] = toArray(lineStr.getCoordinates()); - } - rval.put(TYPE_KEY, MULT_LINE_STR_TYPE); - rval.put(COORD_KEY, coords); - return rval; - } - - /** - * @param geom - * @return - */ - public Map extractMultiPoint(MultiPoint mpoint) { - Map rval = new LinkedHashMap(2); - int count = mpoint.getNumGeometries(); - double[][] coords = new double[count][]; - for (int i = 0; i < count; ++i) { - Point p = (Point) mpoint.getGeometryN(i); - coords[i] = toArray(p.getCoordinate()); - } - rval.put(TYPE_KEY, MULT_POINT_TYPE); - rval.put(COORD_KEY, coords); - return rval; - } - - /** - * @param geom - * @return - */ - public Map extractPolygon(Polygon poly) { - Map rval = new LinkedHashMap(2); - double[][][] coords = getPolyCoords(poly); - rval.put(TYPE_KEY, POLY_TYPE); - rval.put(COORD_KEY, coords); - return rval; - } - - protected double[][][] getPolyCoords(Polygon poly) { - LineString exterior = poly.getExteriorRing(); - int count = poly.getNumInteriorRing() + 1; - double[][][] coords = new double[count][][]; - coords[0] = toArray(exterior.getCoordinates()); - for (int i = 1; i < count; ++i) { - LineString interior = poly.getInteriorRingN(i - 1); - coords[i] = toArray(interior.getCoordinates()); - } - return coords; - } - - /** - * @param geom - * @return - */ - public Map extractLineString(LineString lineStr) { - Map rval = new LinkedHashMap(2); - double[][] coords = toArray(lineStr.getCoordinates()); - rval.put(TYPE_KEY, LINE_STR_TYPE); - rval.put(COORD_KEY, coords); - return rval; - } - - /** - * @param geom - * @return - */ - public Map extractPoint(Point point) { - Map rval = new LinkedHashMap(2); - double[] coords = toArray(point.getCoordinate()); - rval.put(TYPE_KEY, POINT_TYPE); - rval.put(COORD_KEY, coords); - return rval; - } - - protected double[] toArray(Coordinate c) { - if (!Double.isNaN(c.z)) { - return new double[] { c.x, c.y, c.z }; - } else { - return new double[] { c.x, c.y }; - } - } - - protected double[][] toArray(Coordinate[] coords) { - double[][] rval = new double[coords.length][]; - for (int i = 0; i < rval.length; ++i) { - rval[i] = toArray(coords[i]); - } - return rval; - } + public static final String LINE_STR_TYPE = "LineString"; + + public static final String POLY_TYPE = "Polygon"; + + public static final String MULT_POINT_TYPE = "Multi" + POINT_TYPE; + + public static final String MULT_LINE_STR_TYPE = "Multi" + LINE_STR_TYPE; + + public static final String MULT_POLY_TYPE = "Multi" + POLY_TYPE; + + public static final String GEOM_COLL_TYPE = "GeometryCollection"; + + public static final String FEATURE_TYPE = "Feature"; + + public static final String ID_KEY = "id"; + + public static final String FEATURE_COLL_TYPE = "FeatureCollection"; + + public static final String CRS_KEY = "crs"; + + public static final String NAME_KEY = "name"; + + public static final String LINK_KEY = "link"; + + public static final String HREF_KEY = "href"; + + public static final String BBOX_KEY = "bbox"; + + public static final String FEATURES_KEY = "features"; + + public static final String GEOMS_KEY = "geometries"; + + private GeometryFactory _geomFact; + + private Object _mutex = new Object(); + + protected GeometryFactory getGeomFact() { + if (_geomFact == null) { + synchronized (_mutex) { + // check again + if (_geomFact == null) { + _geomFact = new GeometryFactory(); + } + } + } + return _geomFact; + } + + public Map extract(Geometry geom) throws JsonException { + if (geom instanceof Point) { + return extractPoint((Point) geom); + } else if (geom instanceof LineString) { + return extractLineString((LineString) geom); + } else if (geom instanceof Polygon) { + return extractPolygon((Polygon) geom); + } else if (geom instanceof MultiPoint) { + return extractMultiPoint((MultiPoint) geom); + } else if (geom instanceof MultiLineString) { + return extractMultiLineString((MultiLineString) geom); + } else if (geom instanceof MultiPolygon) { + return extractMultiPolygon((MultiPolygon) geom); + } else if (geom instanceof GeometryCollection) { + return extractGeometryCollection((GeometryCollection) geom); + } else { + throw new JsonException("Unkown geometry type: " + geom.getClass()); + } + } + + public Geometry populateGeometry(Map jsonObj) + throws JsonException { + String type = (String) jsonObj.get(TYPE_KEY); + if (type == null) { + throw new JsonException("Unable to find type in json map"); + } + if (POINT_TYPE.equals(type)) { + return populatePoint(jsonObj); + } else if (LINE_STR_TYPE.equals(type)) { + return populateLineString(jsonObj); + } else if (POLY_TYPE.equals(type)) { + return populatePolygon(jsonObj); + } else if (MULT_POINT_TYPE.equals(type)) { + return populateMultiPoint(jsonObj); + } else if (MULT_LINE_STR_TYPE.equals(type)) { + return populateMultiLineString(jsonObj); + } else if (MULT_POLY_TYPE.equals(type)) { + return populateMultiPolygon(jsonObj); + } else if (GEOM_COLL_TYPE.equals(type)) { + return populateGeomCollection(jsonObj); + } else { + throw new JsonException("Unkown GeoJson geometry type: " + type); + } + } + + public Map extract(SimpleFeature feature) + throws JsonException { + return extract(feature, EnumSet.noneOf(FeatureOpt.class)); + } + + public Map extract(SimpleFeature feature, + EnumSet opts) throws JsonException { + Object geom = feature.getDefaultGeometry(); + Map rval = new LinkedHashMap(6); + rval.put(TYPE_KEY, FEATURE_TYPE); + SimpleFeatureType type = feature.getFeatureType(); + if (type == null) { + throw new JsonException("Feature type cannot be null"); + } + String id = feature.getID(); + if (id != null) { + rval.put(ID_KEY, id); + } + if (opts.contains(FeatureOpt.ENCODE_CRS)) { + CoordinateReferenceSystem crs = type.getCoordinateReferenceSystem(); + if (crs != null) { + rval.put(CRS_KEY, extract(crs)); + } + } + if (opts.contains(FeatureOpt.ENCODE_BOUNDS)) { + BoundingBox bounds = feature.getBounds(); + if (bounds != null) { + rval.put(BBOX_KEY, getBounds(bounds)); + } + } + int geomIndex = -1; + if (geom != null) { + rval.put(GEOM_KEY, extract((Geometry) geom)); + geomIndex = type.indexOf(feature.getDefaultGeometryProperty() + .getName()); + } + int count = type.getAttributeCount(); + Map props = new LinkedHashMap(count); + for (int i = 0; i < count; ++i) { + if (i == geomIndex) { + continue; + } + Object value = feature.getAttribute(i); + if (value == null) { + continue; + } + AttributeDescriptor desc = type.getDescriptor(i); + String name = desc.getLocalName(); + if (value instanceof Geometry) { + props.put(name, extract((Geometry) value)); + } else if (value instanceof Envelope) { + props.put(name, getEnv((Envelope) value)); + } else if (value instanceof BoundingBox) { + props.put(name, getBounds((BoundingBox) value)); + } else { + props.put(name, value); + } + } + rval.put(PROP_KEY, props); + return rval; + } + + public Map extract( + FeatureCollection coll) + throws JsonException { + return extract(coll, EnumSet.noneOf(FeatureOpt.class)); + } + + public Map extract( + FeatureCollection coll, + EnumSet opts) throws JsonException { + Map rval = new LinkedHashMap(4); + rval.put(TYPE_KEY, FEATURE_COLL_TYPE); + ReferencedEnvelope bounds = coll.getBounds(); + if (opts.contains(FeatureOpt.ENCODE_CRS) && (bounds != null) + && !bounds.isNull()) { + CoordinateReferenceSystem crs = bounds + .getCoordinateReferenceSystem(); + if (crs != null) { + rval.put(CRS_KEY, extract(crs)); + } + } + if (opts.contains(FeatureOpt.ENCODE_BOUNDS) && (bounds != null) + && !bounds.isNull()) { + rval.put(BBOX_KEY, getBounds(bounds)); + } + FeatureIterator iter = coll.features(); + Object[] features = new Object[coll.size()]; + for (int i = 0; iter.hasNext(); ++i) { + SimpleFeature feature = iter.next(); + features[i] = extract(feature, opts); + } + rval.put(FEATURES_KEY, features); + return rval; + } + + protected double[] getBounds(BoundingBox bbox) { + double minX = bbox.getMinX(); + double minY = bbox.getMinY(); + double maxX = bbox.getMaxX(); + double maxY = bbox.getMaxY(); + return new double[] { minX, minY, maxX, maxY }; + } + + protected double[] getEnv(Envelope bbox) { + double minX = bbox.getMinX(); + double minY = bbox.getMinY(); + double maxX = bbox.getMaxX(); + double maxY = bbox.getMaxY(); + return new double[] { minX, minY, maxX, maxY }; + } + + public Map extract(CoordinateReferenceSystem crs) + throws JsonException { + Map rval = new LinkedHashMap(2); + // TODO supported linked crs + rval.put(TYPE_KEY, NAME_KEY); + Map props = new LinkedHashMap(1); + try { + props.put(NAME_KEY, CRS.lookupIdentifier(crs, true)); + } catch (FactoryException e) { + throw new JsonException("Problem looking up CRS ID", e); + } + rval.put(PROP_KEY, props); + return rval; + } + + @SuppressWarnings("unchecked") + public FeatureCollection populateFeatureCollection( + Map jsonObj, SimpleFeatureType type) + throws JsonException { + Object obj = jsonObj.get(FEATURES_KEY); + if (obj == null) { + if (type == null) { + type = new SimpleFeatureTypeBuilder().buildFeatureType(); + } + return new EmptyFeatureCollection(type); + } + if (!(obj instanceof List)) { + throw new JsonException("Expected List for features, got " + + obj.getClass()); + } + List features = (List) obj; + List rval = new ArrayList(features.size()); + for (Object f : features) { + if (!(f instanceof Map)) { + throw new JsonException("Expected Map for feature got " + + f.getClass()); + } + Map fmap = (Map) f; + if (type == null) { + rval.add(populateFeature(fmap)); + } else { + rval.add(populateFeature(fmap, type)); + } + } + SimpleFeature sample = rval.get(0); + MemoryFeatureCollection coll = new MemoryFeatureCollection( + sample.getFeatureType()); + coll.addAll(rval); + return coll; + } + + protected FeatureCollection getCollection( + List features, SimpleFeatureType type) { + if (type != null) { + MemoryFeatureCollection coll = new MemoryFeatureCollection(type); + coll.addAll(features); + return coll; + } + Map> sorted = new HashMap>(); + + Iterator i = features.iterator(); + while (i.hasNext()) { + SimpleFeature next = i.next(); + List list = sorted.get(next.getFeatureType()); + if (list == null) { + list = new ArrayList(); + } + list.add(next); + } + if (sorted.size() == 1) { + SimpleFeatureType t = features.get(0).getFeatureType(); + MemoryFeatureCollection coll = new MemoryFeatureCollection(t); + coll.addAll(features); + return coll; + } else { + Set keySet = sorted.keySet(); + List colls = new ArrayList( + keySet.size()); + for (SimpleFeatureType key : keySet) { + MemoryFeatureCollection coll = new MemoryFeatureCollection(key); + coll.addAll(sorted.get(key)); + colls.add(coll); + } + return new MixedFeatureCollection(colls); + } + } + + public FeatureCollection populateFeatureCollection( + Map jsonObj) throws JsonException { + return populateFeatureCollection(jsonObj, null); + } + + public SimpleFeature populateFeature(Map jsonObj) + throws JsonException { + return populateFeature(jsonObj, "the_geom", "feature"); + } + + public SimpleFeature populateFeature(Map jsonObj, + SimpleFeatureType type) throws JsonException { + String id = (String) jsonObj.get(ID_KEY); + Geometry geom = getFeatureGeom(jsonObj); + SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); + if (geom != null) { + GeometryDescriptor geomDesc = type.getGeometryDescriptor(); + Name geomName = geomDesc.getName(); + builder.set(geomName, geom); + } + Map props = getProps(jsonObj.get(PROP_KEY)); + for (AttributeDescriptor desc : type.getAttributeDescriptors()) { + String name = desc.getLocalName(); + Object value = props.get(name); + if (value != null) { + builder.set(name, value); + } + } + return builder.buildFeature(id); + } + + @SuppressWarnings("unchecked") + protected Geometry getFeatureGeom(Map jsonObj) + throws JsonException { + Object obj = jsonObj.get(GEOM_KEY); + Geometry geom = null; + if (obj != null) { + if (obj instanceof Map) { + geom = populateGeometry((Map) obj); + } else { + throw new JsonException("Unexpected type for geometry: " + + obj.getClass()); + } + } + return geom; + } + + @SuppressWarnings("unchecked") + public SimpleFeature populateFeature(Map jsonObj, + String geomName, String featureName) throws JsonException { + String id = (String) jsonObj.get(ID_KEY); + SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); + typeBuilder.setName(featureName); + Geometry geom = getFeatureGeom(jsonObj); + if (geom != null) { + typeBuilder.setDefaultGeometry(geomName); + typeBuilder.add(geomName, geom.getClass()); + } + Object crsObj = jsonObj.get(CRS_KEY); + CoordinateReferenceSystem crs = null; + if (crsObj != null) { + if (crsObj instanceof Map) { + crs = populateCrs((Map) crsObj); + typeBuilder.setCRS(crs); + } else { + throw new JsonException( + "Expected Map for CRS got" + + crsObj.getClass()); + } + } + List values = new ArrayList(0); + Object propObj = jsonObj.get(PROP_KEY); + if (propObj != null) { + Map props = getProps(propObj); + Set keySet = props.keySet(); + values = new ArrayList(keySet.size()); + for (String key : keySet) { + Object val = props.get(key); + typeBuilder.add(key, val.getClass()); + values.add(val); + } + } + SimpleFeatureType type = typeBuilder.buildFeatureType(); + SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type); + if (geom != null) { + featureBuilder.add(geom); + } + featureBuilder.addAll(values); + return featureBuilder.buildFeature(id); + } + + @SuppressWarnings("unchecked") + protected Map getProps(Object propObj) throws JsonException { + if (!(propObj instanceof Map)) { + throw new JsonException( + "Expected Map for properties got " + + propObj.getClass()); + } + return (Map) propObj; + } + + public CoordinateReferenceSystem populateCrs(Map jsonObj) + throws JsonException { + String type = (String) jsonObj.get(TYPE_KEY); + if (!NAME_KEY.equals(type)) { + // TODO handle link crs + throw new JsonException("Only named CRS supported"); + } + Object propObj = jsonObj.get(PROP_KEY); + if (propObj == null) { + throw new JsonException("Properties required for CRS"); + } + Map props = getProps(propObj); + String name = (String) props.get(NAME_KEY); + try { + return CRS.decode(name); + } catch (Exception e) { + throw new JsonException("Unable to decode namded CRS", e); + } + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + public Point populatePoint(Map jsonObj) + throws JsonException { + Coordinate c = getCoord(jsonObj); + return getGeomFact().createPoint(c); + } + + protected Coordinate getSingleCoordinate(double[] c) throws JsonException { + Coordinate coord; + if (c.length == 3) { + coord = new Coordinate(c[0], c[1], c[2]); + } else if (c.length == 2) { + coord = new Coordinate(c[0], c[1]); + } else { + throw new JsonException("Unsupported coordinate dimention: " + + c.length); + } + return coord; + } + + protected Coordinate getSingleCoordinate(List l) throws JsonException { + Coordinate coord; + double x = (Double) l.get(0); + double y = (Double) l.get(1); + if (l.size() == 3) { + double z = (Double) l.get(2); + coord = new Coordinate(x, y, z); + } else if (l.size() == 2) { + coord = new Coordinate(x, y); + } else { + throw new JsonException("Unsupported coordinate dimention: " + + l.size()); + } + return coord; + } + + protected Coordinate getCoord(Map jsonObj) + throws JsonException { + Object obj = jsonObj.get(COORD_KEY); + if (obj == null) { + throw new JsonException("Unable to find coordinate array"); + } + if (obj instanceof List) { + return getSingleCoordinate((List) obj); + } else if (obj instanceof double[]) { + return getSingleCoordinate((double[]) obj); + } else { + throw new JsonException("Unexpected value for coordinates: " + + obj.getClass()); + } + } + + protected Coordinate[] get2DArr(Map jsonObj) + throws JsonException { + Object obj = jsonObj.get(COORD_KEY); + if (obj == null) { + throw new JsonException("Unable to find coordinate array"); + } + if (obj instanceof List) { + return wrap2D((List) obj); + } else if (obj instanceof double[][]) { + return wrap((double[][]) obj); + } else { + throw new JsonException("Unexpected value for coordinates: " + + obj.getClass()); + } + } + + protected Coordinate[][] get3DArr(Map jsonObj) + throws JsonException { + Object obj = jsonObj.get(COORD_KEY); + if (obj == null) { + throw new JsonException("Unable to find coordinate array"); + } + if (obj instanceof List) { + List list = (List) obj; + return wrap3D(list); + } else if (obj instanceof double[][][]) { + double[][][] arr = (double[][][]) obj; + Coordinate[][] rval = new Coordinate[arr.length][]; + for (int i = 0; i < arr.length; ++i) { + rval[i] = wrap(arr[i]); + } + return rval; + } else { + throw new JsonException("Unexpected value for coordinates: " + + obj.getClass()); + } + } + + protected Coordinate[][] wrap3D(List list) throws JsonException { + Coordinate[][] rval = new Coordinate[list.size()][]; + Iterator iterator = list.iterator(); + for (int i = 0; iterator.hasNext(); ++i) { + List next = (List) iterator.next(); + rval[i] = wrap2D(next); + } + return rval; + } + + protected Coordinate[][][] get4DArr(Map jsonObj) + throws JsonException { + Object obj = jsonObj.get(COORD_KEY); + if (obj == null) { + throw new JsonException("Unable to find coordinate array"); + } + if (obj instanceof List) { + List list = (List) obj; + Coordinate[][][] rval = new Coordinate[list.size()][][]; + Iterator iterator = list.iterator(); + for (int i = 0; iterator.hasNext(); ++i) { + List next = (List) iterator.next(); + rval[i] = wrap3D(next); + } + return rval; + } else { + throw new JsonException("Unexpected value for coordinates: " + + obj.getClass()); + } + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + public LineString populateLineString(Map jsonObj) + throws JsonException { + GeometryFactory geomFact = getGeomFact(); + Coordinate[] coordinates = get2DArr(jsonObj); + return geomFact.createLineString(coordinates); + } + + protected Coordinate[] wrap2D(List coords) throws JsonException { + int count = coords.size(); + Coordinate[] rval = new Coordinate[count]; + Iterator iterator = coords.iterator(); + for (int i = 0; iterator.hasNext(); ++i) { + List inner = (List) iterator.next(); + + rval[i] = getSingleCoordinate(inner); + } + return rval; + } + + protected Coordinate[] wrap(double[][] coords) throws JsonException { + int count = coords.length; + Coordinate[] rval = new Coordinate[count]; + for (int i = 0; i < count; ++i) { + rval[i] = getSingleCoordinate(coords[i]); + } + return rval; + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + public Geometry populatePolygon(Map jsonObj) + throws JsonException { + Coordinate[][] coords = get3DArr(jsonObj); + return getPolygon(coords); + } + + protected Polygon getPolygon(Coordinate[][] coords) throws JsonException { + GeometryFactory geomFact = getGeomFact(); + LinearRing shell = getLinearRing(coords[0]); + LinearRing[] holes = getInteriors(coords); + return geomFact.createPolygon(shell, holes); + } + + protected LinearRing[] getInteriors(Coordinate[][] coords) + throws JsonException { + LinearRing[] rval = new LinearRing[coords.length - 1]; + for (int i = 1; i < coords.length; ++i) { + rval[i - 1] = getLinearRing(coords[i]); + } + return rval; + } + + protected LinearRing getLinearRing(Coordinate[] coords) + throws JsonException { + GeometryFactory geomFact = getGeomFact(); + return geomFact.createLinearRing(coords); + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + public MultiPoint populateMultiPoint(Map jsonObj) + throws JsonException { + GeometryFactory geomFact = getGeomFact(); + return geomFact.createMultiPoint(get2DArr(jsonObj)); + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + public MultiLineString populateMultiLineString(Map jsonObj) + throws JsonException { + Coordinate[][] coords = get3DArr(jsonObj); + GeometryFactory geomFact = getGeomFact(); + LineString[] lines = new LineString[coords.length]; + for (int i = 0; i < lines.length; ++i) { + Coordinate[] wrap = coords[i]; + lines[i] = geomFact.createLineString(wrap); + } + return geomFact.createMultiLineString(lines); + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + public MultiPolygon populateMultiPolygon(Map jsonObj) + throws JsonException { + Coordinate[][][] coords = get4DArr(jsonObj); + Polygon[] polys = new Polygon[coords.length]; + for (int i = 0; i < coords.length; ++i) { + polys[i] = getPolygon(coords[i]); + } + return getGeomFact().createMultiPolygon(polys); + } + + /** + * @param jsonObj + * @return + * @throws JsonException + */ + @SuppressWarnings("unchecked") + public GeometryCollection populateGeomCollection(Map jsonObj) + throws JsonException { + Object obj = jsonObj.get(GEOMS_KEY); + if (obj == null) { + throw new JsonException("Unable to find geometries in collection"); + } + if (!(obj instanceof List)) { + throw new JsonException("Expected List for geometries got: " + + obj.getClass()); + } + List geoms = (List) obj; + Geometry[] rval = new Geometry[geoms.size()]; + Iterator iterator = geoms.iterator(); + for (int i = 0; iterator.hasNext(); ++i) { + Object o = iterator.next(); + if (o instanceof Map) { + rval[i] = populateGeometry((Map) o); + } else { + throw new JsonException( + "Expected Map for each geometry, got " + + o.getClass()); + } + } + return getGeomFact().createGeometryCollection(rval); + } + + /** + * @param geom + * @return + * @throws JsonException + */ + public Map extractGeometryCollection(GeometryCollection coll) + throws JsonException { + Map rval = new LinkedHashMap(2); + int count = coll.getNumGeometries(); + Object[] geoms = new Object[count]; + for (int i = 0; i < count; ++i) { + Geometry geom = coll.getGeometryN(i); + geoms[i] = extract(geom); + } + rval.put(TYPE_KEY, GEOM_COLL_TYPE); + rval.put(GEOMS_KEY, geoms); + return rval; + } + + /** + * @param geom + * @return + */ + public Map extractMultiPolygon(MultiPolygon mpoly) { + Map rval = new LinkedHashMap(2); + int count = mpoly.getNumGeometries(); + double[][][][] coords = new double[count][][][]; + for (int i = 0; i < count; ++i) { + Polygon poly = (Polygon) mpoly.getGeometryN(i); + coords[i] = getPolyCoords(poly); + } + rval.put(TYPE_KEY, MULT_POLY_TYPE); + rval.put(COORD_KEY, coords); + return rval; + } + + /** + * @param geom + * @return + */ + public Map extractMultiLineString(MultiLineString mlineStr) { + Map rval = new LinkedHashMap(2); + int count = mlineStr.getNumGeometries(); + double[][][] coords = new double[count][][]; + for (int i = 0; i < count; ++i) { + LineString lineStr = (LineString) mlineStr.getGeometryN(i); + coords[i] = toArray(lineStr.getCoordinates()); + } + rval.put(TYPE_KEY, MULT_LINE_STR_TYPE); + rval.put(COORD_KEY, coords); + return rval; + } + + /** + * @param geom + * @return + */ + public Map extractMultiPoint(MultiPoint mpoint) { + Map rval = new LinkedHashMap(2); + int count = mpoint.getNumGeometries(); + double[][] coords = new double[count][]; + for (int i = 0; i < count; ++i) { + Point p = (Point) mpoint.getGeometryN(i); + coords[i] = toArray(p.getCoordinate()); + } + rval.put(TYPE_KEY, MULT_POINT_TYPE); + rval.put(COORD_KEY, coords); + return rval; + } + + /** + * @param geom + * @return + */ + public Map extractPolygon(Polygon poly) { + Map rval = new LinkedHashMap(2); + double[][][] coords = getPolyCoords(poly); + rval.put(TYPE_KEY, POLY_TYPE); + rval.put(COORD_KEY, coords); + return rval; + } + + protected double[][][] getPolyCoords(Polygon poly) { + LineString exterior = poly.getExteriorRing(); + int count = poly.getNumInteriorRing() + 1; + double[][][] coords = new double[count][][]; + coords[0] = toArray(exterior.getCoordinates()); + for (int i = 1; i < count; ++i) { + LineString interior = poly.getInteriorRingN(i - 1); + coords[i] = toArray(interior.getCoordinates()); + } + return coords; + } + + /** + * @param geom + * @return + */ + public Map extractLineString(LineString lineStr) { + Map rval = new LinkedHashMap(2); + double[][] coords = toArray(lineStr.getCoordinates()); + rval.put(TYPE_KEY, LINE_STR_TYPE); + rval.put(COORD_KEY, coords); + return rval; + } + + /** + * @param geom + * @return + */ + public Map extractPoint(Point point) { + Map rval = new LinkedHashMap(2); + double[] coords = toArray(point.getCoordinate()); + rval.put(TYPE_KEY, POINT_TYPE); + rval.put(COORD_KEY, coords); + return rval; + } + + protected double[] toArray(Coordinate c) { + if (!Double.isNaN(c.z)) { + return new double[] { c.x, c.y, c.z }; + } else { + return new double[] { c.x, c.y }; + } + } + + protected double[][] toArray(Coordinate[] coords) { + double[][] rval = new double[coords.length][]; + for (int i = 0; i < rval.length; ++i) { + rval[i] = toArray(coords[i]); + } + return rval; + } } diff --git a/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/MixedFeatureCollection.java b/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/MixedFeatureCollection.java index 6e04c2cdf1..d4e7c51b90 100644 --- a/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/MixedFeatureCollection.java +++ b/edexOsgi/com.raytheon.uf.common.json/src/com/raytheon/uf/common/json/geo/MixedFeatureCollection.java @@ -6,138 +6,155 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import org.geotools.data.memory.MemoryFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; import org.geotools.data.store.DataFeatureCollection; -import org.geotools.feature.FeatureCollection; import org.geotools.geometry.jts.ReferencedEnvelope; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.geometry.BoundingBox; +/** + * Mixed Feature Collection + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug  9, 2011            bclement    Initial creation
+ * Mar 11, 2014      #2718 randerso    Changes for GeoTools 10.5
+ * 
+ * 
+ * + * @author bclement + * @version 1.0 + */ public class MixedFeatureCollection extends DataFeatureCollection { - protected List> colls; + protected List colls; - public MixedFeatureCollection( - List> colls) { - this.colls = colls; - } + public MixedFeatureCollection(List colls) { + this.colls = colls; + } - @Override - protected Iterator openIterator() throws IOException { - return new MixedIterator(); - } + @Override + protected Iterator openIterator() throws IOException { + return new MixedIterator(); + } - @SuppressWarnings({ "rawtypes" }) - @Override - public boolean removeAll(Collection arg0) { - Iterator> i = colls - .iterator(); - boolean rval = false; - while (i.hasNext()) { - rval = rval || i.next().removeAll(arg0); - } - return rval; - } + @SuppressWarnings({ "rawtypes" }) + @Override + public boolean removeAll(Collection arg0) { + Iterator i = colls.iterator(); + boolean rval = false; + while (i.hasNext()) { + rval = rval || i.next().removeAll(arg0); + } + return rval; + } - @SuppressWarnings("rawtypes") - @Override - public boolean retainAll(Collection arg0) { - Iterator> i = colls - .iterator(); - boolean rval = false; - while (i.hasNext()) { - rval = rval || i.next().retainAll(arg0); - } - return rval; - } + @SuppressWarnings("rawtypes") + @Override + public boolean retainAll(Collection arg0) { + Iterator i = colls.iterator(); + boolean rval = false; + while (i.hasNext()) { + rval = rval || i.next().retainAll(arg0); + } + return rval; + } - @Override - public Object[] toArray(Object[] array) { - List rval = new ArrayList(); - Iterator i = this.iterator(); - while (i.hasNext()) { - rval.add(i.next()); - } - return rval.toArray(array); - } + @Override + public Object[] toArray(Object[] array) { + List rval = new ArrayList(); + Iterator i = this.iterator(); + while (i.hasNext()) { + rval.add(i.next()); + } + return rval.toArray(array); + } - public SimpleFeatureType getSchema() { - return null; - } + @Override + public SimpleFeatureType getSchema() { + return null; + } - class MixedIterator implements Iterator { + class MixedIterator implements Iterator { - protected int curr = 0; - protected Iterator iter; + protected int curr = 0; - @Override - public boolean hasNext() { - if ((iter != null) && iter.hasNext()) { - return true; - } - while (curr < colls.size()) { - if (iter != null) { - colls.get(curr - 1).close(iter); - } - iter = colls.get(curr++).iterator(); - if (iter.hasNext()) { - return true; - } - } + protected SimpleFeatureIterator iter; - if (iter != null) { - colls.get(colls.size() - 1).close(iter); - } - return false; - } + @Override + public boolean hasNext() { + if ((iter != null) && iter.hasNext()) { + return true; + } + while (curr < colls.size()) { + if (iter != null) { + iter.close(); + } + iter = colls.get(curr++).features(); + if (iter.hasNext()) { + return true; + } + } - @Override - public SimpleFeature next() { - return iter.next(); - } + if (iter != null) { + iter.close(); + } + return false; + } - @Override - public void remove() { - // TODO Auto-generated method stub + @Override + public SimpleFeature next() { + return iter.next(); + } - } + @Override + public void remove() { + // TODO Auto-generated method stub - } + } - @Override - public ReferencedEnvelope getBounds() { - Iterator iterator = iterator(); - ReferencedEnvelope rval = null; - if (iterator.hasNext()) { - SimpleFeature sf = iterator.next(); - BoundingBox bbox = sf.getBounds(); - rval = new ReferencedEnvelope(bbox); - } - while (iterator.hasNext()) { - SimpleFeature sf = iterator.next(); - BoundingBox bbox = sf.getBounds(); - rval.expandToInclude(new ReferencedEnvelope(bbox)); - } - if (rval == null) { - rval = new ReferencedEnvelope(); - } - return rval; - } + } - @Override - public int getCount() throws IOException { - int count = 0; - Iterator iterator = iterator(); - try { - while (iterator.hasNext()) { - iterator.next(); - count++; - } - } finally { - close(iterator); - } + @Override + public ReferencedEnvelope getBounds() { + Iterator iterator = iterator(); + ReferencedEnvelope rval = null; + if (iterator.hasNext()) { + SimpleFeature sf = iterator.next(); + BoundingBox bbox = sf.getBounds(); + rval = new ReferencedEnvelope(bbox); + } + while (iterator.hasNext()) { + SimpleFeature sf = iterator.next(); + BoundingBox bbox = sf.getBounds(); + rval.expandToInclude(new ReferencedEnvelope(bbox)); + } + if (rval == null) { + rval = new ReferencedEnvelope(); + } + return rval; + } - return count; - } + @Override + public int getCount() throws IOException { + int count = 0; + Iterator iterator = iterator(); + try { + while (iterator.hasNext()) { + iterator.next(); + count++; + } + } finally { + close(iterator); + } + + return count; + } } 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 index 2eda8b9393..0edf65e4d7 100644 --- 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 @@ -25,7 +25,6 @@ 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; @@ -36,7 +35,6 @@ 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; - /** * Converts simple features to GeoJSON * @@ -46,7 +44,8 @@ import com.raytheon.uf.edex.ogc.common.OgcResponse.TYPE; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Aug 9, 2011 bclement Initial creation + * Aug 9, 2011 bclement Initial creation + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -57,7 +56,7 @@ public class JsonFeatureFormatter implements SimpleFeatureFormatter { public static MimeType mimeType = new MimeType("application/json"); - protected GeoJsonUtil jsonUtil = new GeoJsonUtilSimpleImpl(); + protected GeoJsonUtil jsonUtil = new GeoJsonUtilSimpleImpl(); /* * (non-Javadoc) @@ -80,20 +79,20 @@ public class JsonFeatureFormatter implements SimpleFeatureFormatter { * com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#format(java.util * .List) */ - @Override - public OgcResponse format(List> features) - throws Exception { + @Override + public OgcResponse format(List> features) + throws Exception { MixedFeatureCollection mixed = convert(features); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - jsonUtil.serialize(mixed, baos); - return new OgcResponse(baos.toString(), mimeType, TYPE.TEXT); - } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + jsonUtil.serialize(mixed, baos); + return new OgcResponse(baos.toString(), mimeType, TYPE.TEXT); + } protected MixedFeatureCollection convert(List> features) { - List> colls = new ArrayList>( + List colls = new ArrayList( features.size()); for (List l : features) { - if (l != null && !l.isEmpty()) { + if ((l != null) && !l.isEmpty()) { SimpleFeatureType t = l.get(0).getFeatureType(); MemoryFeatureCollection c = new MemoryFeatureCollection(t); c.addAll(l); @@ -103,26 +102,26 @@ public class JsonFeatureFormatter implements SimpleFeatureFormatter { return new MixedFeatureCollection(colls); } - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#getMimeType() - */ - @Override + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.edex.wms.format.SimpleFeatureFormatter#getMimeType() + */ + @Override public MimeType getMimeType() { - return mimeType; - } + return mimeType; + } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter#matchesFormat - * (java.lang.String) - */ - @Override + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.ogc.common.feature.SimpleFeatureFormatter#matchesFormat + * (java.lang.String) + */ + @Override public boolean matchesFormat(MimeType format) { return mimeType.equalsIgnoreParams(format); - } + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/sigmet/SigmetInfo.java b/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/sigmet/SigmetInfo.java index 3f33feaead..2d819c03f6 100644 --- a/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/sigmet/SigmetInfo.java +++ b/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/sigmet/SigmetInfo.java @@ -24,8 +24,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.geotools.data.DefaultQuery; -import org.geotools.data.shapefile.indexed.IndexedShapefileDataStore; +import org.geotools.data.Query; +import org.geotools.data.shapefile.ShapefileDataStore; import org.geotools.feature.FeatureIterator; import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.datum.DefaultEllipsoid; @@ -60,6 +60,7 @@ import com.vividsolutions.jts.geom.Polygon; * 02/2012 #597 S. Gurung Moved snap functionalities to SnapUtil. Removed GUI snapping for Non ConvSigmet. * 02/2012 S. Gurung Moved back isSnapADC() and getNumOfCompassPts() to SigmetInfo from SnapUtil * 11/12 #893 J. Wu TTR635 - Fix volcano in alphabetical breakdown order. + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @author gzhang @@ -535,13 +536,13 @@ public class SigmetInfo { FeatureIterator featureIterator = null; HashMap firGeoMap = new HashMap(); - IndexedShapefileDataStore shapefileDataStore=null; + ShapefileDataStore shapefileDataStore=null; String shapeField=null; try{ File file = PgenStaticDataProvider.getProvider().getFirBoundsFile(); - shapefileDataStore = new IndexedShapefileDataStore(file.toURI() - .toURL(), null, false, true, org.geotools.data.shapefile.indexed.IndexType.QIX); + shapefileDataStore = new ShapefileDataStore(file.toURI() + .toURL()); shapeField = shapefileDataStore.getFeatureSource().getSchema().getGeometryDescriptor().getLocalName(); }catch(Exception e){ @@ -553,7 +554,7 @@ public class SigmetInfo { try { String[] types = shapefileDataStore.getTypeNames(); - DefaultQuery query = new DefaultQuery(); + Query query = new Query(); query.setTypeName(types[0]); String[] fields = new String[labelFields.length+1]; diff --git a/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/tools/PgenWatchBoxAddDelCntyHandler.java b/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/tools/PgenWatchBoxAddDelCntyHandler.java index 84f51f2461..f251197584 100644 --- a/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/tools/PgenWatchBoxAddDelCntyHandler.java +++ b/ncep/gov.noaa.nws.ncep.ui.pgen/src/gov/noaa/nws/ncep/ui/pgen/tools/PgenWatchBoxAddDelCntyHandler.java @@ -16,11 +16,11 @@ import gov.noaa.nws.ncep.ui.pgen.rsc.PgenResource; import java.util.List; +import org.geotools.data.simple.SimpleFeatureCollection; +import org.geotools.data.simple.SimpleFeatureIterator; import org.geotools.factory.CommonFactoryFinder; import org.geotools.factory.GeoTools; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureCollections; -import org.geotools.feature.FeatureIterator; +import org.geotools.feature.DefaultFeatureCollection; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; import org.geotools.referencing.crs.DefaultGeographicCRS; @@ -45,6 +45,7 @@ import com.vividsolutions.jts.geom.Point; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 12/09 #159 B. Yin Initial Creation. + * Mar 11, 2014 #2718 randerso Changes for GeoTools 10.5 * * * @@ -60,7 +61,7 @@ public class PgenWatchBoxAddDelCntyHandler extends InputHandlerDefaultImpl { //feature collection used to find which county a location is in - static FeatureCollection counties; + static DefaultFeatureCollection counties; /** * Public constructor @@ -105,9 +106,9 @@ public class PgenWatchBoxAddDelCntyHandler extends InputHandlerDefaultImpl { Point click = gf.createPoint(loc); //apply filter - FeatureCollection fc = counties.subCollection(createFilter(click)); + SimpleFeatureCollection fc = counties.subCollection(createFilter(click)); - FeatureIterator featureIterator = fc.features(); + SimpleFeatureIterator featureIterator = fc.features(); //find the ID of the county the location is inside of String ugc = null; @@ -121,6 +122,7 @@ public class PgenWatchBoxAddDelCntyHandler extends InputHandlerDefaultImpl { break; } } + featureIterator.close(); boolean gotCnty = false; SPCCounty county = null; @@ -221,7 +223,7 @@ public class PgenWatchBoxAddDelCntyHandler extends InputHandlerDefaultImpl { */ private void createCountyFeatureCollection(){ - counties = FeatureCollections.newCollection(); + counties = new DefaultFeatureCollection(); // create simple feature type SimpleFeatureTypeBuilder builder2 = new SimpleFeatureTypeBuilder(); diff --git a/tests/unit/com/raytheon/uf/common/datadelivery/registry/ebxml/DataSetWithFiltersQueryTest.java b/tests/unit/com/raytheon/uf/common/datadelivery/registry/ebxml/DataSetWithFiltersQueryTest.java index ae32324151..c05b92b8f2 100644 --- a/tests/unit/com/raytheon/uf/common/datadelivery/registry/ebxml/DataSetWithFiltersQueryTest.java +++ b/tests/unit/com/raytheon/uf/common/datadelivery/registry/ebxml/DataSetWithFiltersQueryTest.java @@ -29,11 +29,11 @@ import org.geotools.geometry.jts.ReferencedEnvelope; import org.junit.Test; import com.raytheon.uf.common.datadelivery.registry.DataLevelType; +import com.raytheon.uf.common.datadelivery.registry.DataLevelType.LevelType; import com.raytheon.uf.common.datadelivery.registry.DataSet; +import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage; import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSet; import com.raytheon.uf.common.datadelivery.registry.Parameter; -import com.raytheon.uf.common.datadelivery.registry.DataLevelType.LevelType; -import com.raytheon.uf.common.datadelivery.registry.GriddedCoverage; import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.gridcoverage.Corner; import com.raytheon.uf.common.gridcoverage.LatLonGridCoverage; @@ -56,6 +56,7 @@ import com.vividsolutions.jts.geom.Envelope; * Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects. * Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes. * Jan 02, 2012 1345 djohnson Fix broken code from referenced envelope switch. + * Mar 11, 2014 2718 randerso Changes for GeoTools 10.5 * * * @@ -75,7 +76,7 @@ public class DataSetWithFiltersQueryTest { @Test public void testSatisfiesFilterCriteriaReturnsTrueWhenOnlySatisfiableLevelsSpecified() { DataLevelType dataLevelType = new DataLevelType(LevelType.SFC); - + Parameter parameter = new Parameter(); parameter.setLevelType(java.util.Arrays.asList(dataLevelType)); @@ -131,8 +132,8 @@ public class DataSetWithFiltersQueryTest { dataSet.setCoverage(coverage); // Choose a smaller bounding box inside the dataset's - ReferencedEnvelope selectedAreaCoordinates = new ReferencedEnvelope( - MapUtil.LATLON_PROJECTION); + ReferencedEnvelope selectedAreaCoordinates = ReferencedEnvelope + .create(MapUtil.LATLON_PROJECTION); final Coordinate upperLeft = coverage.getUpperLeft(); final Coordinate lowerRight = coverage.getLowerRight(); selectedAreaCoordinates.expandToInclude(upperLeft.x + 1, @@ -169,7 +170,7 @@ public class DataSetWithFiltersQueryTest { // Choose a bounding box lying outside of the dataset's ReferencedEnvelope selectedAreaCoordinates = new ReferencedEnvelope( new Envelope(new Coordinate(-15, -14), new Coordinate(-14, -13)), - MapUtil.LATLON_PROJECTION); + MapUtil.LATLON_PROJECTION); assertFalse( "Should return false when unsatisfiable area is specified!",