From b28f945bc150c98a8547315ffb928d5ee430c462 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Thu, 6 Feb 2014 13:36:30 -0600 Subject: [PATCH] Issue #2672 Handle envelopes in data access requests of points and lightning. Change-Id: Id9a56e9f8027a2f489561c241e2f34dd92dce400 Former-commit-id: cd772d89613e385df812636899bd8ec0fe3d9b5e [formerly 25ad0e327c53f94ebe99d5d7203d216bb6da874d] [formerly ec8514000fd5a188031ce6ca44daf1bcd2265ed5 [formerly efe32c8302834b1c53a5f65850aff8f12437d3bb]] Former-commit-id: ec8514000fd5a188031ce6ca44daf1bcd2265ed5 Former-commit-id: 19cb907ac827c5c085211a974d5606fb33b771da --- .../dataaccess/BinLightingAccessFactory.java | 24 +++++++++--- .../dataaccess/PointDataAccessFactory.java | 38 ++++++++++++++++++- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.binlightning/src/com/raytheon/uf/common/dataplugin/binlightning/dataaccess/BinLightingAccessFactory.java b/edexOsgi/com.raytheon.uf.common.dataplugin.binlightning/src/com/raytheon/uf/common/dataplugin/binlightning/dataaccess/BinLightingAccessFactory.java index 18acffaa66..967132cd90 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.binlightning/src/com/raytheon/uf/common/dataplugin/binlightning/dataaccess/BinLightingAccessFactory.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.binlightning/src/com/raytheon/uf/common/dataplugin/binlightning/dataaccess/BinLightingAccessFactory.java @@ -52,18 +52,24 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.time.DataTime; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.GeometryFactory; /** * Data access framework factory for bin lightning * + * Envelopes requests cannot be handled efficiently using metadata so all data + * is retrieved and filtered within the factory. For very large requests this + * may result in suboptimal performance. + * *
  * 
  * SOFTWARE HISTORY
  * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jan 21, 2014 2667       bclement     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Jan 21, 2014  2667     bclement    Initial creation
+ * Feb 06, 2014  2672     bsteffen    Add envelope support
  * 
  * 
* @@ -165,7 +171,7 @@ public class BinLightingAccessFactory extends AbstractDataPluginFactory { for (Entry> groupEntry : srcDatasets .entrySet()) { addGeometryData(rval, ds, groupEntry.getKey(), - groupEntry.getValue()); + groupEntry.getValue(), request.getEnvelope()); } } return rval.toArray(new IGeometryData[rval.size()]); @@ -183,9 +189,11 @@ public class BinLightingAccessFactory extends AbstractDataPluginFactory { * lightning source value from metadata * @param datasets * requested datasets from datastore + * @param envelope + * envelope to use for geospatial filtering */ private void addGeometryData(List dataList, IDataStore ds, - String source, List datasets) { + String source, List datasets, Envelope envelope) { // Go fetch data try { IDataRecord[] records = ds.retrieveDatasets( @@ -219,6 +227,12 @@ public class BinLightingAccessFactory extends AbstractDataPluginFactory { .getFloatData(); for (int i = 0; i < timeData.length; i++) { + if (envelope != null + && !envelope.contains(longitudeData[i], + latitudeData[i])) { + /* Skip any data the user doesn't want */ + continue; + } DataTime dt = new DataTime(new Date(timeData[i])); DefaultGeometryData data = new DefaultGeometryData(); data.setDataTime(dt); diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/dataaccess/PointDataAccessFactory.java b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/dataaccess/PointDataAccessFactory.java index 5c6ad382e0..e85a4fa40f 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/dataaccess/PointDataAccessFactory.java +++ b/edexOsgi/com.raytheon.uf.common.pointdata/src/com/raytheon/uf/common/pointdata/dataaccess/PointDataAccessFactory.java @@ -53,6 +53,7 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.TimeRange; import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.GeometryFactory; /** @@ -66,7 +67,9 @@ import com.vividsolutions.jts.geom.GeometryFactory; * ------------- -------- ----------- -------------------------- * Oct 31, 2013 2502 bsteffen Initial creation * Nov 26, 2013 2537 bsteffen Minor code cleanup. - * Jan,14, 2014 2667 mnash Remove getGridData method + * Jan,14, 2014 2667 mnash Remove getGridData method + * Feb 06, 2014 2672 bsteffen Add envelope support + * * * * @author bsteffen @@ -99,8 +102,12 @@ public class PointDataAccessFactory extends AbstractDataPluginFactory { private String locationPointDataKey = PointDataConstants.DATASET_STATIONID; + private String latitudeDatabaseKey = "location.latitude"; + private String latitudePointDataKey = "latitude"; + private String longitudeDatabaseKey = "location.longitude"; + private String longitudePointDataKey = "longitude"; private String refTimePointDataKey = PointDataConstants.DATASET_REFTIME; @@ -157,6 +164,17 @@ public class PointDataAccessFactory extends AbstractDataPluginFactory { .getValue().toString())); } } + Envelope envelope = request.getEnvelope(); + if (envelope != null) { + String minLon = Double.toString(envelope.getMinX()); + String maxLon = Double.toString(envelope.getMaxX()); + rcMap.put(longitudeDatabaseKey, new RequestConstraint(minLon, + maxLon)); + String minLat = Double.toString(envelope.getMinY()); + String maxLat = Double.toString(envelope.getMaxY()); + rcMap.put(latitudeDatabaseKey, + new RequestConstraint(minLat, maxLat)); + } return rcMap; } @@ -425,6 +443,24 @@ public class PointDataAccessFactory extends AbstractDataPluginFactory { this.longitudePointDataKey = longitudePointDataKey; } + /** + * @param latitudeDatabaseKey + * The hibernate field name of the field that is used to identify + * latitude. Default values is "location.latitude" + */ + public void setLatitudeDatabaseKey(String latitudeDatabaseKey) { + this.latitudeDatabaseKey = latitudeDatabaseKey; + } + + /** + * @param longitudeDatabaseKey + * The hibernate field name of the field that is used to identify + * longitude. Default values is "location.longitude" + */ + public void setLongitudeDatabaseKey(String longitudeDatabaseKey) { + this.longitudeDatabaseKey = longitudeDatabaseKey; + } + /** * @param refTimePointDataKey * The point data key of the reference time. Default value is