[Lada-commits] [PATCH 5 of 8] We might want to serialize an object without geom

Wald Commits scm-commit at wald.intevation.org
Fri Dec 9 16:58:41 CET 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1481297530 -3600
# Node ID 2bc06e7f6fb5bbf8d8249db2c1aa3f5a46d6e9e8
# Parent  73ad827faa8106c89d5d85df525fc80db4d0d608
We might want to serialize an object without geom.

This happens e.g. if an object is returned to the client before a
geometry has been constructed, due to validation error.

diff -r 73ad827faa81 -r 2bc06e7f6fb5 src/main/java/de/intevation/lada/model/stammdaten/Ort.java
--- a/src/main/java/de/intevation/lada/model/stammdaten/Ort.java	Fri Dec 09 15:34:15 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stammdaten/Ort.java	Fri Dec 09 16:32:10 2016 +0100
@@ -197,7 +197,10 @@
     }
 
     public Double getLatitude() {
-        return this.geom.getY();
+        // We might want to serialize an object without geom
+        return this.geom != null
+            ? this.geom.getY()
+            : null;
     }
 
     public Timestamp getLetzteAenderung() {
@@ -209,7 +212,10 @@
     }
 
     public Double getLongitude() {
-        return this.geom.getX();
+        // We might want to serialize an object without geom
+        return this.geom != null
+            ? this.geom.getX()
+            : null;
     }
 
     public String getMpArt() {


More information about the Lada-commits mailing list