Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/BlackboardDataFacet.java @ 6152:0587819960c3
Waterlevel differences & bed height differences: Add new model LinearInterpolated intented to unify the two very similiar calculations. The focus of the current implementation is correctness and not speed! The fact that the data sets more mostly sorted by station is not exploited. Doing so would improve performance significantly.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 02 Jun 2013 17:52:53 +0200 |
parents | af13ceeba52a |
children | 838d0d82b450 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2739
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import java.util.List; |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2739
diff
changeset
|
14 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2739
diff
changeset
|
15 import org.dive4elements.artifacts.CallContext; |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2739
diff
changeset
|
17 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
2739
diff
changeset
|
18 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 /** |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 * Facet that writes artifact-uui and facet index on the blackboard, |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 * delivers data if asked so. |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 */ |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 public class BlackboardDataFacet extends DefaultFacet { |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 public BlackboardDataFacet() {} |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 /** Do not instantiate a BlackboardDataFacet, subclass it instead. */ |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 public BlackboardDataFacet(int idx, String name, String description) { |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 super(idx, name, description); |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 } |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
2739
ccc955ef8811
Whitespaces.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2405
diff
changeset
|
34 |
2122
81312f84689a
Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2104
diff
changeset
|
35 /** Do not instantiate a BlackboardDataFacet, subclass it instead. */ |
81312f84689a
Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2104
diff
changeset
|
36 public BlackboardDataFacet(String name, String description) { |
81312f84689a
Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2104
diff
changeset
|
37 super(0, name, description); |
81312f84689a
Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2104
diff
changeset
|
38 } |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 |
2739
ccc955ef8811
Whitespaces.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2405
diff
changeset
|
40 |
2104
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
41 /** Define key to which to respond when asked for 'blackboard' |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
42 * (DataProvider)- data. */ |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
43 public String areaDataKey(Artifact art) { |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
44 return art.identifier() + ":" + getName() + ":" + getIndex(); |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
45 } |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
46 |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
47 |
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
48 /** Hey, We can ArtifactUUID+:+FacetName+:+FacetIndex (i.e. getData)! */ |
2405
f008c3335a77
Towards fixe of flys/issue495.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2125
diff
changeset
|
49 @Override |
f008c3335a77
Towards fixe of flys/issue495.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2125
diff
changeset
|
50 public List getStaticDataProviderKeys(Artifact art) { |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 List list = new ArrayList(); |
2104
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
52 list.add(areaDataKey(art)); |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 return list; |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 } |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 /** |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 * Can provide whatever getData returns. |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 * @param key will respond on uuid+index |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 * @param param ignored |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 * @param context ignored |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 * @return whatever getData delivers. |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 */ |
2405
f008c3335a77
Towards fixe of flys/issue495.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2125
diff
changeset
|
64 @Override |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 public Object provideBlackboardData(Artifact artifact, |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 Object key, |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 Object param, |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 CallContext context |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 ) { |
2104
bb0dede9294f
Implementation towards areas at other than first axis (flys/issue441).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2024
diff
changeset
|
70 if (key.equals(areaDataKey(artifact))) { |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 return getData(artifact, context); |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 } |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 else { |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 return null; |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 } |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 } |
2125
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
77 |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
78 /** Copy deeply. */ |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
79 @Override |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
80 public Facet deepCopy() { |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
81 BlackboardDataFacet copy = new BlackboardDataFacet(); |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
82 copy.set(this); |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
83 return copy; |
7a8f52267a5c
Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2122
diff
changeset
|
84 } |
2024
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 } |
2bb160b2768e
New facet, will ease converting other facets to be able to contribute to area computations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |