From 39a38a5d9d3c64d1f71ef2216188372c7f4a60f0 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Tue, 22 Apr 2014 18:40:15 -0500 Subject: [PATCH] Issue #2997 Fix NullPointerException when env is null Change-Id: Iec29c2c99f43239e95de6b01cb3e91d67211a1fe Former-commit-id: 6cfdda0e7b71cc13f39de6b1d39b31809851ef1b [formerly ae9e2357dc983755e5611103a2dc53aef08b77d4 [formerly 35c090952c9030f7c86422e863a13c8c9069bfeb] [formerly 6cfdda0e7b71cc13f39de6b1d39b31809851ef1b [formerly 31668fe53d6b138106412516a657107f521423c5]]] Former-commit-id: ae9e2357dc983755e5611103a2dc53aef08b77d4 [formerly 35c090952c9030f7c86422e863a13c8c9069bfeb] Former-commit-id: ae9e2357dc983755e5611103a2dc53aef08b77d4 Former-commit-id: 30673a179c70c49eff3519d229f85bf038d6f6a3 --- .../maps/dataaccess/util/MapsQueryUtil.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.maps/src/com/raytheon/uf/common/dataplugin/maps/dataaccess/util/MapsQueryUtil.java b/edexOsgi/com.raytheon.uf.common.dataplugin.maps/src/com/raytheon/uf/common/dataplugin/maps/dataaccess/util/MapsQueryUtil.java index 8fbc3e18fd..e6844a7393 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.maps/src/com/raytheon/uf/common/dataplugin/maps/dataaccess/util/MapsQueryUtil.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.maps/src/com/raytheon/uf/common/dataplugin/maps/dataaccess/util/MapsQueryUtil.java @@ -80,8 +80,11 @@ public class MapsQueryUtil { List columns, List additionalConstraints, String table, String geomField) { - String geospatialConstraint = "ST_Intersects(the_geom, ST_GeometryFromText('" - + boundingGeom.toText() + "', " + WGS84_SRID + "))"; + String geospatialConstraint = null; + if (boundingGeom != null) { + geospatialConstraint = "ST_Intersects(the_geom, ST_GeometryFromText('" + + boundingGeom.toText() + "', " + WGS84_SRID + "))"; + } return assembleMapsTableQuery(geospatialConstraint, columns, additionalConstraints, table, geomField); @@ -110,10 +113,13 @@ public class MapsQueryUtil { List columns, List additionalConstraints, String table, String geomField) { - String geospatialConstraint = String.format( - "%s && ST_SetSrid('BOX3D(%f %f, %f %f)'::box3d," + WGS84_SRID - + ")", geomField, env.getMinX(), env.getMinY(), - env.getMaxX(), env.getMaxY()); + String geospatialConstraint = null; + if (env != null) { + geospatialConstraint = String.format( + "%s && ST_SetSrid('BOX3D(%f %f, %f %f)'::box3d," + + WGS84_SRID + ")", geomField, env.getMinX(), + env.getMinY(), env.getMaxX(), env.getMaxY()); + } return assembleMapsTableQuery(geospatialConstraint, columns, additionalConstraints, table, geomField); }