I am using OpenMap and have to load very large dimensioned images.
I tried to load these images as big raster which fails wi开发者_如何转开发th an OufOfMemoryException. In debug mode the layer constructor tells me that the image dimensions are too large.In an OpenMap mailing list I found the MyJAIPlugin, which allows me to load and display GeoTiff files.
How can I show a 300mb GeoTiff in OpenMap?
I had a nearly same situation by loading hd maps with at least 690mb filesize.
I also used the JAIPlugIn from the mailing list and internaly they use the OMScalingRaster witch works with a BufferedImage. These limits your image size and causes the debug message.
I've solved it by modifieing the OMScalingRaster. I've changed the BufferedImage to a TiledImage to handle large images and fixed the upcoming errors. Here it's important you change the scaleTo(Projection thisProj)-method, to scale with JAI.
Now i can load the file and it's rendered on the map. But if you are zooming out too much, it will throw a OutOfMemoryException because in my modification i make a subimage of the part of the image that will be visible and give it as BufferedImage to the OMRaster.
Here is the mod. at the end of the scaleTo-method:
// Now we can grab the bit we want out of the source
// and
// scale it to fit the intersection.
// Calc width adjustment
float widthAdj = (float) ((double) iRect.width
/ (double) clipRect.width);
// Calc height adjustment
float heightAdj = (float) ((double) iRect.height
/ (double) clipRect.height);
// Create the transform
// JAI-Version
ParameterBlock pb = new ParameterBlock();
pb.addSource(sourceImage.getSubImage(clipRect.x,
clipRect.y,
clipRect.width,
clipRect.height).getAsBufferedImage());
pb.add(widthAdj); // The xScale
pb.add(heightAdj); // The yScale
pb.add(0.0F); // The x translation
pb.add(0.0F); // The y translation
RenderedOp newImage = JAI.create("scale",pb, null);
bitmap = newImage.getAsBufferedImage();
point1.setLocation(iRect.x, iRect.y);
// setVisible(currentVisibility);
}
} else {
bitmap = null;
}
}
For the other errors by replacing BufferedImage with TiledImage use the equivalent TiledImage-methods. But to save memory you should use the TiledImage-constructor with the sharedDataBuffer flag = true.
For Exsample this mod. can handle maps (compressed 690mb) with a scaling of 1:50000 and i can zoom out to 1:600000 before the layer says it run out of memory.
精彩评论