# HG changeset patch # User Ingo Weinzierl # Date 1269967880 0 # Node ID 6cd8492019d8bf85061f6b7d4b96e2ebae8cc588 # Parent c907636c02886a1af7a453f9935d3861478a9c28 Validate wkt string and display error messages if the validation failed (issue214). gnv-artifacts/trunk@869 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c907636c0288 -r 6cd8492019d8 gnv-artifacts/ChangeLog --- a/gnv-artifacts/ChangeLog Tue Mar 30 14:16:07 2010 +0000 +++ b/gnv-artifacts/ChangeLog Tue Mar 30 16:51:20 2010 +0000 @@ -1,3 +1,17 @@ +2010-03-30 Ingo Weinzierl + + Issue214 + + * src/main/java/de/intevation/gnv/utils/InputValidator.java: Added code for + validating polygons and linestrings. The input type needs to be 'polygon' + or 'linestring'. + + * doc/conf/products/horizontalcrosssection/conf_mesh.xml: Changed the input + type of the wkt string from 'string' to 'polygon'. + + * doc/conf/products/verticalcrosssection/conf_mesh.xml: Changed the input + type of the wkt string from 'string' to 'linestring'. + 2010-03-30 Ingo Weinzierl * src/main/java/de/intevation/gnv/state/ExtendedInputData.java: Added a diff -r c907636c0288 -r 6cd8492019d8 gnv-artifacts/doc/conf/products/horizontalcrosssection/conf_mesh.xml --- a/gnv-artifacts/doc/conf/products/horizontalcrosssection/conf_mesh.xml Tue Mar 30 14:16:07 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/horizontalcrosssection/conf_mesh.xml Tue Mar 30 16:51:20 2010 +0000 @@ -134,7 +134,7 @@ - + diff -r c907636c0288 -r 6cd8492019d8 gnv-artifacts/doc/conf/products/verticalcrosssection/conf_mesh.xml --- a/gnv-artifacts/doc/conf/products/verticalcrosssection/conf_mesh.xml Tue Mar 30 14:16:07 2010 +0000 +++ b/gnv-artifacts/doc/conf/products/verticalcrosssection/conf_mesh.xml Tue Mar 30 16:51:20 2010 +0000 @@ -135,7 +135,7 @@ - + diff -r c907636c0288 -r 6cd8492019d8 gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Tue Mar 30 14:16:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Tue Mar 30 16:51:20 2010 +0000 @@ -65,8 +65,27 @@ public static boolean isInputValid(String input, String type) { log.debug("InputValidator.isInputValid " + input + " " + type); + + // Let's check polygons and linestrings first, because they might + // contain comma. A splitting at comma characters wouldn't be good here. + if ("Polygon".equalsIgnoreCase(type) || "Linestring".equalsIgnoreCase(type)) + { + try { + WKTReader reader = new WKTReader(); + reader.read(input); + + return true; + } + catch (ParseException pe) { + log.warn(pe, pe); + return false; + } + } + + // Check all the other input here boolean returnValue = false; String[] values = input.split(","); + for (int i = 0; i < values.length; i++) { boolean valid;