Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java @ 778:9a828e5a2390
Removed trailing whitespace
gnv-artifacts/trunk@851 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 07:58:51 +0000 |
parents | eedad2ddad14 |
children | c4156275c1e1 |
comparison
equal
deleted
inserted
replaced
777:8009961db1cb | 778:9a828e5a2390 |
---|---|
107 */ | 107 */ |
108 public HorizontalCrossSectionMeshOutputState() { | 108 public HorizontalCrossSectionMeshOutputState() { |
109 } | 109 } |
110 | 110 |
111 public void initialize(String uuid, CallContext callContext) | 111 public void initialize(String uuid, CallContext callContext) |
112 throws StateException { | 112 throws StateException { |
113 super.initialize(uuid, callContext); | 113 super.initialize(uuid, callContext); |
114 if (log.isDebugEnabled()) { | 114 if (log.isDebugEnabled()) { |
115 log.debug("initialize output state " + uuid); | 115 log.debug("initialize output state " + uuid); |
116 } | 116 } |
117 // fill the cache | 117 // fill the cache |
170 } // run | 170 } // run |
171 }.start(); | 171 }.start(); |
172 } | 172 } |
173 | 173 |
174 public void out( | 174 public void out( |
175 Document format, | 175 Document format, |
176 Collection<InputData> inputData, | 176 Collection<InputData> inputData, |
177 OutputStream outputStream, | 177 OutputStream outputStream, |
178 String uuid, | 178 String uuid, |
179 CallContext callContext | 179 CallContext callContext |
180 ) | 180 ) |
181 throws StateException | 181 throws StateException |
182 { | 182 { |
183 String outputMode = XMLUtils.xpathString( | 183 String outputMode = XMLUtils.xpathString( |
184 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE); | 184 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE); |
185 | 185 |
186 if (outputMode == null) { | 186 if (outputMode == null) { |
208 | 208 |
209 protected void writeZip( | 209 protected void writeZip( |
210 String uuid, | 210 String uuid, |
211 CallContext callContext, | 211 CallContext callContext, |
212 OutputStream output | 212 OutputStream output |
213 ) | 213 ) |
214 throws StateException | 214 throws StateException |
215 { | 215 { |
216 try { | 216 try { |
217 String p = getShapeFilePath(); | 217 String p = getShapeFilePath(); |
218 if (p != null) { | 218 if (p != null) { |
357 synchronized (shapeFileLock) { | 357 synchronized (shapeFileLock) { |
358 if (shapeDir.exists()) { | 358 if (shapeDir.exists()) { |
359 FileUtils.deleteContent(shapeDir); | 359 FileUtils.deleteContent(shapeDir); |
360 } | 360 } |
361 else if (!shapeDir.mkdirs()) { | 361 else if (!shapeDir.mkdirs()) { |
362 log.error("cannot create directory '" | 362 log.error("cannot create directory '" |
363 + shapeDir.getAbsolutePath() + "'"); | 363 + shapeDir.getAbsolutePath() + "'"); |
364 return null; | 364 return null; |
365 } | 365 } |
366 createdDir = true; | 366 createdDir = true; |
367 } | 367 } |
406 finally { | 406 finally { |
407 if (!success && createdDir) { | 407 if (!success && createdDir) { |
408 FileUtils.deleteRecursive(shapeDir); | 408 FileUtils.deleteRecursive(shapeDir); |
409 } | 409 } |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 | 413 |
414 protected AttributedPoint2ds getResult(String uuid, CallContext callContext) | 414 protected AttributedPoint2ds getResult(String uuid, CallContext callContext) |
415 throws StateException | 415 throws StateException |
416 { | 416 { |
430 cf.getCache().put(new net.sf.ehcache.Element(key, result)); | 430 cf.getCache().put(new net.sf.ehcache.Element(key, result)); |
431 } | 431 } |
432 | 432 |
433 return result; | 433 return result; |
434 } | 434 } |
435 | 435 |
436 protected AttributedPoint2ds produceResult(CallContext callContext) | 436 protected AttributedPoint2ds produceResult(CallContext callContext) |
437 throws StateException | 437 throws StateException |
438 { | 438 { |
439 InputData meshPolygon = inputData.get("mesh_polygon"); | 439 InputData meshPolygon = inputData.get("mesh_polygon"); |
440 InputData meshId = inputData.get("meshid"); | 440 InputData meshId = inputData.get("meshid"); |
441 | 441 |
532 int kIdx = rd.getColumnIndex("KPOSITION"); | 532 int kIdx = rd.getColumnIndex("KPOSITION"); |
533 int tIdx = rd.getColumnIndex("TIMEVALUE"); | 533 int tIdx = rd.getColumnIndex("TIMEVALUE"); |
534 int pIdx = rd.getColumnIndex("PARAMETERID"); | 534 int pIdx = rd.getColumnIndex("PARAMETERID"); |
535 | 535 |
536 if (sIdx == -1 || iIdx == -1 | 536 if (sIdx == -1 || iIdx == -1 |
537 || jIdx == -1 || kIdx == -1 | 537 || jIdx == -1 || kIdx == -1 |
538 || vIdx == -1 || tIdx == -1 | 538 || vIdx == -1 || tIdx == -1 |
539 || pIdx == -1 | 539 || pIdx == -1 |
540 ) { | 540 ) { |
541 log.error("missing column in result set"); | 541 log.error("missing column in result set"); |
542 return null; | 542 return null; |
558 int i = result.getInteger(iIdx); | 558 int i = result.getInteger(iIdx); |
559 int j = result.getInteger(jIdx); | 559 int j = result.getInteger(jIdx); |
560 | 560 |
561 Point2d p2d = new Point2d(coord.x, coord.y, v, i, j); | 561 Point2d p2d = new Point2d(coord.x, coord.y, v, i, j); |
562 points.add(p2d); | 562 points.add(p2d); |
563 | 563 |
564 } | 564 } |
565 ap2ds.setPoints(points); | 565 ap2ds.setPoints(points); |
566 | 566 |
567 return ap2ds; | 567 return ap2ds; |
568 } | 568 } |
608 int numSamples = numSamples(callContext); | 608 int numSamples = numSamples(callContext); |
609 int groundInterpolation = getGroundInterpolation(callContext); | 609 int groundInterpolation = getGroundInterpolation(callContext); |
610 int extrapolationRounds = extrapolationRounds(callContext); | 610 int extrapolationRounds = extrapolationRounds(callContext); |
611 | 611 |
612 if (!interpolation.interpolate( | 612 if (!interpolation.interpolate( |
613 input.getPoints(), | 613 input.getPoints(), |
614 boundingBox, | 614 boundingBox, |
615 new Dimension(numSamples, numSamples), | 615 new Dimension(numSamples, numSamples), |
616 new QueriedXYDepth(groundInterpolation), | 616 new QueriedXYDepth(groundInterpolation), |
617 extrapolationRounds | 617 extrapolationRounds |
618 )) { | 618 )) { |
646 | 646 |
647 JTSMultiPolygonProducer jtsmpp = new JTSMultiPolygonProducer( | 647 JTSMultiPolygonProducer jtsmpp = new JTSMultiPolygonProducer( |
648 polygon, | 648 polygon, |
649 boundingBox.getMinX(), boundingBox.getMinY(), | 649 boundingBox.getMinX(), boundingBox.getMinY(), |
650 boundingBox.getMaxX(), boundingBox.getMaxY()); | 650 boundingBox.getMaxX(), boundingBox.getMaxY()); |
651 | 651 |
652 int numRegions = new Vectorizer(intRaster, numSamples) | 652 int numRegions = new Vectorizer(intRaster, numSamples) |
653 .process(jtsmpp); | 653 .process(jtsmpp); |
654 | 654 |
655 Map<Integer, MultiPolygon> polygons = jtsmpp.getMultiPolygons( | 655 Map<Integer, MultiPolygon> polygons = jtsmpp.getMultiPolygons( |
656 new ExternalIndexConverter(basePalette)); | 656 new ExternalIndexConverter(basePalette)); |
703 input.setLineStrings(lineStrings); | 703 input.setLineStrings(lineStrings); |
704 | 704 |
705 return input; | 705 return input; |
706 } | 706 } |
707 | 707 |
708 | 708 |
709 @Override | 709 @Override |
710 public void setup(Node configuration) { | 710 public void setup(Node configuration) { |
711 super.setup(configuration); | 711 super.setup(configuration); |
712 this.ijkQueryID = Config.getStringXPath(configuration,"queryID-ijk"); | 712 this.ijkQueryID = Config.getStringXPath(configuration,"queryID-ijk"); |
713 | 713 |
714 } | 714 } |
715 | 715 |
716 private static int numSamples(CallContext callContext) { | 716 private static int numSamples(CallContext callContext) { |
717 GNVArtifactContext context = | 717 GNVArtifactContext context = |
718 (GNVArtifactContext)callContext.globalContext(); | 718 (GNVArtifactContext)callContext.globalContext(); |
719 Integer samples = (Integer)context.get( | 719 Integer samples = (Integer)context.get( |
720 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_SAMPLES_KEY); | 720 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_SAMPLES_KEY); |
742 ? dir | 742 ? dir |
743 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH; | 743 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SHAPEFILE_PATH; |
744 } | 744 } |
745 | 745 |
746 private static int getGroundInterpolation(CallContext callContext) { | 746 private static int getGroundInterpolation(CallContext callContext) { |
747 GNVArtifactContext context = | 747 GNVArtifactContext context = |
748 (GNVArtifactContext)callContext.globalContext(); | 748 (GNVArtifactContext)callContext.globalContext(); |
749 | 749 |
750 String interpolation = (String)context.get( | 750 String interpolation = (String)context.get( |
751 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY); | 751 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_GROUND_INTERPOLATION_KEY); |
752 | 752 |
754 } | 754 } |
755 | 755 |
756 private static Map<Integer, PaletteManager> getPalettes( | 756 private static Map<Integer, PaletteManager> getPalettes( |
757 CallContext callContext | 757 CallContext callContext |
758 ) { | 758 ) { |
759 GNVArtifactContext context = | 759 GNVArtifactContext context = |
760 (GNVArtifactContext)callContext.globalContext(); | 760 (GNVArtifactContext)callContext.globalContext(); |
761 Map<Integer, PaletteManager> palettes = | 761 Map<Integer, PaletteManager> palettes = |
762 (Map<Integer, PaletteManager>)context.get( | 762 (Map<Integer, PaletteManager>)context.get( |
763 GNVArtifactContext.PALETTES_KEY); | 763 GNVArtifactContext.PALETTES_KEY); |
764 return palettes != null | 764 return palettes != null |