GeoTools
  1. GeoTools
  2. GEOT-1157

StreamingRenderer does not properly handle "memoryPreloadingEnabled" hint

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.7-M0
    • Component/s: render
    • Labels:
      None
    • Testcase included:
      yes

      Description

      If the "memoryPreloadingEnabled" hint of the StreamingRenderer is set to Boolean.TRUE, only one of multiple GridCoverage layers of a MapContext will be displayed. This is also regardless which opacity is used in a RasterSymbolizer for the layers:

      public class SimpleMapViewer {
      public static void main(String[] args) throws IOException

      { MapContext mapContext = GTUtils.createWorldImageContext(); GTUtils.addWorldImageLayer(mapContext, new File("world-5400x2700.jpg"), 1.0); GTUtils.addWorldImageLayer(mapContext, new File("europe-7953x3326.jpg"), 0.5); // OK: both layers are shown, but performance very poor GTRenderer renderer = GTUtils.createRenderer(false); // PROBLEM: only first layer is shown, performance is better (but not good) //GTRenderer renderer = GTUtils.createRenderer(true); JMapPane mapPane = new JMapPane(renderer, mapContext); mapPane.setMapArea(mapContext.getLayerBounds()); JFrame frame = new JFrame(); frame.setTitle("SimpleMapViewer"); frame.getContentPane().add(mapPane, BorderLayout.CENTER); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setBounds(20, 20, 640, 320); frame.setVisible(true); }

      }

      public class GTUtils {
      public static MapContext createWorldImageContext()

      { return new DefaultMapContext(DefaultGeographicCRS.WGS84); }

      public static void addWorldImageLayer(MapContext context, File file, double opacity) throws IOException

      { GridCoverage gc = readWorldImage(file); StyleBuilder sb = new StyleBuilder(); RasterSymbolizer rs = sb.createRasterSymbolizer(); rs.setOpacity(ConstantExpression.constant(opacity)); context.addLayer(gc, sb.createStyle(rs)); }

      public static GridCoverage readWorldImage(File file) throws IOException

      { return new WorldImageReader(file).read(null); }

      public static GTRenderer createRenderer(boolean memoryPreloadingEnabled)

      { HashMap rendererHints = new HashMap(3); rendererHints.put("memoryPreloadingEnabled", Boolean.valueOf(memoryPreloadingEnabled)); // !!! RenderingHints java2DHints = new RenderingHints(null); java2DHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); java2DHints.put(JAI.KEY_INTERPOLATION, new InterpolationNearest()); StreamingRenderer renderer = new StreamingRenderer(); renderer.setRendererHints(rendererHints); renderer.setJava2DHints(java2DHints); return renderer; }

      }

        Activity

        Hide
        Andrea Aime added a comment -
        The hint has been removed
        Show
        Andrea Aime added a comment - The hint has been removed

          People

          • Assignee:
            Jesse Eichar
            Reporter:
            Norman Fomferra
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: