@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdSHPModelDecoder2 extends Object implements ILcdModelDecoder
filter
is usedTLcdSHPModelDecoder
.
It loads all records up-front, including all geometry and property data.
This results in large memory footprint as well as a big decoding hit on startup, but subsequent queries are very fast.
File | Required | Entry point | Description |
---|---|---|---|
*.shp | x | x | Shape file containing the vector data |
*.dbf | dBASE table file containing the feature attributes of the shapes | ||
*.cpg | A plain text file which specifies the codepage number and which is used to identify the character encoding of the .shp file.
The file can contain a code page number or the name of a char set. |
||
*.shx | Index file containing the offset of each record from the beginning of the main file | ||
*.sbn/*.sbx | Optional spatial index files. If these are not present the decoder will create its own spatial index files. |
When the index file (*.shx) or one of the spatial index files (*.sbx or *.sbn) is missing, the decoder will create them at runtime. If possible the spatial index files are stored next to the source data with an *.sbnl and *.sbxl extension. If the files cannot be written next to the source data (e.g. no write permission), they will be written in the temp folder and deleted after disposing the model. If these files need to be created at runtime, there might be a small delay before the elements of this model are returned.
ILcdModelReferenceDecoder
. The default reference decoder set on this
model decoder is based on all model reference decoders annotated with the LcdService
annotation, and can handle
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.ILcd2DBoundsIndexedModel
.TLcdSHPModelDescriptor
.SHP
.data model
is based on the properties in the .dbf file.SHP Type | Decoded Type |
---|---|
POINT | ILcd2DEditablePoint object |
POINT_M | ILcd2DEditablePoint object implementing ILcdSHPMeasure |
POINT_Z | ILcd3DEditablePoint object implementing ILcdSHPMeasure |
POLYLINE | ILcd2DEditablePolyline object, or ILcdShapeList thereof |
POLYLINE_M | ILcd2DEditablePolyline objects implementing ILcdSHPMeasureList , or ILcdShapeList thereof |
POLYLINE_Z | ILcd3DEditablePolyline objects implementing ILcdSHPMeasureList , or ILcdShapeList thereof |
POLYGON | ILcd2DEditablePolygon object, or ILcdComplexPolygon |
POLYGON_M | ILcd2DEditablePolygon objects implementing ILcdSHPMeasureList , or ILcdShapeList thereof |
POLYGON_Z | ILcd3DEditablePolygon objects implementing ILcdSHPMeasureList , or ILcdShapeList thereof |
MULTI_POINT | ILcd2DEditablePolypoint object, or ILcdShapeList thereof |
MULTI_POINT_M | ILcdPolypoint objects implementing ILcdSHPMeasureList , or ILcdShapeList thereof |
MULTI_POINT_Z | ILcdPolypoint objects implementing ILcdSHPMeasureList , or ILcdShapeList thereof |
ILcdModelDecoder decoder = new TLcdSHPModelDecoder2();
ILcdModel model = decoder.decode("world.shp");
read lock
.memory-mapped files
to lazily load data.
Memory-mapped files are an efficient way to do random access on files.
The memory used by memory-mapped files is not part of the JVM heap.
The OS can allocate otherwise free system memory for caching pages in the files.
If you don't want this behavior you can use TLcdSHPModelDecoder
instead.
TLcdSHPModelEncoder
.Constructor and Description |
---|
TLcdSHPModelDecoder2() |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
TLcdModelMetadata |
decodeModelMetadata(String aSourceName)
Decodes metadata for the specified data source.
|
ILcdModelReference |
getDefaultModelReference()
Returns the model reference to be used for models when the model reference decoder is set to null.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the decoder used to produce model references.
|
boolean |
isTrimStringPropertyValues()
Indicates whether or not string values are trimmed when decoding DBF files.
|
void |
setDefaultModelReference(ILcdModelReference aDefaultModelReference)
Sets the model reference to be used for models when the model reference decoder is set to null.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the decoder to use to produce model references for models created with this decoder.
|
void |
setTrimStringPropertyValues(boolean aTrimStringPropertyValues)
Specifies whether or not leading and trailing whitespace should be removed
from string properties while decoding DBF files.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeSource, discoverDataSources
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely 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)
public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
ILcdModel
and does
not autogenerate any missing support files (such as the .sbnl
file), like the decode(String)
method does. The resulting TLcdModelMetadata
can however contain references to such files, even though
they do not (yet) exist.decodeModelMetadata
in interface ILcdModelDecoder
aSourceName
- the data source for which the model metadata will be decoded.IOException
- if the metadata cannot be decoded for some reason.ILcdModelDecoder.canDecodeSource(String)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
aDefaultModelReference
- the model reference to be used for models when the model reference
decoder is set to null.getDefaultModelReference()
public ILcdModelReference getDefaultModelReference()
setDefaultModelReference(com.luciad.model.ILcdModelReference)
public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
,
setDefaultModelReference(com.luciad.model.ILcdModelReference)
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the decoder to use to produce model references for models created with this decoder.getModelReferenceDecoder()
,
setDefaultModelReference(com.luciad.model.ILcdModelReference)
public void setTrimStringPropertyValues(boolean aTrimStringPropertyValues)
true
.aTrimStringPropertyValues
- whether or not string values in DBF files should be trimmedpublic boolean isTrimStringPropertyValues()
setTrimStringPropertyValues(boolean)