annotate gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoAttributeGenerator.java @ 1129:ccfa07b88476

merged geo-backend
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:01 +0200
parents f953c9a559d8
children
rev   line source
1115
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
1 /*
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
3 *
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
5 * Read the file LGPL.txt coming with the software for details
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
7 */
f953c9a559d8 Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 802
diff changeset
8
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.raster;
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
465
f7038820df2e Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
11 /**
802
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
12 * Generates label attributes for iso lines. It takes the
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
13 * neighboring palette ranges and calculates the mid point
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
14 * between these two ranges.
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: 465
diff changeset
15 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
465
f7038820df2e Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
16 */
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public class IsoAttributeGenerator
465
f7038820df2e Added support to trace rasters to JTS multi polygons and multi line strings.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 448
diff changeset
18 implements IsoProducer.AttributeGenerator
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 {
802
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
20 /**
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
21 * The palette where to look for the ranges.
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
22 */
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 protected Palette palette;
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
802
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
25 /**
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
26 * Default constructor.
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
27 */
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public IsoAttributeGenerator() {
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 }
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
802
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
31 /**
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
32 * Constructor to create an IsoAttributeGenerator with
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
33 * a given lookup palette.
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
34 * @param palette The palette.
4abe172be970 Finished Javadoc of the raster package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 798
diff changeset
35 */
448
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public IsoAttributeGenerator(Palette palette) {
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 this.palette = palette;
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public Object generateAttribute(int neighbor1, int neighbor2) {
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 Palette.Entry e1 = palette.getEntryByIndex(neighbor1);
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 Palette.Entry e2 = palette.getEntryByIndex(neighbor2);
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 if (e1 == null || e2 == null) {
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 return null;
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 }
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 double e1t = e1.getFrom();
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 double e2f = e2.getTo();
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 return Double.valueOf(e2f >= e1t
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 ? 0.5d*(e1t+e2f)
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 : 0.5d*(e2.getTo()+e1.getFrom()));
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 }
3cb2bea50456 Generate iso line classes according gnv-issues/issue108
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 }
798
6cff63d0c434 Fixed vim modeline. Added some Javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 780
diff changeset
56 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org