annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/CrossSectionKMService.java @ 5771:0677aff0ff15

Fixed typo ind i18n string.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 18 Apr 2013 15:03:13 +0200
parents f021080cb409
children
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
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 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
7
f7d890f4855f Added Service Service to lookup 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 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
9
f7d890f4855f Added Service Service to lookup 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 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
11
f7d890f4855f Added Service Service to lookup 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 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
13 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
14
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
15 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
16 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
17 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
18 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
19 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
20 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
21
f7d890f4855f Added Service Service to lookup 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 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
23
f7d890f4855f Added Service Service to lookup 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 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
25
f7d890f4855f Added Service Service to lookup 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 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
27
f7d890f4855f Added Service Service to lookup 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 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
29 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
30
f7d890f4855f Added Service Service to lookup 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 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
32 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
33 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
34
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
35
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 * Service to find the next/previous km (measurement) of cross sections.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
38 * 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
39 * service does the following:
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
40 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
41 * 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
42 * the N nearest other measurement points in both directions.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
43 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
44 * 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
45 * exists.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
46 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
47 * 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
48 * (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
49 * result in [4,5,7,8,9]).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
50 */
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
51 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
52 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
53 {
f7d890f4855f Added Service Service to lookup 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 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
55 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
56
f7d890f4855f Added Service Service to lookup 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 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
58
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
59
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
60 /** 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
61 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
62 }
f7d890f4855f Added Service Service to lookup 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
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
64
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 * @param data
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
67 */
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
68 @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
69 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
70 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
71 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
72 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
73 ) {
f7d890f4855f Added Service Service to lookup 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 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
75
f7d890f4855f Added Service Service to lookup 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 NodeList crossSectionNodes =
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
77 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
78
f7d890f4855f Added Service Service to lookup 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 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
80
f7d890f4855f Added Service Service to lookup 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 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
82
f7d890f4855f Added Service Service to lookup 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 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
84 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
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 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
87 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
88 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
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 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
91 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
92 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
93 }
f7d890f4855f Added Service Service to lookup 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 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
96 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
97 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
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 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
100 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
101 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
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 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
104 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
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 }
f7d890f4855f Added Service Service to lookup 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 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
108 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
109 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
110 }
f7d890f4855f Added Service Service to lookup 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
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
112 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
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 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
115 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
116 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
117 }
f7d890f4855f Added Service Service to lookup 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
f7d890f4855f Added Service Service to lookup 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 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
120 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
121
f7d890f4855f Added Service Service to lookup 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 (!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
123 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
124 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
125 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
126 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
127 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
128 "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
129 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
130 "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
131 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
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 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
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 }
f7d890f4855f Added Service Service to lookup 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
f7d890f4855f Added Service Service to lookup 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 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
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 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
140 }
f7d890f4855f Added Service Service to lookup 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
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
142 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
143
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
144 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
145
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
146 if (cache == null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
147 return getUncached(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
148 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
149
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
150 NavigableMap<Double, Integer> map;
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
151
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
152 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
153 if (element == null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
154 map = getUncached(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
155 if (map != null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
156 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
157 crossSectionId, map);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
158 cache.put(element);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
159 }
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 else {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
162 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
163 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
164
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
165 return map;
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
166 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
167
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
168
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
169 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
170 * @param km the kilometer from which to start searching for other
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
171 * measurements
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
172 * @param N number of neighboring measurements to find.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
173 */
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
174 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
175 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
176 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
177 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
178 ) {
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
179 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
180 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
181
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
182 Integer v = map.get(km);
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
183
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
184 if (v != null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
185 result.add(new AbstractMap.SimpleEntry<Double, Integer>(km, v));
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
186 }
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
187
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
188 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
189 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
190 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
191 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
192 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
193 }
f7d890f4855f Added Service Service to lookup 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 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
195 }
f7d890f4855f Added Service Service to lookup 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 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.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
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.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
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 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
207 }
f7d890f4855f Added Service Service to lookup 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
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
209
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
210 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
211 * @param crossSectionId id of queried cross-section (in db).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
212 * @return Mapping from kilometer to db-id.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
213 */
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
214 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
215 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
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 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
218 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
219
f7d890f4855f Added Service Service to lookup 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 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
221 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
222 "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
223 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
224
f7d890f4855f Added Service Service to lookup 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<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
226 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
227 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
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
f7d890f4855f Added Service Service to lookup 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 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
231 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
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 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
234 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
235 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
236 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
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 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
240 }
f7d890f4855f Added Service Service to lookup 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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org