Class ShapeFileFeatureLayer
This class represents a Layer backed by a Shape File.
public class ShapeFileFeatureLayer : FeatureLayer
- Inheritance
-
ShapeFileFeatureLayer
- Inherited Members
Remarks
None
Constructors
ShapeFileFeatureLayer()
This is a constructor for the class.
public ShapeFileFeatureLayer()
Remarks
This is the default constructor. If you use this constructor, then you should set the required methods manually.
ShapeFileFeatureLayer(string)
This is a constructor for the class.
public ShapeFileFeatureLayer(string shapePathFilename)
Parameters
shapePathFilename
stringThis parameter is the Shape File path and filename.
Remarks
None
ShapeFileFeatureLayer(string, FileAccess)
This is a constructor for the class.
public ShapeFileFeatureLayer(string shapePathFilename, FileAccess readWriteMode)
Parameters
shapePathFilename
stringThis parameter is the Shape File path and filename.
readWriteMode
FileAccessThis parameter specifies whether the file will be opened in read-only or read/write mode.
Remarks
None
ShapeFileFeatureLayer(string, string)
This is a constructor for the class.
public ShapeFileFeatureLayer(string shapePathFilename, string indexPathFilename)
Parameters
shapePathFilename
stringThis parameter is the Shape File path and filename.
indexPathFilename
stringThis parameter is the index file path and filename.
Remarks
None
ShapeFileFeatureLayer(string, string, FileAccess)
This is a constructor for the class.
public ShapeFileFeatureLayer(string shapePathFilename, string indexPathFilename, FileAccess readWriteMode)
Parameters
shapePathFilename
stringThis parameter is the Shape File path and filename.
indexPathFilename
stringThis parameter is the index file path and filename.
readWriteMode
FileAccessThis parameter specifies whether the file will be opened in read-only or read/write mode.
Remarks
None
ShapeFileFeatureLayer(string, string, FileAccess, Encoding)
This is a constructor for the class.
public ShapeFileFeatureLayer(string shapePathFilename, string indexPathFilename, FileAccess readWriteMode, Encoding encoding)
Parameters
shapePathFilename
stringThis parameter is the Shape File path and filename.
indexPathFilename
stringThis parameter is the index file path and filename.
readWriteMode
FileAccessThis parameter specifies whether the file will be opened in read-only or read/write mode.
encoding
EncodingThis parameter specifies the encoding of the data.
Remarks
None
Properties
Encoding
This property gets and sets the encoding information for the DBF.
public Encoding Encoding { get; set; }
Property Value
HasBoundingBox
This property checks to see if a Layer has a BoundingBox or not. If it has no BoundingBox, it will throw an exception when you call the GetBoundingBox() and GetFullExtent() APIs. In ShapeFileFeatureLayer, we override this API and mark it as true.
public override bool HasBoundingBox { get; }
Property Value
Remarks
The default implementation in the base class returns false.
IndexPathFilename
This property returns the path and filename of the index file you want to represent.
public string IndexPathFilename { get; set; }
Property Value
- string
This property returns the path and filename of the index file you want to represent.
Remarks
None
Exceptions
- ArgumentException
Setting an invalid PathFilename structure will throw an ArgumentException.
ProgressiveDrawingRecordsCount
public int ProgressiveDrawingRecordsCount { get; set; }
Property Value
ReadWriteMode
public FileAccess ReadWriteMode { get; set; }
Property Value
RequireIndex
This property gets and sets whether an index is required when reading data. The default value is true.
public bool RequireIndex { get; set; }
Property Value
ShapePathFilename
This property returns the path and filename of the Shape File you want to represent.
public string ShapePathFilename { get; set; }
Property Value
- string
This property returns the path and filename of the Shape File you want to represent.
Remarks
None
Exceptions
- ArgumentException
Setting an invalid PathFilename structure will throw an ArgumentException.
SimplificationAreaInPixel
public int SimplificationAreaInPixel { get; set; }
Property Value
UsingSpatialIndex
This property gets whether the Shape File FeatureSource has an index or not.
public bool UsingSpatialIndex { get; }
Property Value
Methods
BuildIndexFile(IEnumerable<Feature>, string)
This method builds a spatial index for the specified group of features.
public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename)
Parameters
features
IEnumerable<Feature>This parameter specifies the features for which to build the index.
indexPathFilename
stringThis parameter specifies the target index path and filename.
Remarks
This overload allows you to pass in a group of features and specify the index filename to use.
BuildIndexFile(IEnumerable<Feature>, string, BuildIndexMode)
This method builds a spatial index for the specified group of features.
public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename, BuildIndexMode buildIndexMode)
Parameters
features
IEnumerable<Feature>This parameter specifies the features for which to build the index.
indexPathFilename
stringThis parameter determines the target index path filename.
buildIndexMode
BuildIndexModeThis parameter determines whether an index file will be rebuilt if it already exists.
Remarks
This overload allows you to pass in a group of features and specify the index filename to use.
BuildIndexFile(IEnumerable<Feature>, string, ProjectionConverter)
This method builds a spatial index for the specified group of features and target projection.
public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename, ProjectionConverter projectionConverter)
Parameters
features
IEnumerable<Feature>This parameter specifies the features for which to build the index.
indexPathFilename
stringThis parameter specifies the target index path and filename.
projectionConverter
ProjectionConverterThis parameter specifies the projection to build index against those features.
Remarks
This overload allows you to pass in a group of features and specify a target projection and the index filename to use.
BuildIndexFile(IEnumerable<Feature>, string, ProjectionConverter, BuildIndexMode)
This method builds a spatial index for the specified group of features.
public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename, ProjectionConverter projectionConverter, BuildIndexMode buildIndexMode)
Parameters
features
IEnumerable<Feature>This parameter specifies the features for which to build the index.
indexPathFilename
stringThis parameter determines the target index path filename.
projectionConverter
ProjectionConverterThis parameter determines the Projection to build index against those features.
buildIndexMode
BuildIndexModeThis parameter determines whether an index file will be rebuilt if it already exists.
Remarks
This overload allows you to pass in a group of features and specify a target projection and the index filename to use.
BuildIndexFile(string)
This method builds a spatial index for the layer.
public static void BuildIndexFile(string pathFilename)
Parameters
pathFilename
stringThe path and filename to the Shape File.
Remarks
This overload allows you to pass in the Shape File.
BuildIndexFile(string, string, string, string, BuildIndexMode)
This method builds a spatial index only for those features that satisfy a regular expression.
public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, string columnName, string regularExpression, BuildIndexMode buildIndexMode)
Parameters
shapePathFilename
stringThis parameter specifies the Shape File for which to build the index.
indexPathFilename
stringThis parameter determines the target index path filename.
columnName
stringThis parameter determines the column name whose values will be tested against the regular expression.
regularExpression
stringThis parameter represents the regular expression to test against each feature for inclusion in the index.
buildIndexMode
BuildIndexModeThis parameter determines whether an index file will be rebuilt if it already exists.
Remarks
This overload allows you to pass in a Shape File and specify the index filename to use.
BuildIndexFile(string, string, BuildIndexMode)
This method build a spatial index for the shape file which increases accessspeed.
public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, BuildIndexMode buildIndexMode)
Parameters
shapePathFilename
stringThis parameter is the shape file name and path that you want to build an index for.
indexPathFilename
stringThis parameter specifies the index file name.
buildIndexMode
BuildIndexModeThis parameter determines what will happen if there is an existing index file.
Remarks
This overload builds an index file with the same name as the shape file with only the extension being different. You can also specify if you want to rebuild an existing index file.
BuildIndexFile(string, string, ProjectionConverter, string, string, BuildIndexMode)
This method builds a spatial index only for those features that satisfy a regular expression, based on a passed-in projection.
public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, ProjectionConverter projectionConverter, string columnName, string regularExpression, BuildIndexMode buildIndexMode)
Parameters
shapePathFilename
stringThis parameter specifies the Shape File for which to build the index.
indexPathFilename
stringThis parameter determines the target index path filename.
projectionConverter
ProjectionConverterThis parameter determines the projection that will be used to build the index against those features that satisfy the regular expression.
columnName
stringThis parameter determines the column name whose values will be tested against the regular expression.
regularExpression
stringThis parameter represents the regular expression to test against each feature for inclusion in the index.
buildIndexMode
BuildIndexModeThis parameter determines whether an index file will be rebuilt if it already exists.
Remarks
This overload allows you to pass in a Shape File and specify the index filename to use.
BuildIndexFile(string, string, ProjectionConverter, string, string, BuildIndexMode, Encoding)
This method builds a spatial index only for those features that satisfy a regular expression, based on a passed-in projection.
public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, ProjectionConverter projectionConverter, string columnName, string regularExpression, BuildIndexMode buildIndexMode, Encoding encoding)
Parameters
shapePathFilename
stringThis parameter specifies the Shape File for which to build the index.
indexPathFilename
stringThis parameter determines the target index path filename.
projectionConverter
ProjectionConverterThis parameter determines the projection that will be used to build the index against those features that satisfy the regular expression.
columnName
stringThis parameter determines the column name whose values will be tested against the regular expression.
regularExpression
stringThis parameter represents the regular expression to test against each feature for inclusion in the index.
buildIndexMode
BuildIndexModeThis parameter determines whether an index file will be rebuilt if it already exists.
encoding
EncodingThis parameter specifies the encoding information used in the source DBF file.
Remarks
This overload allows you to pass in a Shape File and specify the index filename to use.
BuildIndexFile(string, BuildIndexMode)
This method builds a spatial index for the layer.
public static void BuildIndexFile(string pathFilename, BuildIndexMode rebuildExistingIndexMode)
Parameters
pathFilename
stringThis parameter is the matching pattern that defines which Shape Files to include.
rebuildExistingIndexMode
BuildIndexModeThis parameter determines whether an index file will be rebuilt if it already exists.
Remarks
This overload allows you to pass in the Shape File and determines if we rebuild an index file that already exists.
BuildRecordIdColumn(string, string, BuildRecordIdMode)
Static API used to build RecordId. The Id will start from 0.
public static void BuildRecordIdColumn(string shapeFilename, string fieldname, BuildRecordIdMode rebuildNeeded)
Parameters
shapeFilename
stringThe name of the target ShapeFile on which to base the newly built RecordId.
fieldname
stringThe field name for the RecordId.
rebuildNeeded
BuildRecordIdModeThe RecordId build mode.
BuildRecordIdColumn(string, string, BuildRecordIdMode, int)
Static API used to build RecordId from the specified starting Id number.
public static void BuildRecordIdColumn(string shapeFilename, string fieldname, BuildRecordIdMode rebuildNeeded, int startNumber)
Parameters
shapeFilename
stringThe name of the target ShapeFile on which to base the newly built RecordId.
fieldname
stringThe field name for the RecordId.
rebuildNeeded
BuildRecordIdModeThe RecordId build mode.
startNumber
intThe starting Id number of the RecordId.
BuildRecordIdColumn(string, string, BuildRecordIdMode, int, Encoding)
Static API used to build RecordId from the specified starting Id number.
public static void BuildRecordIdColumn(string shapeFilename, string fieldname, BuildRecordIdMode rebuildNeeded, int startNumber, Encoding encoding)
Parameters
shapeFilename
stringThe name of the target ShapeFile on which to base the newly built RecordId.
fieldname
stringThe field name for the RecordId.
rebuildNeeded
BuildRecordIdModeThe RecordId build mode.
startNumber
intThe starting Id number of the RecordId.
encoding
EncodingThis parameter specifies the encoding information in the DBF.
CloneDeepCore()
protected override Layer CloneDeepCore()
Returns
CloneShapeFileStructure(string, string)
Clone the structure from the source ShapeFile to the target ShapeFile. After cloning the structure, the target ShapeFile will have the same type and the same DBF columns as the source ShapeFile, but without any records in it.
public static void CloneShapeFileStructure(string sourceShapePathFilename, string targetShapePathFilename)
Parameters
sourceShapePathFilename
stringThe source Shape File to be cloned.
targetShapePathFilename
stringThe target Shape File, which will have the same structure as the source Shape File after cloning operation is complete.
CloneShapeFileStructure(string, string, OverwriteMode)
Clone the structure from the source ShapeFile to the target ShapeFile. After cloning the structure, the target ShapeFile will have the same type and the same DBF columns as the source ShapeFile, but without any records in it.
public static void CloneShapeFileStructure(string sourceShapePathFilename, string targetShapePathFilename, OverwriteMode overwriteMode)
Parameters
sourceShapePathFilename
stringThe source Shape File to be cloned.
targetShapePathFilename
stringThe target Shape File, which will have the same structure as the source Shape File after cloning operation is complete.
overwriteMode
OverwriteModeThis parameter specifies the overwrite mode when the target ShapeFile already exists.
Remarks
An exception will be thown when the target ShapeFile does not exist and the overwrite mode is set to DoNotOverwrite.
CloneShapeFileStructure(string, string, OverwriteMode, Encoding)
Clone the structure from the source ShapeFile to the target ShapeFile. After cloning the structure, the target ShapeFile will have the same type and the same DBF columns as the source ShapeFile, but without any records in it.
public static void CloneShapeFileStructure(string sourceShapePathFilename, string targetShapePathFilename, OverwriteMode overwriteMode, Encoding encoding)
Parameters
sourceShapePathFilename
stringThe source Shape File to be cloned.
targetShapePathFilename
stringThe target Shape File, which will have the same structure as the source Shape File after cloning operation is complete.
overwriteMode
OverwriteModeThis parameter specifies the overwrite mode when the target ShapeFile already exists.
encoding
EncodingThis parameter specifies the encoding information in the source Shape File.
Remarks
An exception will be thown when the target ShapeFile does not exist and the overwrite mode is set to DoNotOverwrite.
CreateShapeFile(ShapeFileType, string, IEnumerable<DbfColumn>)
Static API to create a new Shape File.
public static void CreateShapeFile(ShapeFileType shapeType, string pathFilename, IEnumerable<DbfColumn> databaseColumns)
Parameters
shapeType
ShapeFileTypeThis parameter specifies the the Shape File type for the target Shape File.
pathFilename
stringThis parameter specifies the Shape filename for the target Shape File.
databaseColumns
IEnumerable<DbfColumn>This parameter specifies the DBF column information for the target Shape File.
CreateShapeFile(ShapeFileType, string, IEnumerable<DbfColumn>, Encoding)
Static API to create a new Shape File.
public static void CreateShapeFile(ShapeFileType shapeType, string pathFilename, IEnumerable<DbfColumn> databaseColumns, Encoding encoding)
Parameters
shapeType
ShapeFileTypeThis parameter specifies the the Shape File type for the target Shape File.
pathFilename
stringThis parameter specifies the Shape filename for the target Shape File.
databaseColumns
IEnumerable<DbfColumn>This parameter specifies the DBF column information for the target Shape File.
encoding
EncodingThis parameter specifies the DBF encoding infromation for the target Shape File.
CreateShapeFile(ShapeFileType, string, IEnumerable<DbfColumn>, Encoding, OverwriteMode)
Static API to create a new Shape File.
public static void CreateShapeFile(ShapeFileType shapeType, string pathFilename, IEnumerable<DbfColumn> databaseColumns, Encoding encoding, OverwriteMode overwriteMode)
Parameters
shapeType
ShapeFileTypeThis parameter specifies the the Shape File type for the target Shape File.
pathFilename
stringThis parameter specifies the Shape filename for the target Shape File.
databaseColumns
IEnumerable<DbfColumn>This parameter specifies the DBF column information for the target Shape File.
encoding
EncodingThis parameter specifies the DBF encoding infromation for the target Shape File.
overwriteMode
OverwriteModeThis parameter specifies the override mode when the target Shape File exists.
Remarks
An exception will be thown when the target Shape File does not exist while the overwrite mode is set to DoNotOverwrite.
DrawCore(GeoCanvas, Collection<SimpleCandidate>)
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
Parameters
canvas
GeoCanvaslabelsInAllLayers
Collection<SimpleCandidate>
GetShapeFileType()
Get the Shape File type for the Shape File FeatureSource.
public ShapeFileType GetShapeFileType()
Returns
- ShapeFileType
The ShapeFileType for the ShapeFile FeatureSource.
GetValidColumnNames(IEnumerable<string>)
public static Collection<string> GetValidColumnNames(IEnumerable<string> columnNames)
Parameters
columnNames
IEnumerable<string>
Returns
GetValidColumnNames(IEnumerable<string>, Encoding)
public static Collection<string> GetValidColumnNames(IEnumerable<string> columnNames, Encoding encoding)
Parameters
columnNames
IEnumerable<string>encoding
Encoding
Returns
GetValidColumns(IEnumerable<DbfColumn>)
public static Collection<DbfColumn> GetValidColumns(IEnumerable<DbfColumn> columns)
Parameters
columns
IEnumerable<DbfColumn>
Returns
GetValidColumns(IEnumerable<DbfColumn>, Encoding)
public static Collection<DbfColumn> GetValidColumns(IEnumerable<DbfColumn> columns, Encoding encoding)
Parameters
columns
IEnumerable<DbfColumn>encoding
Encoding
Returns
Rebuild(string)
This method rebuilds the SHP, SHX, DBF, IDX and IDS files for the given shape file.
public static void Rebuild(string shapePathFilename)
Parameters
shapePathFilename
stringThis parameter is the shape file you want to rebuild.
Remarks
This method rebuilds the SHP, SHX, DBF, IDX and IDS files for the given shape
file. When we do editing we have optimized the updates so that we do not need to
rebuild the entire shape file. This leads to the shape file being out of order which
may cause it not to open in other tools. One optimization is if you update a record
instead of rebuilding a new shape file we mark the old record as null and add the
edited record at the end of the shape file. This greatly increases the speed of
committing shape file changes but will over time unorder the shape file. In addition we
do a delete the DBF file will simply mark the record deleted and not compact the space.
Rebuilding the shape file will correctly order the SPX and SHX along with compacting
the DBF file and rebuild any index with the same any of the shape file if it
exists.
Note that if you have build custom index files where the name of the index differs from
that of the shape file you will need to rebuild those manually using the BuildIndex
methods.
Rebuild(string, ShapeFileSortingMode, int)
public static void Rebuild(string shapePathFilename, ShapeFileSortingMode sortingMode, int sridForSorting)
Parameters
shapePathFilename
stringsortingMode
ShapeFileSortingModesridForSorting
int
Reproject(string, string, ProjectionConverter, OverwriteMode)
This API provide a easy way to project features in a shape file into another projection and save it to shape file.
public static void Reproject(string sourceShapeFile, string targetShapeFile, ProjectionConverter projectionConverter, OverwriteMode overwriteMode)
Parameters
sourceShapeFile
stringThis parameter specifies the source shape file to be projected.
targetShapeFile
stringThis parameter specifies the target shape file to be saved for the projected features.
projectionConverter
ProjectionConverterThis parameter is the projection to project the source shape file to target shape file. The source Shape file should be in the FromProjection of the Projection prameter, and the targetShapeFile will be in the ToProjection of the Projection.
overwriteMode
OverwriteModeThis parameter specifies the override mode when the target shape file exists.
Validate()
This method checks all features in a shapefile is supported by Mapsuite or not.
public Dictionary<string, string> Validate()
Returns
- Dictionary<string, string>
A dictionary which contains all the unsupported features. The key is the Indexs which failed to pass the check, the value contains the reason for its failure.
Events
StreamLoading
This event allows you to pass in your own stream to represent the files.
public event EventHandler<StreamLoadingEventArgs> StreamLoading
Event Type
Remarks
If you choose you can pass in your own stream to represent the file. The stream can come from a variety of places such as isolated storage, a compressed file, and encrypted stream. When the Image is finished with the stream it will dispose of it so be sure to keep this in mind when passing the stream in. If you do not pass in a alternate stream the class will attempt to load the file from the file system using the PathFilename property.