comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/ShapeFileWriter.java @ 806:2cea76f1112e

Added Javadoc in utils package. gnv-artifacts/trunk@888 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Apr 2010 13:10:39 +0000
parents feeaf5aec552
children f953c9a559d8
comparison
equal deleted inserted replaced
805:bb7afd783321 806:2cea76f1112e
44 private static Logger log = Logger.getLogger( 44 private static Logger log = Logger.getLogger(
45 ShapeFileWriter.class); 45 ShapeFileWriter.class);
46 46
47 private static NumberFormat format = NumberFormat.getInstance(); 47 private static NumberFormat format = NumberFormat.getInstance();
48 48
49 /**
50 * Precision used to format double values.
51 */
49 public static final int DOUBLE_PRECISION = 3; 52 public static final int DOUBLE_PRECISION = 3;
50 53
51 static { 54 static {
52 format.setMaximumFractionDigits(DOUBLE_PRECISION); 55 format.setMaximumFractionDigits(DOUBLE_PRECISION);
53 } 56 }
54 57
55 private ShapeFileWriter() { 58 private ShapeFileWriter() {
56 } 59 }
57 60
61
62 /**
63 * Write multilinestrings to shapefile.
64 *
65 * @param shapeFile Shapefile.
66 * @param parameterId The parameter id.
67 * @param layer The layer.
68 * @param date The date.
69 * @param multiLineStrings The multilinestring.
70 * @return true, if shapefile writing was successful - otherwise false.
71 */
58 public static boolean writeMultiLineStringsToFile( 72 public static boolean writeMultiLineStringsToFile(
59 File shapeFile, 73 File shapeFile,
60 Integer parameterId, 74 Integer parameterId,
61 Integer layer, 75 Integer layer,
62 Date date, 76 Date date,
69 date, 83 date,
70 multiLineStrings, 84 multiLineStrings,
71 "isolines"); 85 "isolines");
72 } 86 }
73 87
88
89 /**
90 * Write multilinestrings to shapefile.
91 *
92 * @param shapeFile Shapefile.
93 * @param parameterId The parameter id.
94 * @param layer The layer.
95 * @param date The date.
96 * @param multiLineStrings The multilinestring.
97 * @param name A name.
98 * @return true, if shapefile writing was successful - otherwise false.
99 */
74 public static boolean writeMultiLineStringsToFile( 100 public static boolean writeMultiLineStringsToFile(
75 File shapeFile, 101 File shapeFile,
76 Integer parameterId, 102 Integer parameterId,
77 Integer layer, 103 Integer layer,
78 Date date, 104 Date date,
171 } 197 }
172 198
173 return success; 199 return success;
174 } 200 }
175 201
202
203 /**
204 * Write multipolygon to file.
205 *
206 * @param shapeFile The shapefile.
207 * @param parameterId The parameter id.
208 * @param layer The layer.
209 * @param date The date.
210 * @param multiPolygons Multipolygons.
211 * @return true, if shapefile writing was successful - otherwise false.
212 */
176 public static boolean writeMultiPolygonsToFile( 213 public static boolean writeMultiPolygonsToFile(
177 File shapeFile, 214 File shapeFile,
178 Integer parameterId, 215 Integer parameterId,
179 Integer layer, 216 Integer layer,
180 Date date, 217 Date date,
188 multiPolygons, 225 multiPolygons,
189 "polygons"); 226 "polygons");
190 } 227 }
191 228
192 229
230 /**
231 * Write data to shapefile.
232 *
233 * @param shapeFile The shapefile.
234 * @param name The name.
235 * @param data The data.
236 * @param geometryType The geometry type.
237 * @return true, if shapefile writing was successful - otherwise false.
238 */
193 public static boolean writeDataToFile(File shapeFile, 239 public static boolean writeDataToFile(File shapeFile,
194 String name, 240 String name,
195 Collection<Result> data, 241 Collection<Result> data,
196 String geometryType){ 242 String geometryType){
197 243
292 catch (IOException ioe) {} 338 catch (IOException ioe) {}
293 } 339 }
294 } 340 }
295 341
296 return true; 342 return true;
297 343 }
298 } 344
299 345
346 /**
347 * Write multipolygons to file.
348 *
349 * @param shapeFile The shapefile.
350 * @param parameterId The parameter id.
351 * @param layer The layer.
352 * @param date The date.
353 * @param multiPolygons Multipolygons.
354 * @param name A name.
355 * @return true, if shapefile writing was successful - otherwise false.
356 */
300 public static boolean writeMultiPolygonsToFile( 357 public static boolean writeMultiPolygonsToFile(
301 File shapeFile, 358 File shapeFile,
302 Integer parameterId, 359 Integer parameterId,
303 Integer layer, 360 Integer layer,
304 Date date, 361 Date date,
397 } 454 }
398 455
399 return success; 456 return success;
400 } 457 }
401 458
459 /**
460 * Returns an object as Double.
461 *
462 * @param a An object.
463 * @return Object <i>a</i> as Double. If <i>a</i> is not a double and no
464 * number, 0d is returned.
465 */
402 private static final Double asDouble(Object a) { 466 private static final Double asDouble(Object a) {
403 if (a instanceof Double) { 467 if (a instanceof Double) {
404 return (Double)a; 468 return (Double)a;
405 } 469 }
406 if (a instanceof Number) { 470 if (a instanceof Number) {
407 return Double.valueOf(((Number)a).doubleValue()); 471 return Double.valueOf(((Number)a).doubleValue());
408 } 472 }
409 return 0d; 473 return 0d;
410 } 474 }
411 475
476 /**
477 * Turns a double value into a string representation taking account of the
478 * locale.
479 *
480 * @param value A double value.
481 * @return The double value formatted as string.
482 */
412 private static final String value2description(Double value) { 483 private static final String value2description(Double value) {
413 return format.format(value); 484 return format.format(value);
414 } 485 }
415 } 486 }
416 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 487 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org