Table of Contents

Class ShapeFileFeatureLayer

Namespace
ThinkGeo.Core
Assembly
ThinkGeo.Core.dll

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 string

This 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 string

This parameter is the Shape File path and filename.

readWriteMode FileAccess

This 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 string

This parameter is the Shape File path and filename.

indexPathFilename string

This 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 string

This parameter is the Shape File path and filename.

indexPathFilename string

This parameter is the index file path and filename.

readWriteMode FileAccess

This 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 string

This parameter is the Shape File path and filename.

indexPathFilename string

This parameter is the index file path and filename.

readWriteMode FileAccess

This parameter specifies whether the file will be opened in read-only or read/write mode.

encoding Encoding

This 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

Encoding

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

bool

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

int

ReadWriteMode

public FileAccess ReadWriteMode { get; set; }

Property Value

FileAccess

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

bool

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

int

UsingSpatialIndex

This property gets whether the Shape File FeatureSource has an index or not.

public bool UsingSpatialIndex { get; }

Property Value

bool

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 string

This 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 string

This parameter determines the target index path filename.

buildIndexMode BuildIndexMode

This 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 string

This parameter specifies the target index path and filename.

projectionConverter ProjectionConverter

This 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 string

This parameter determines the target index path filename.

projectionConverter ProjectionConverter

This parameter determines the Projection to build index against those features.

buildIndexMode BuildIndexMode

This 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 string

The 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 string

This parameter specifies the Shape File for which to build the index.

indexPathFilename string

This parameter determines the target index path filename.

columnName string

This parameter determines the column name whose values will be tested against the regular expression.

regularExpression string

This parameter represents the regular expression to test against each feature for inclusion in the index.

buildIndexMode BuildIndexMode

This 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 string

This parameter is the shape file name and path that you want to build an index for.

indexPathFilename string

This parameter specifies the index file name.

buildIndexMode BuildIndexMode

This 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 string

This parameter specifies the Shape File for which to build the index.

indexPathFilename string

This parameter determines the target index path filename.

projectionConverter ProjectionConverter

This parameter determines the projection that will be used to build the index against those features that satisfy the regular expression.

columnName string

This parameter determines the column name whose values will be tested against the regular expression.

regularExpression string

This parameter represents the regular expression to test against each feature for inclusion in the index.

buildIndexMode BuildIndexMode

This 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 string

This parameter specifies the Shape File for which to build the index.

indexPathFilename string

This parameter determines the target index path filename.

projectionConverter ProjectionConverter

This parameter determines the projection that will be used to build the index against those features that satisfy the regular expression.

columnName string

This parameter determines the column name whose values will be tested against the regular expression.

regularExpression string

This parameter represents the regular expression to test against each feature for inclusion in the index.

buildIndexMode BuildIndexMode

This parameter determines whether an index file will be rebuilt if it already exists.

encoding Encoding

This 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 string

This parameter is the matching pattern that defines which Shape Files to include.

rebuildExistingIndexMode BuildIndexMode

This 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 string

The name of the target ShapeFile on which to base the newly built RecordId.

fieldname string

The field name for the RecordId.

rebuildNeeded BuildRecordIdMode

The 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 string

The name of the target ShapeFile on which to base the newly built RecordId.

fieldname string

The field name for the RecordId.

rebuildNeeded BuildRecordIdMode

The RecordId build mode.

startNumber int

The 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 string

The name of the target ShapeFile on which to base the newly built RecordId.

fieldname string

The field name for the RecordId.

rebuildNeeded BuildRecordIdMode

The RecordId build mode.

startNumber int

The starting Id number of the RecordId.

encoding Encoding

This parameter specifies the encoding information in the DBF.

CloneDeepCore()

protected override Layer CloneDeepCore()

Returns

Layer

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 string

The source Shape File to be cloned.

targetShapePathFilename string

The 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 string

The source Shape File to be cloned.

targetShapePathFilename string

The target Shape File, which will have the same structure as the source Shape File after cloning operation is complete.

overwriteMode OverwriteMode

This 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 string

The source Shape File to be cloned.

targetShapePathFilename string

The target Shape File, which will have the same structure as the source Shape File after cloning operation is complete.

overwriteMode OverwriteMode

This parameter specifies the overwrite mode when the target ShapeFile already exists.

encoding Encoding

This 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 ShapeFileType

This parameter specifies the the Shape File type for the target Shape File.

pathFilename string

This 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 ShapeFileType

This parameter specifies the the Shape File type for the target Shape File.

pathFilename string

This 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 Encoding

This 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 ShapeFileType

This parameter specifies the the Shape File type for the target Shape File.

pathFilename string

This 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 Encoding

This parameter specifies the DBF encoding infromation for the target Shape File.

overwriteMode OverwriteMode

This 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 GeoCanvas
labelsInAllLayers 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

Collection<string>

GetValidColumnNames(IEnumerable<string>, Encoding)

public static Collection<string> GetValidColumnNames(IEnumerable<string> columnNames, Encoding encoding)

Parameters

columnNames IEnumerable<string>
encoding Encoding

Returns

Collection<string>

GetValidColumns(IEnumerable<DbfColumn>)

public static Collection<DbfColumn> GetValidColumns(IEnumerable<DbfColumn> columns)

Parameters

columns IEnumerable<DbfColumn>

Returns

Collection<DbfColumn>

GetValidColumns(IEnumerable<DbfColumn>, Encoding)

public static Collection<DbfColumn> GetValidColumns(IEnumerable<DbfColumn> columns, Encoding encoding)

Parameters

columns IEnumerable<DbfColumn>
encoding Encoding

Returns

Collection<DbfColumn>

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 string

This 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 string
sortingMode ShapeFileSortingMode
sridForSorting 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 string

This parameter specifies the source shape file to be projected.

targetShapeFile string

This parameter specifies the target shape file to be saved for the projected features.

projectionConverter ProjectionConverter

This 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 OverwriteMode

This 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

EventHandler<StreamLoadingEventArgs>

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.