Simone Giannecchini a écrit : > Besides the fact that the GridCoverage IS is de-facto deprecated, I am > not a fan of automagic code.
I would call that optimization rather than automagic. To me, "automatic" is making an arbitrary decision. For example assuming that a geometry having (x,y) values in +/-180 and +/-90° range has a GeographicCRS is automagic. At the opposite an optimization do not change the result, i.e. is invisible for the users except for the speed/memory difference. The Java language itself is full of optimizations. JAI too (example below). In GeoTools an example is dropping a coordinate transformation when we detect that it is the identity one. > It seems quite natural to have a scale operation for scaling images, a > warp operation for warping images, and a crop operation for cropping > images. I agree - it is very natural to have those operations when we want to do only a scale, or only a crop. When we want to combine them, there is some advantages to see the combinaison as a "resample" as a whole. Or sometime not - it is user's choice on a case-by-case basis. > Well, that depends a lot. If you are simply going to scale up or down > a raster, besides the non trivial cost of putting together the > gridgeometry for the resample operation a warp affine is much slower > than a simple scale. That is why I started using scale in some cases. https://jai-core.dev.java.net/source/browse/jai-core/src/share/classes/com/sun/media/jai/opimage/AffineCRIF.java?rev=1.1&view=markup Quoting their source code (you can find the place where it occurs by searching "scale"): // // Check and see if the affine transform is in fact doing // a Scale operation. In which case call Scale which is more // optimized than Affine. // There is similar checks for translation and copy operations. This is optimization (not automagic) of the same kind than the one done in our Resample2D. This is why I didn't put special cases for translation and scale since I noticed that JAI implementation was already doing this optimization for us. > This is controversial from my experience. In principle it might be > better to do everything in one step as the resample does. But in the > past I have experience scaling very large tiled raster data (up to 20 > gb as single mosaic) and it seemed that for certain scale factors > (very big ones) with certain schemes (bilinear) or higher it was > better to do multiple scales. As an instance, if you want to scale by > 64 I found out that doing multiple scales by 4 was faster. In ths case > if you think of a complex reprojection (datum change) of a very large > raster which also involves a drastic downsampling, I would not be 100% > sure that doin this in one step using warp affine is the best way to > go. I would rather scale down first and then reproject since you are > going to apply the reprojection point by point in java and if you > first downsample you would make things much faster (this is from > experience). Yes I can imagine that cases like that happen... > Anyway, I would not say that you are wrong, I would just say that I > would not be so firm. You are right, I should not be too firm (it was not my intend). Thanks for sharing your experience, Martin ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
