annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/CrossSectionKMService.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
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: 5868
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: 5868
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: 2120
diff changeset
9 package org.dive4elements.river.artifacts.services;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
11 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
12 import org.dive4elements.artifacts.GlobalContext;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
14 import org.dive4elements.artifacts.common.utils.XMLUtils;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
16 import org.dive4elements.river.artifacts.cache.CacheFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
17
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
18 import org.dive4elements.river.backend.SessionHolder;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
19
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
20 import org.dive4elements.river.model.CrossSection;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
21 import org.dive4elements.river.model.CrossSectionLine;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
23 import java.util.AbstractMap;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 import java.util.ArrayDeque;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import java.util.Deque;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 import java.util.List;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 import java.util.Map;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 import java.util.NavigableMap;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 import java.util.concurrent.ConcurrentSkipListMap;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 import net.sf.ehcache.Cache;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
34 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
35 import org.apache.logging.log4j.LogManager;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 import org.hibernate.Query;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 import org.hibernate.Session;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 import org.w3c.dom.Document;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 import org.w3c.dom.Element;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 import org.w3c.dom.NodeList;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
44
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
45 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
46 * Service to find the next/previous km (measurement) of cross sections.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
47 * Looking at the query for a single cross-section id at a single km, the
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
48 * service does the following:
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
49 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
50 * It returns the km itself if a measurement at that km was found and
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
51 * the N nearest other measurement points in both directions.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
52 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
53 * That means, you can pass N=0 to find out whether a measurement at given km
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
54 * exists.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
55 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
56 * If less than N neighbours exist in one direction, less are delivered
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
57 * (e.g. given measurements at [0,2,3,4,5,7,8,9] a query for km=8, N=3 will
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
58 * result in [4,5,7,8,9]).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
59 */
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 public class CrossSectionKMService
5868
35b2d86c3fb5 River artifacts: Renamed FLYSService to D4EService.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
61 extends D4EService
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
63 private static Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
64 LogManager.getLogger(CrossSectionKMService.class);
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 public static final String CACHE_NAME = "cross-section-kms";
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
68
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
69 /** Trivial constructor. */
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 public CrossSectionKMService() {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
73
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
74 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
75 * @param data
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
76 */
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 @Override
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 public Document doProcess(
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 Document data,
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 GlobalContext globalContext,
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 CallMeta callMeta
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
83 log.debug("CrossSectionKMService.doProcess");
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 NodeList crossSectionNodes =
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
86 data.getElementsByTagName("art:cross-section");
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 Document document = XMLUtils.newDocument();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 Element all = document.createElement("cross-sections");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 for (int i = 0, CS = crossSectionNodes.getLength(); i < CS; ++i) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 Element crossSectionElement = (Element)crossSectionNodes.item(i);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 String idString = crossSectionElement.getAttribute("id");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 String kmString = crossSectionElement.getAttribute("km");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 String neighborsString = crossSectionElement.getAttribute("n");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 if (idString.length() == 0 || kmString.length() == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
100 log.debug("missing attributes in cross-section element");
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 continue;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 double km;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 Integer crossSectionId;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 int N = 2;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 try {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 km = Double.parseDouble(kmString);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 crossSectionId = Integer.valueOf(idString);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 if (neighborsString.length() > 0) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 N = Integer.parseInt(neighborsString);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
117 log.debug("converting number failed", nfe);
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 continue;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
121 NavigableMap<Double, Integer> map = getKms(crossSectionId);
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 if (map == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
124 log.debug("cannot find cross section " + crossSectionId);
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 continue;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 Deque<Map.Entry<Double, Integer>> result =
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 nearestNeighbors(map, km, N);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 if (!result.isEmpty()) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 Element csE = document.createElement("cross-section");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 csE.setAttribute("id", idString);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 for (Map.Entry<Double, Integer> entry: result) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 Element lineE = document.createElement("line");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 lineE.setAttribute(
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 "line-id", String.valueOf(entry.getValue()));
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 lineE.setAttribute(
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 "km", String.valueOf(entry.getKey()));
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 csE.appendChild(lineE);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 all.appendChild(csE);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 document.appendChild(all);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148 return document;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
151 public static NavigableMap<Double, Integer> getKms(int crossSectionId) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
152
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
153 Cache cache = CacheFactory.getCache(CACHE_NAME);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
154
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
155 if (cache == null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
156 return getUncached(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
157 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
158
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
159 NavigableMap<Double, Integer> map;
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
160
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
161 net.sf.ehcache.Element element = cache.get(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
162 if (element == null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
163 map = getUncached(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
164 if (map != null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
165 element = new net.sf.ehcache.Element(
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
166 crossSectionId, map);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
167 cache.put(element);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
168 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
169 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
170 else {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
171 map = (NavigableMap<Double, Integer>)element.getValue();
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
172 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
173
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
174 return map;
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
175 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
176
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
177
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
178 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
179 * @param km the kilometer from which to start searching for other
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
180 * measurements
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
181 * @param N number of neighboring measurements to find.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
182 */
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
183 public static Deque<Map.Entry<Double, Integer>> nearestNeighbors(
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
184 NavigableMap<Double, Integer> map,
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
185 double km,
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
186 int N
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
187 ) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
188 Deque<Map.Entry<Double, Integer>> result =
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
189 new ArrayDeque<Map.Entry<Double, Integer>>(2*N);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
190
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
191 Integer v = map.get(km);
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
192
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
193 if (v != null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
194 result.add(new AbstractMap.SimpleEntry<Double, Integer>(km, v));
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
195 }
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
196
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
197 int i = 0;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
198 for (Map.Entry<Double, Integer> entry:
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
199 map.headMap(km, false).descendingMap().entrySet()) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
200 if (i++ >= N) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
201 break;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 result.addFirst(entry);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
204 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
205
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
206 i = 0;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
207 for (Map.Entry<Double, Integer> entry:
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
208 map.tailMap(km, false).entrySet()) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
209 if (i++ >= N) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
210 break;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
211 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
212 result.addLast(entry);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
213 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
214
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 return result;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
218
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
219 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
220 * @param crossSectionId id of queried cross-section (in db).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
221 * @return Mapping from kilometer to db-id.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
222 */
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 public static NavigableMap<Double, Integer> getUncached(
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 Integer crossSectionId
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225 ) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226 NavigableMap<Double, Integer> result =
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 new ConcurrentSkipListMap<Double, Integer>();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229 Session session = SessionHolder.HOLDER.get();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 Query query = session.createQuery(
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231 "from CrossSection where id=:id");
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
232 query.setParameter("id", crossSectionId);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
233
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 List<CrossSection> crossSections = query.list();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235 if (crossSections.isEmpty()) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 return null;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
237 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239 CrossSection crossSection = crossSections.get(0);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 List<CrossSectionLine> lines = crossSection.getLines();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
241
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242 for (CrossSectionLine line: lines) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
243 Double km = line.getKm().doubleValue();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244 Integer id = line.getId();
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
245 result.put(km, id);
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248 return result;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org