@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdJPIPModelDecoder extends Object implements ILcdModelDecoder
http://host:port/path/to/image.jp2
).
"http"
or "jpip"
.ILcd2DBoundsIndexedModel
.TLcdJPIPModelDescriptor
.ALcdImage
(and ILcdMultilevelRaster
) instance.ILcdDisposable.dispose()
on all model elements. Note that the caller
must ensure that the elements are not used after they are disposed. Typically this means removing all layers that use
the model from their view before disposing the elements.
ILcdTransport
used for communicating with a JPIP server can be customized by
using the setTransportFactory(com.luciad.io.transport.ILcdTransportFactory)
method.decodeRasterReference(com.luciad.format.jpeg2000.TLcdJPIPModelDescriptor)
method can be
overridden to customize the decoding of the georeferencing information of the raster. This is
for example necessary if this information is embedded as application-specific XML.
ILcdModelDecoder decoder = new TLcdJPIPModelDecoder();
ILcdModel model = decoder.decode("http://localhost:8080/image.jp2");
image cache size
affects how much data needs to be retrieved
from the server. Typically some of the data retrieved for an image region can be reused in
subsequent requests for nearby image regions. A larger cache size increases the chance that data
can be read from the cache instead of retrieving it again from the server.threshold
.ALcdImage
API it is possible to decode monochrome, RGB and multi band images. Each band of the image may contain
<= 16
bits, which will not be scaled. Further, it is assumed that all data is unsigned.
model descriptor
and the precision in the ILcdRaster
from its ILcdRaster.getColorModel() color model
. The raster component
is either 8 or 16 bits and the total number of bits per raster pixel is at most 32bits. Image components
is obtained by scaling the image components. For example, an RGB JPIP image with
11 bits per component will be converted to an RGB raster with 8 bits per component where each component is scaled by (2^11 - 1) / (2^8 - 1)
.
Constructor and Description |
---|
TLcdJPIPModelDecoder()
Creates a new
TLcdJPIPModelDecoder , with a globally shared buffer for
caching pixel data. |
TLcdJPIPModelDecoder(ILcdBuffer aBuffer)
Creates a new
TLcdJPIPModelDecoder with the given buffer. |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether
TLcdJPIPModelDecoder can decode the given data. |
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
protected ILcdRasterReference |
decodeRasterReference(TLcdJPIPModelDescriptor aModelDescriptor)
Decodes the raster reference based on the metadata.
|
ILcdBounds |
getDefaultBounds()
Sets the default model bounds that is assigned to rasters of the
decoded models whose images don't specify bounds.
|
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference that is assigned to decoded models
whose images don't specify model references.
|
int |
getDefaultValue()
Returns the default pixel value that is assigned to the rasters of the
decoded models.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
int |
getImageCacheSize()
Returns the size (in bytes) of the image cache.
|
double |
getMaximumResidualTiePointError()
Returns the maximum acceptable average residual error for tie points.
|
int |
getMinimumTiePointCount()
Returns the minimum number of tie points required for positioning images
that provide tie points.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder that is used for decoded models
whose images don't specify model references.
|
ILcdRasterReferencer |
getRasterReferencer()
Returns the raster referencer that is used when positioning images
based on tie points.
|
ILcdTransportFactory |
getTransportFactory()
Returns the transport factory that will construct the
ILcdTransport used for
communicating with a JPIP server. |
boolean |
isAllowOrthographicReferencing()
Returns whether images that are positioned in geodetic references
using tie points may be put in approximating orthographic grid
references that are centered around the images.
|
boolean |
isQueryServerOnCanDecode()
Returns whether the server should be queried in the
canDecodeSource(String) method. |
void |
setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing)
Specifies whether images that are positioned in geodetic references
using tie points may be put in approximating orthographic grid
references that are centered around the images.
|
void |
setDefaultBounds(ILcdBounds aBounds)
Sets the default model bounds that will be assigned to rasters of the
decoded models whose images don't specify bounds.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Sets the default model reference that will be assigned to decoded models
whose images don't specify model references.
|
void |
setDefaultValue(int aDefaultValue)
Sets the default pixel value that will be assigned to the rasters of the
decoded models.
|
void |
setImageCacheSize(int aCacheSize)
Sets the size (in bytes) of the image cache.
|
void |
setMaximumResidualTiePointError(double aMaximumResidualTiePointError)
Sets the maximum acceptable average residual error for tie points, when
positioning images that provide tie points instead of scaling
information or transformation matrices.
|
void |
setMinimumTiePointCount(int aMinimumTiePointCount)
Sets the minimum number of tie points required for positioning images
that provide tie points instead of scaling information or
transformation matrices.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder that will be used for decoded models
whose images don't specify model references.
|
void |
setQueryServerOnCanDecode(boolean aQueryServerOnCanDecode)
Sets whether the server should be queried in the
canDecodeSource(String) method. |
void |
setRasterReferencer(ILcdRasterReferencer aRasterReferencer)
Sets the raster referencer that will be used when positioning images
based on tie points.
|
void |
setTransportFactory(ILcdTransportFactory aTransportFactory)
Sets the transport factory that will construct the
ILcdTransport used for
communicating with a JPIP server. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdJPIPModelDecoder()
TLcdJPIPModelDecoder
, with a globally shared buffer for
caching pixel data.TLcdSharedBuffer.getBufferInstance()
public TLcdJPIPModelDecoder(ILcdBuffer aBuffer)
TLcdJPIPModelDecoder
with the given buffer.aBuffer
- the buffer in which pixel data can be decoded and cached.public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
null
.aModelReferenceDecoder
- the model reference decoder.public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
null
.aDefaultModelReference
- the default model reference.public ILcdModelReference getDefaultModelReference()
setDefaultModelReference(com.luciad.model.ILcdModelReference)
public void setDefaultBounds(ILcdBounds aBounds)
null
.aBounds
- the default model bounds.public ILcdBounds getDefaultBounds()
setDefaultBounds(com.luciad.shape.ILcdBounds)
public void setMinimumTiePointCount(int aMinimumTiePointCount)
3
.aMinimumTiePointCount
- the minimum number of tie points.setMaximumResidualTiePointError(double)
public int getMinimumTiePointCount()
setMinimumTiePointCount(int)
public void setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing)
true
.public boolean isAllowOrthographicReferencing()
setAllowOrthographicReferencing(boolean)
public void setMaximumResidualTiePointError(double aMaximumResidualTiePointError)
10
.aMaximumResidualTiePointError
- the maximum residual error, expressed
in pixels.setMinimumTiePointCount(int)
public double getMaximumResidualTiePointError()
setMaximumResidualTiePointError(double)
public void setRasterReferencer(ILcdRasterReferencer aRasterReferencer)
minimumTiePointCount
, allowOrthographicReferencing
,
and maximumResidualTiePointError
, which are used by default.
The initial value is null
.aRasterReferencer
- the raster referencer, which will create model
references and raster bounds based on tie points.public ILcdRasterReferencer getRasterReferencer()
setRasterReferencer(com.luciad.format.raster.reference.ILcdRasterReferencer)
public void setDefaultValue(int aDefaultValue)
0
.aDefaultValue
- the default pixel value.ILcdRaster.setDefaultValue(int)
public int getDefaultValue()
setDefaultValue(int)
public ILcdTransportFactory getTransportFactory()
ILcdTransport
used for
communicating with a JPIP server.setTransportFactory(com.luciad.io.transport.ILcdTransportFactory)
public void setTransportFactory(ILcdTransportFactory aTransportFactory)
ILcdTransport
used for
communicating with a JPIP server.
The default transport factory creates ILcdTransport
s based on the Apache HttpClient
library. This factory uses the proxy configuration from
the system-wide proxy selector
The transports created by the factory should implement ILcdDisposable
if they hold any
resources (ex. network connections).
This setter does not affect already decoded models.aTransportFactory
- the transport factory, must not be null
public int getImageCacheSize()
setImageCacheSize(int)
public void setImageCacheSize(int aCacheSize)
64MB
.
This setter does not affect already decoded models.
The cache size will be clamped to the minimal cache size if it is too small.aCacheSize
- the cache size in bytespublic boolean isQueryServerOnCanDecode()
canDecodeSource(String)
method.true
if the server should be queriedsetQueryServerOnCanDecode(boolean)
public void setQueryServerOnCanDecode(boolean aQueryServerOnCanDecode)
canDecodeSource(String)
method.
If enabled, the server will be queried in the canDecode
method to verify that it is a
valid JPIP server, otherwise this method will only verify that the provided source name is a
valid URI.
This is enabled by default.aQueryServerOnCanDecode
- true
if the server should be queriedpublic String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
TLcdJPIPModelDecoder
can decode the given data.
The source name should be a URI with one of the supported schemes.
This method verifies that the specified source name is a valid URI. If
isQueryServerOnCanDecode()
is enabled then this method will also verify that the
specified the server exists and is a valid JPIP server.canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the url of the image that is to be testedtrue
if TLcdJPIPModelDecoder
can decode
the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
protected ILcdRasterReference decodeRasterReference(TLcdJPIPModelDescriptor aModelDescriptor) throws IOException
aModelDescriptor
- the model descriptorIOException
- if the raster reference could not be decoded