Issue #2882: Allow null values to be passed back in parameter values for DefaultGeometryData.

Change-Id: I258d247476cf280e107d386b903e9764a492d4f4

Former-commit-id: 0407f5b2e5 [formerly 0e583860b64e9ca856152affe70f62d5f866af4f]
Former-commit-id: d58bb87ee6
This commit is contained in:
David Gillingham 2014-03-19 17:19:02 -05:00
parent 12aa173989
commit e34f698b1d
3 changed files with 13 additions and 4 deletions

View file

@ -39,6 +39,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 10, 2012 njensen Initial creation
* Mar 19, 2014 2882 dgilling Create a new Type for null data.
*
* </pre>
*
@ -49,7 +50,7 @@ import com.vividsolutions.jts.geom.Geometry;
public interface IGeometryData extends IData {
public static enum Type {
STRING, INT, LONG, FLOAT, DOUBLE;
STRING, INT, LONG, FLOAT, DOUBLE, NULL;
};
/**
@ -118,5 +119,4 @@ public interface IGeometryData extends IData {
*/
public Type getType(String param);
}

View file

@ -44,6 +44,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Nov 09, 2012 njensen Initial creation
* Jun 03, 2013 #2023 dgilling Implement getAttributes().
* Jan 21, 2014 2667 bclement attribute method comments
* Mar 19, 2014 2882 dgilling Handle null values with a special Type.
*
* </pre>
*
@ -141,6 +142,9 @@ public class DefaultGeometryData implements IGeometryData {
case DOUBLE:
result = (Double) data.value;
break;
case NULL:
result = null;
break;
default:
throw new UnsupportedOperationException(
"Unable to handle data of type "
@ -273,6 +277,8 @@ public class DefaultGeometryData implements IGeometryData {
data.type = Type.LONG;
} else if (data.value instanceof Float) {
data.type = Type.FLOAT;
} else if (data.value == null) {
data.type = Type.NULL;
}
}
this.dataMap.put(parameter, data);

View file

@ -27,8 +27,11 @@
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 06/03/13 dgilling Initial Creation.
# 06/03/13 dgilling Initial Creation.
# 01/06/14 #2537 bsteffen Share geometry WKT.
# 03/19/14 #2882 dgilling Raise an exception when getNumber()
# is called for data that is not a
# numeric Type.
#
#
@ -67,7 +70,7 @@ class PyGeometryData(IGeometryData, PyData.PyData):
elif t == 'DOUBLE':
return float(value)
else:
return value
raise TypeError("Data for parameter " + param + " is not a numeric type.")
def getUnit(self, param):
return self.__dataMap[param][2]