annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/CrossSectionKMService.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children 35b2d86c3fb5
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
9 package org.dive4elements.river.artifacts.services;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
11 import org.dive4elements.artifacts.CallMeta;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
12 import org.dive4elements.artifacts.GlobalContext;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
14 import org.dive4elements.artifacts.common.utils.XMLUtils;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
16 import org.dive4elements.river.artifacts.cache.CacheFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
17
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
18 import org.dive4elements.river.backend.SessionHolder;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
19
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
20 import org.dive4elements.river.model.CrossSection;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 2120
diff changeset
21 import org.dive4elements.river.model.CrossSectionLine;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
23 import java.util.AbstractMap;
1749
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 import java.util.ArrayDeque;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import java.util.Deque;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 import java.util.List;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 import java.util.Map;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 import java.util.NavigableMap;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 import java.util.concurrent.ConcurrentSkipListMap;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 import net.sf.ehcache.Cache;
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
f7d890f4855f Added Service Service to lookup 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.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
35
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 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
37 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
38
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 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
40 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
41 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
42
1961
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 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
45 * Service to find the next/previous km (measurement) of cross sections.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
46 * 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
47 * service does the following:
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
48 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
49 * 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
50 * the N nearest other measurement points in both directions.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
51 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
52 * 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
53 * exists.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
54 *
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
55 * 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
56 * (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
57 * result in [4,5,7,8,9]).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
58 */
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
59 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
60 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
61 {
f7d890f4855f Added Service Service to lookup 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 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
63 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
64
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 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
66
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
67
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
68 /** 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
69 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
70 }
f7d890f4855f Added Service Service to lookup 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
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
72
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
73 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
74 * @param data
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
75 */
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
76 @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
77 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
78 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
79 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
80 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
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 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
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 NodeList crossSectionNodes =
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
85 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
86
f7d890f4855f Added Service Service to lookup 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 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
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 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
90
f7d890f4855f Added Service Service to lookup 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 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
92 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
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 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
95 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
96 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
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 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
99 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
100 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
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
f7d890f4855f Added Service Service to lookup 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 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
104 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
105 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
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 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
108 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
109 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
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 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
112 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
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 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
116 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
117 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
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
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
120 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
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 (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
123 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
124 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
125 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 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
128 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
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 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
131 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
132 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
133 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
134 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
135 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
136 "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
137 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
138 "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
139 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
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 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
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 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145 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
146
f7d890f4855f Added Service Service to lookup 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 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
148 }
f7d890f4855f Added Service Service to lookup 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
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
150 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
151
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
152 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
153
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
154 if (cache == null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
155 return getUncached(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
156 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
157
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
158 NavigableMap<Double, Integer> map;
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 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
161 if (element == null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
162 map = getUncached(crossSectionId);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
163 if (map != null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
164 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
165 crossSectionId, map);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
166 cache.put(element);
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
167 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
168 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
169 else {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
170 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
171 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
172
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
173 return map;
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
174 }
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
175
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
176
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
177 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
178 * @param km the kilometer from which to start searching for other
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
179 * measurements
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
180 * @param N number of neighboring measurements to find.
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 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
183 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
184 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
185 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
186 ) {
f7d890f4855f Added Service Service to lookup 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 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
188 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
189
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
190 Integer v = map.get(km);
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
191
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
192 if (v != null) {
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1973
diff changeset
193 result.add(new AbstractMap.SimpleEntry<Double, Integer>(km, v));
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
194 }
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
195
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
196 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
197 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
198 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
199 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
200 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
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 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
203 }
f7d890f4855f Added Service Service to lookup 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 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
206 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
207 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
208 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
209 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
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 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
212 }
f7d890f4855f Added Service Service to lookup 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 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
215 }
f7d890f4855f Added Service Service to lookup 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
1961
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
217
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
218 /**
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
219 * @param crossSectionId id of queried cross-section (in db).
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
220 * @return Mapping from kilometer to db-id.
4781096f31f8 Mainly documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1749
diff changeset
221 */
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
222 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
223 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
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 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
226 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
227
f7d890f4855f Added Service Service to lookup 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 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
229 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
230 "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
231 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
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 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
234 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
235 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
236 }
f7d890f4855f Added Service Service to lookup 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 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
239 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
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 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
242 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
243 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
244 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
245 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 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
248 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 }
f7d890f4855f Added Service Service to lookup the Nth nearest neighbors for a set of given cross section ids and kms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org