Current Multi-Size API (as of 02.10.2015)
...
getImageToModelTransform(GeoCoding)
: CallsGeoCoding.getImageToMapTransform
to check if it is affine, if so, returns it, otherwise returns identity (1). 22 usagesgetModelCrs(GeoCoding)
: CallsGeoCoding.getImageToMapTransform
to check if it is affine, if so, returnsGeoCoding.mapCrs
, otherwiseGeoCoding.imageCrs
. 22 usagesgetMultiLevelModel(RasterDataNode)
: Used to derive a multi-level image model from a raster data node's source image, otherwise callscreateMultiLevelModel
.(2) 26 usagescreateMultiLevelModel(ProductNode)
: Used to create a default multi-level image model. CallsgetImageToModelTransform
, usesProduct.numResolutionsMax
.(2) 9 usagesgetPreferredTileSize(Product)
Gets the preferred tile size of a product or computes a new one. 16 usages
(1) Returning the identity transformation by default is probably wrong in many cases, because then images of any size would return the same transformation into a common model CRS!
...
The following is a proposal for a reinterpretation of Product properties and methods and a description of new ones:
- A data Product contains
- Vector data
- Raster data,
- with same or different image raster sizes
- with same or different or without geo-coding assigned
- A product has a model coordinate reference system (model CRS) which is common to all the product components
- Vector data geometries are always given in model coordinates(1)
- Raster data images provide an
AffineTransformation
from image pixel coordinates to model coordinates
- A product must always return valid model CRS via
Product.getModelCrs()
. Either the model CRS- is passed to a constructor, or
- is explicitly set using
Product.setModelCrs(crs)
, or - is derived from a reference raster data node(2)(3), or if no such exists
- an
IllegalStateException
is thrown
- A product must return a non-zero reference scene raster size via
Product.getReferenceRasterSizegetSceneRasterSize()
. Note thatPin
s andGCP
s have apixelPos
attribute that refers to the reference raster's grid. Also,TiePointGrid
s interpolate from their local raster data grid into the reference raster's grid. Either the reference scene raster size- is passed to a constructor, or
- is explicitly set using
Product.setReferenceSceneRasterSize(size)
, or - is derived from a reference raster data node, or if no such exists
- an
IllegalStateException
is thrown
- A product must return an affine transformation from the reference raster grid to the model CRS (i2m-transform) via
Product.getReferenceImageToModelTransformgetSceneImageToModelTransform()
. Either the i2m-transform- is passed to a constructor, or
- is explicitly set using
Product.set
, orReference
Scene
Image
ToModelTransform(i2mT) - is derived from a reference raster data node(4), or if no such exists
- an
IllegalStateException
is thrown
- A product may return a reference scene geo-coding via
Product.getReferenceSceneGeoCoding()
providing the transformation from the reference scene raster coordinates to geographical coordinates. Therefore, a reference geo-coding implies a valid reference scene raster size. Either the reference scene geo-coding- is passed to a constructor, or
- is explicitly set using
Product.setReferenceSceneGeoCoding(geoCoding)
, or - is derived from a reference raster data node, or if no such exists
null
is returned
- A product must return a preferred tile size for all raster data nodes(5) via
Product.getPreferredTileSize()
. Either the preferred tile size- is explicitely set by
Product.setPreferredTileSize(tw,th)
, or - a default tile size is computed from the reference raster size, or if no such exists
(512, 512)
is returned.
- is explicitely set by
(
...
- is explicitely set by
Product.setPreferredTileSize(iw, ih, tw,th)
, or - a default tile size is computed for
(iw,ih)
.
(1) Vector data are represented by SimpleFeature
which can provide a CRS for their default geometry. Howver, in SNAP we use a common coordinate system for all vector data therefore a single model CRS is required per product. Pin
s and GCP
s also have a pixelPos
attribute. Its value must be given in reference scene raster coordinates.
(2) Obtaining the reference raster data node could be done as follows:
...
(5) A client may wish to force all images of all raster data nodes to have the same tile size regardless of their actual image size. This may or may not be useful for a particular product type instance. Also, it may make sense to force the tile cache to contain single size tiles for maximum memory reuse.
RasterDataNode API
- A raster data node must return a tile size
RasterDataNode.tileSize
that is used by it's source image or that will be used for any source image as long as it hasn't been created so far. Either the tile size is- retrieved from a source image, or if no such yet exists,
- the one explicitely set by
RasterDataNode.setTileSize(tw,th)
, or - the value of
Product.preferredTileSize
Facts and Consequences
- Every product instance must have a model CRS. As a consequence, in order to save products in DIMAP- or -NetCDF format, they must be made persistable.
- A reference scene geo-coding implies a valid reference scene raster size.
- A model CRS may be derived from the reference the scene geo-coding, see implementation of
ImageManager.getModelCrs(gc)
- A model CRS may be derived from a valid reference scene image only, if no reference scene geo-coding is specified.
- All i2m-transforms are affine (linear) transformations.
- The
Product.
addBand(name, ...)
andaddMask(name, ...)
methods must throw anIllegalStateException
if no valid reference raster size is defined. - Note that it is still confusing to API users that we
- use the terms image, raster, pixel, sample in an inconsistent manner in property/method names in
RasterDataNode
and alsoTile
(GPF); - have map, geo and image CRS in the GeoCoding API, but a model CRS in the Product API (four CRS!). Luckily, API users usually don't deal with that too much.
- use the terms image, raster, pixel, sample in an inconsistent manner in property/method names in
...
- Concerning points 1 to 6 and considering the actual use of these properties: is default a better name than reference, or even stay with scene?
Answer (NF): scene is not bad because it refers to the satellite footprint or spatial coverage, reference iis more neutral (because we don't always have footprints or spatial coverage), default is only useful concerning theProduct.addBand(name,...)
andaddMask(name, ..)
methods. May may stay with scene, to minimze refactorings and maximize compatibility. Problematic are other uses of scene such as inProductSceneView
. On the other hand, theLayer
s used in such a view all share the model CRS. We could argument, that whenever we say scene, we refer to model coordinates.
Decision: We stay with scene in API names which may be derived from a reference raster data node. RasterDataNode
currently has arasterSize
property and also asceneRasterSize
property which are the same in most cases, but usually different for aTiePointGrid
. OncesceneRasterSize
is reinterpreted asreferenceRasterSize
reinterpreted in this new sense, thenrasterSize
should refer to the actual size of the raster data in use. But since aTiePointGrid
automatically expand its data to thereferenceRasterSize
sceneRasterSize
, its actual raster size is the reference raster size. How can we avoid this ambiguity?
Answer (NF): Hide the actual tie point grid size as an implementation detail inTiePointGrid
.- Carefully visit and analyse all current
RasterDataNode.rasterWith/Height/Size
as well asRasterDataNode.
get/setRasterData
andRasterDataNode.
getSceneRasterData
usages. - Then let
RasterDataNode.rasterWith/Height/Size
return the actual raster size with respect to a multi-size product, change context code accordingly (should only affectTiePointGrid
usages). - Replace current
RasterDataNode.sceneRasterWidth/Height/Size
usages byRasterDataNode.rasterWith/Height/Size
. - Completely remove
RasterDataNode.sceneRasterWidth/Height/Size
properties. - Replace current
RasterDataNode.getSceneRasterData
usages byRasterDataNode.
.getRasterData
- Completely remove
RasterDataNode.sceneRasterData
method.
- Carefully visit and analyse all current
- Why do we need a
pixelPos
attribute for Pins and GCPs? The product's model CRS is either theGeoCoding.mapCrs
or some image CRS referring to the reference raster size. Therefore there is always a linear transformation from the model CRS to the image CRS anyway.
Answer (NF): Check actual usage ofpixelPos
. If it is not too much work, remove the attribute completly, use thegeometry
field instead as it seems the most generic and non-redundant information.
...
- revisit existing Product constructors and change according to requirements 1 to 6.
- add
Product.get/setModelCrs
methods. ImplementgetModelCrs
method according to point 3 above - rename reimplement
Product.getSceneRasterSize
intogetReferenceRasterSize
. Implement method according to point 4 above (we may stay withsceneRasterSize
, see above Q&A 1)
...
- reimplement
Product.
getSceneRasterWidth/Height
into
getReferenceRasterWidth/Height
. Implement method according to point 4 above (return zero instead of null).
- rename
Product.getGeoCoding
intogetReferenceGeoCoding
getSceneGeoCoding
. Implement method according to point 6 above - replace all
ImageManager.getModelCrs(gc)
by Product.getModelCrs() calls, removeImageManager.getModelCrs
- replace all
ImageManager.getImageToModelTransform(gc)
by ??? calls, removeImageManager.getImageToModelTransform
...