Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/raster/ExternalIndexConverter.java @ 864:2b8707432121
ISSUE262: Removed duplicate StateIds
gnv-artifacts/trunk@1002 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 27 Apr 2010 13:10:24 +0000 |
parents | feae2f9d6c6f |
children | f953c9a559d8 |
rev | line source |
---|---|
484
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.raster; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 /** |
802
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
6 * Converts the interal color index of a polygon to the external index |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
7 * defined by the corresponding palette entry. |
803
feae2f9d6c6f
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
802
diff
changeset
|
8 * |
780
c4156275c1e1
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
484
diff
changeset
|
9 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
484
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 */ |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 public class ExternalIndexConverter |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 implements JTSMultiPolygonProducer.ValueConverter |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 private static Logger log = Logger.getLogger( |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 ExternalIndexConverter.class); |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
802
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
17 /** |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
18 * The palette where to find the color indices. |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
19 */ |
484
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 protected Palette palette; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
802
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
22 /** |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
23 * Default constructor. |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
24 */ |
484
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public ExternalIndexConverter() { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
802
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
28 /** |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
29 * Constrcutor to create an ExternalIndexConverter with |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
30 * a given palette. |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
31 * @param palette The palette where to find the color indices. |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
32 */ |
484
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 public ExternalIndexConverter(Palette palette) { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 this.palette = palette; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
802
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
37 /** |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
38 * Maps the color index of a polygon to the external index |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
39 * defined by the corresponing palette entry. |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
40 * @param value The value to convert |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
41 * @return The mapped value or the original value if |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
42 * no corresponing palette entry was found. |
4abe172be970
Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
780
diff
changeset
|
43 */ |
484
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 public Integer convert(Integer value) { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 if (value == null) { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 return value; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 int v = value.intValue(); |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 if (v == -1) { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 return value; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 Palette.Entry entry = palette.getEntryByIndex(v); |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 if (entry == null) { |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 log.warn("cannot find palette entry for index: " + v); |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 return value; |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 return Integer.valueOf(entry.getExternalIndex()); |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
823e4f808418
Generate JTS geometries (multi polygons and multi linestrings) from
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |