comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java @ 2678:d35e37b6a211

Fix issue620: synchron navigation at impossible km. flys-artifacts/trunk@4376 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 10 May 2012 09:13:33 +0000
parents 734d5f5e55c0
children 64dc2997b2dd
comparison
equal deleted inserted replaced
2677:57d6670ddda3 2678:d35e37b6a211
240 } 240 }
241 241
242 242
243 /** 243 /**
244 * Get CrossSectionLine spatially closest to what is specified in the data 244 * Get CrossSectionLine spatially closest to what is specified in the data
245 * "cross_section.km". 245 * "cross_section.km", null if considered too far.
246 * 246 *
247 * @return CrossSectionLine closest to "cross_section.km". 247 * @return CrossSectionLine closest to "cross_section.km", might be null
248 * if considered too far.
248 */ 249 */
249 public FastCrossSectionLine searchCrossSectionLine() { 250 public FastCrossSectionLine searchCrossSectionLine() {
250 251 double TOO_FAR = 1d;
251 CrossSection crossSection = CrossSectionFactory 252 CrossSection crossSection = CrossSectionFactory
252 .getCrossSection(getDBID()); 253 .getCrossSection(getDBID());
253 254
254 if (logger.isDebugEnabled()) { 255 if (logger.isDebugEnabled()) {
255 logger.debug("dbid " + getDBID() + " : " + crossSection); 256 logger.debug("dbid " + getDBID() + " : " + crossSection);
270 double ceilD = ceil != null 271 double ceilD = ceil != null
271 ? Math.abs(ceil - wishKM) 272 ? Math.abs(ceil - wishKM)
272 : Double.MAX_VALUE; 273 : Double.MAX_VALUE;
273 274
274 double km = floorD < ceilD ? floor : ceil; 275 double km = floorD < ceilD ? floor : ceil;
276
277 // If we are too far from the wished km, return null.
278 if (Math.abs(km - wishKM) > TOO_FAR) {
279 return null;
280 }
275 281
276 return FastCrossSectionLineFactory 282 return FastCrossSectionLineFactory
277 .getCrossSectionLine(crossSection, km); 283 .getCrossSectionLine(crossSection, km);
278 } 284 }
279 285

http://dive4elements.wald.intevation.org