annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/CrossSectionKMService.java @ 1961:4781096f31f8

Mainly documentation. flys-artifacts/trunk@3368 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 08 Dec 2011 12:01:24 +0000
parents f7d890f4855f
children e0b081105a82
rev   line source
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
1 package de.intevation.flys.artifacts.services;
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
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
3 import de.intevation.artifacts.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
4 import de.intevation.artifacts.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
5
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
6 import de.intevation.artifacts.common.ArtifactNamespaceContext;
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
7 import de.intevation.artifacts.common.utils.XMLUtils;
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
8
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
9 import de.intevation.flys.artifacts.cache.CacheFactory;
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
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
11 import de.intevation.flys.backend.SessionHolder;
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
12
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 import de.intevation.flys.model.CrossSection;
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
14 import de.intevation.flys.model.CrossSectionLine;
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
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
16 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
17 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
18 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
19 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
20 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
21 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
22
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
23 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
24
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 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
26
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 org.apache.log4j.Logger;
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
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 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
30 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
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 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
33 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
34 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
35
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
36
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
37 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
38 * Service to find the next/previous km (measurement) of cross sections.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
39 * 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
40 * service does the following:
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
41 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
42 * 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
43 * the N nearest other measurement points in both directions.
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 * 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
46 * exists.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
47 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
48 * 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
49 * (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
50 * result in [4,5,7,8,9]).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
51 */
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
52 public class 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
53 extends FLYSService
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
54 {
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
55 private static Logger logger =
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
56 Logger.getLogger(CrossSectionKMService.class);
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
57
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
58 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
59
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
60
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
61 /** 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
62 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
63 }
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
64
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
65
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
66 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
67 * @param data
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
68 */
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
69 @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
70 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
71 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
72 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
73 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
74 ) {
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
75 logger.debug("CrossSectionKMService.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
76
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 NodeList crossSectionNodes =
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
78 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
79
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 Cache cache = CacheFactory.getCache(CACHE_NAME);
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
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 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
83
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 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
85
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
86 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
87 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
88
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 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
90 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
91 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
92
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 if (idString.length() == 0 || kmString.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
94 logger.debug("missing attributes in cross-section 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
95 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
96 }
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
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 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
99 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
100 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
101
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 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
103 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
104 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
105
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 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
107 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
108 }
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 }
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 catch (NumberFormatException nfe) {
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 logger.debug("converting number failed", nfe);
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 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
113 }
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 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
116
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
117 if (cache == 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
118 map = getUncached(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
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 else {
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
121 net.sf.ehcache.Element element = cache.get(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
122 if (element == 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
123 map = getUncached(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
124 if (map != 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
125 element = new net.sf.ehcache.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
126 crossSectionId, 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
127 cache.put(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
128 }
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 }
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 else {
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 map = (NavigableMap<Double, Integer>)element.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
132 }
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 }
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
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 if (map == 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
136 logger.debug("cannot find cross section " + 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
137 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
138 }
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
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 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
141 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
142
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 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
144 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
145 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
146 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
147 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
148 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
149 "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
150 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
151 "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
152 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
153 }
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
154 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
155 }
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
156 }
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
157
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
158 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
159
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
160 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
161 }
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
162
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
163
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
164 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
165 * @param km the kilometer from which to start searching for other
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
166 * measurements
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
167 * @param N number of neighboring measurements to find.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
168 */
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
169 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
170 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
171 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
172 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
173 ) {
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
174 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
175 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
176
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
177 if(map.get(km) != null) {
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
178 result.add(new AbstractMap.SimpleEntry<Double, Integer>(km,map.get(km)));
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
179
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
180 }
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
181
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
182 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
183 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
184 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
185 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
186 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
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 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
189 }
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
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
191 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
192 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
193 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
194 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
195 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
196 }
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 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
198 }
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
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 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
201 }
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
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
203
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
204 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
205 * @param crossSectionId id of queried cross-section (in db).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
206 * @return Mapping from kilometer to db-id.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
207 */
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
208 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
209 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
210 ) {
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 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
212 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
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 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
215 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
216 "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
217 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
218
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
219 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
220 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
221 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
222 }
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
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 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
225 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
226
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 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
228 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
229 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
230 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
231 }
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
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 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
234 }
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 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org