Skip to content

< Back


ShapeFileFeatureSource

Namespace: ThinkGeo.Core

This class represents a FeatureSource backed by ESRI a Shape File.

public class ShapeFileFeatureSource : FeatureSource

Inheritance ObjectFeatureSourceShapeFileFeatureSource

Remarks:

None

Properties

ShapePathFilename

This property returns the path and file of the shape file you want to use.

public string ShapePathFilename { get; set; }

Property Value

String

Exceptions

ArgumentException
Setting an invalid FilePathName structure will thrown an ArgumentException.

Remarks:

When you specify the path and file name it should be in the correct format as such however the file does not need to exists on the file system. This is to allow us to accept streams supplied by the developer at runtime. If you choose to provide a file that exists then we will attempt to use it. If we cannot find it then we will raise the SteamLoading event and allow you to supply the stream. For example you can pass in "C:\NotARealPath\File1.shp" which does not exists on the file system. When we raise the event for you to supply a stream we will pass to you the path and file name for you to differentiate the files.

IndexPathFilename

This property gets and sets the path and file of the index you want to use.

public string IndexPathFilename { get; set; }

Property Value

String

Remarks:

When you specify the path and file name it should be in the correct format as such however the file does not need to exists on the file system. This is to allow us to accept streams supplied by the developer at runtime. If you choose to provide a file that exists then we will attempt to use it. If we cannot find it then we will raise the SteamLoading event and allow you to supply the stream. For example you can pass in "C:\NotARealPath\File1.idx" which does not exists on the file system. When we raise the event for you to supply a stream we will pass to you the path and file name for you to differentiate the files.

ReadWriteMode

public FileAccess ReadWriteMode { get; set; }

Property Value

FileAccess

IsEditable

This property returns if the FeatureSource allows edits or is read only.

public bool IsEditable { get; }

Property Value

Boolean

Remarks:

This property is useful to check if a specific FeatureSource accepts editing. If you call the BeginTransaction and this property is false then an exception will be raised.

For developers who are creating or extending a FeatureSource it is expected that you override this virtual method if the new FeatureSource you are creating allows edits. By default the decimalDegreesValue if false meaning that if you want to allow edits you must override this method and return true.

UsingSpatialIndex

This property gets the shape file feature source with index or not.

public bool UsingSpatialIndex { get; }

Property Value

Boolean

RequireIndex

This property gets and sets the requirement of index when reading data. The default value is true.

public bool RequireIndex { get; set; }

Property Value

Boolean

Encoding

This property get and set the encoding information for the dbf.

public Encoding Encoding { get; set; }

Property Value

Encoding

SimplificationAreaInPixel

public int SimplificationAreaInPixel { get; set; }

Property Value

Int32

SimplifiedAreas

public Collection<RectangleShape> SimplifiedAreas { get; }

Property Value

Collection<RectangleShape>

Id

public string Id { get; }

Property Value

String

CanExecuteSqlQuery

This property specifies whether the FeatureSource can excute a SQL query or not. If it is false, then it will throw exception when these APIs are calleds: ExecuteScalar, ExecuteNonQuery, ExecuteQuery

public bool CanExecuteSqlQuery { get; }

Property Value

Boolean

Remarks:

The default implementation is false.

IsOpen

This property returns true if the FeatureSource is open and false if it is not.

public bool IsOpen { get; }

Property Value

Boolean

Remarks:

Various methods on the FeatureSource require that it be in an open state. If one of those methods is called when the state is not open, then the method will throw an exception. To enter the open state, you must call the FeatureSource's Open method. The method will raise an exception if the current FeatureSource is already open.

Projection

public Projection Projection { get; protected set; }

Property Value

Projection

CanModifyColumnStructure

public bool CanModifyColumnStructure { get; }

Property Value

Boolean

IsInTransaction

This property returns true if the FeatureSource is in a transaction and false if it is not.

public bool IsInTransaction { get; }

Property Value

Boolean

Remarks:

To enter a transaction, you must first call the BeginTransaction method of the FeatureSource. It is possible that some FeatureSources are read-only and do not allow edits. To end a transaction, you must either call CommitTransaction or RollbackTransaction.

IsTransactionLive

This property returns true if the features currently modified in a transaction are expected to reflect their state when calling other methods on the FeatureSource, such as spatial queries.

public bool IsTransactionLive { get; set; }

Property Value

Boolean

Remarks:

The live transaction concept means that all of the modifications you perform during a transaction are live from the standpoint of the querying methods on the object.

As an example, imagine that you have a FeatureSource that has 10 records in it. Next, you begin a transaction and then call GetAllFeatures. The result would be 10 records. After that, you call a delete on one of the records and call the GetAllFeatures again. This time you only get nine records, even though the transaction has not yet been committed. In the same sense, you could have added a new record or modified an existing one and those changes would be considered live, though not committed.

In the case where you modify records -- such as expanding the size of a polygon -- those changes are reflected as well. For example, you expand a polygon by doubling its size and then do a spatial query that would not normally return the smaller record, but instead would return the larger records. In this case, the larger records are returned. You can set this property to be false, as well; in which case, all of the spatially related methods would ignore anything that is currently in the transaction buffer waiting to be committed. In such a case, only after committing the transaction would the FeatureSource reflect the changes.

ProjectionConverter

This property holds the projection object that is used within the FeatureSource to ensure that features inside of the FeatureSource are projected.

public ProjectionConverter ProjectionConverter { get; set; }

Property Value

ProjectionConverter

Remarks:

By default this property is null, meaning that the data being passed back from any methods on the FeatureSource will be in the coordinate system of the raw data. When you specify a projection object in the property, all incoming and outgoing method calls will subject the features to projection.

For example, if the spatial database you are using has all of its data stored in decimal degrees, but you want to see the data in UTM, you would create a projection object that goes from decimal degrees to UTM and set that as the projection. With this one property set, we will ensure that it will seem to you the developer that all of the data in the FeatureSource is in UTM. That means every spatial query will return UTM projected shapes. You can even pass in UTM shapes for the parameters. Internally, we will ensure that the shapes are converted to and from the projection without any intervention on the developer's part.

In fact, even when you override virtual or abstract core methods in the FeatureSource, you will not need to know about projections at all. Simply work with the data in its native coordinate system. We will handle all of the projection at the high level method.

GeoCache

The cache system.

public FeatureCache GeoCache { get; set; }

Property Value

FeatureCache

Remarks:

You must set IsActive to true for the Cache system. The default is not active.

FeatureIdsToExclude

A collection of strings representing record id of features not to get in the Layer.

public Collection<string> FeatureIdsToExclude { get; }

Property Value

Collection<String>

Remarks:

This string collection is a handy place to specify what records not to get from the source. Suppose you have a shape file of roads and you want to hide the roads within a particular rectangle, simply execute GetFeaturesInsideBoundingBox() and add the id of the return features to the collection and forget about them. Since you can set this by Layer it makes is easy to determine what to and what not to.

TransactionBuffer

The TransactionBuffer used in the Transaction System.

public TransactionBuffer TransactionBuffer { get; set; }

Property Value

TransactionBuffer

Remarks:


The Transaction System

The transaction system of a FeatureSource sits on top of the inherited implementation of any specific source, such as Oracle Spatial or Shape files. In this way, it functions the same way for every FeatureSource. You start by calling BeginTransaction. This allocates a collection of in-memory change buffers that are used to store changes until you commit the transaction. So, for example, when you call the Add, Delete or Update method, the changes to the feature are stored in memory only. If for any reason you choose to abandon the transaction, you can call RollbackTransaction at any time and the in-memory buffer will be deleted and the changes will be lost. When you are ready to commit the transaction, you call CommitTransaction and the collections of changes are then passed to the CommitTransactionCore method and the implementer of the specific FeatureSource is responsible for integrating your changes into the underlying FeatureSource. By default the IsLiveTransaction property is set to false, which means that until you commit the changes, the FeatureSource API will not reflect any changes that are in the temporary editing buffer.

In the case where the IsLiveTransaction is set to true, then things function slightly differently. The live transaction concept means that all of the modifications you perform during a transaction are live from the standpoint of the querying methods on the object.

As an example, imagine that you have a FeatureSource that has 10 records in it. Next, you begin a transaction and then call GetAllFeatures. The result would be 10 records. After that, you call a delete on one of the records and call the GetAllFeatures again. This time you only get nine records, even though the transaction has not yet been committed. In the same sense, you could have added a new record or modified an existing one and those changes would be considered live, though not committed.

In the case where you modify records -- such as expanding the size of a polygon -- those changes are reflected as well. For example, you expand a polygon by doubling its size and then do a spatial query that would not normally return the smaller record, but instead would return the larger records. In this case, the larger records are returned. You can set this property to be false, as well; in which case, all of the spatially related methods would ignore anything that is currently in the transaction buffer waiting to be committed. In such a case, only after committing the transaction would the FeatureSource reflect the changes.

MaxRecordsToDraw

public int MaxRecordsToDraw { get; set; }

Property Value

Int32

Constructors

ShapeFileFeatureSource()

This is the class constructor.

public ShapeFileFeatureSource()

Remarks:

None

ShapeFileFeatureSource(String)

This is the class constructor.

public ShapeFileFeatureSource(string shapePathFilename)

Parameters

shapePathFilename String
This parameter represents the path and file name to the .shp file.

Remarks:

None

ShapeFileFeatureSource(String, FileAccess)

This is the class constructor.

public ShapeFileFeatureSource(string shapePathFilename, FileAccess readWriteMode)

Parameters

shapePathFilename String
This parameter represents the path and file name to the .shp file.

readWriteMode FileAccess
This parameters represents the mode that we will open the file in.

Remarks:

None

ShapeFileFeatureSource(String, String)

This is a constructor for the class.

public ShapeFileFeatureSource(string shapePathFilename, string indexPathFilename)

Parameters

shapePathFilename String
This parameter is the shape file name you want to load.

indexPathFilename String
This parameter is the index file you want to use.

Remarks:

This constructor allows you to specify the shape file and the index file to use. In some cases you may want to build custom index files or want the index file to have a different name that the shape file.

ShapeFileFeatureSource(String, String, FileAccess)

This is a constructor for the class.

public ShapeFileFeatureSource(string shapePathFilename, string indexPathFilename, FileAccess readWriteMode)

Parameters

shapePathFilename String
This parameter is the shape file name you want to load.

indexPathFilename String
This parameter is the index file you want to use.

readWriteMode FileAccess

        This parameter reflects if you want to open shape file and index for read or read
        write mode.

Remarks:

This constructor allows you to specify the shape file and the index file to use. In some cases you may want to build custom index files or want the index file to have a different name that the shape file. It also allows you to specify is you want to open the files for read or read and write. You will need to open the file for read and write if you plan on doing any editing to the files.

ShapeFileFeatureSource(String, String, FileAccess, Encoding)

This is a constructor for the class.

public ShapeFileFeatureSource(string shapePathFilename, string indexPathFilename, FileAccess readWriteMode, Encoding encoding)

Parameters

shapePathFilename String
This parameter is the shape file name you want to load.

indexPathFilename String
This parameter is the index file you want to use.

readWriteMode FileAccess

         This parameter reflects if you want to open shape file and index for read or read
         write mode.

encoding Encoding
The encoding to read and write the dbf file.

Remarks:

This constructor allows you to specify the shape file and the index file to use. In some cases you may want to build custom index files or want the index file to have a different name that the shape file. It also allows you to specify is you want to open the files for read or read and write. You will need to open the file for read and write if you plan on doing any editing to the files.

Methods

GetAllFeaturesCore(IEnumerable<String>)

This method returns all of the InternalFeatures in the FeatureSource.

protected Collection<Feature> GetAllFeaturesCore(IEnumerable<string> returningColumnNames)

Parameters

returningColumnNames IEnumerable<String>

        This parameter allows you to select the field names of the column data you wish
        to return with each Feature.

Returns

Collection<Feature>

        The return decimalDegreesValue is a collection of all of the InternalFeatures in the
        FeatureSource.

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which has not been opened it will throw an InvalidOperationException.

Remarks:

This method returns all of the InternalFeatures in the FeatureSource. You will not need to consider anything about pending transactions as this will be handled in the non Core version of the method.

The main purpose of this method is to be the anchor of all of our default virtual implementations within this class. We wanted as the framework developers to provide you the user with as much default virtual implementation as possible. To do this we needed a way to get access to all of the features. For example, we want to create a default implementation for finding all of the InternalFeatures in a bounding box. Because this is an abstract class we do not know the specifics of the underlying data or how its spatial indexes work. What we do know is that if we get all the records then we can brute force the answer. In this way if you inherited form this class and only implemented this one method we can provide default implementations for virtually every other API.

While this is nice for you the developer if you decide to create your own FeatureSource it comes with a price. The price is that it is very inefficient. In the case we just discussed about finding all of the InternalFeatures in a bounding box we would not want to look at every record to fulfil this method. Instead we would want to override the GetFeaturesInsideBoundingBoxCore and implement specific code that would be fast. For example in Oracle Spatial there is a specific SQL statement to do this operation very quickly. The same holds true with other specific FeatureSource examples.

Most default implementations in the FeatureSource call the GetFeaturesInsideBoundingBoxCore which by default calls the GetAllFeaturesCore. It is our advice that if you create your own FeatureSource that you ALWAYS override the GetFeatureInsideBoundingBox. It will ensure that nearly every other API will operate efficiently. Please see the specific API to determine what method it uses.

GetFeatureIdsCore()

protected Collection<string> GetFeatureIdsCore()

Returns

Collection<String>

GetColumnsCore()

This method returns the columns available for the FeatureSource.

protected Collection<FeatureSourceColumn> GetColumnsCore()

Returns

Collection<FeatureSourceColumn>
This method returns the columns available for the FeatureSource.

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which has not been opened it will throw an InvalidOperationException.

Remarks:

As this is the abstract core version of the Columns method it is intended to be overridden in inherited version of the class. When overriding you will be responsible for getting a list of all of the columns supported by the FeatureSource. In this way the FeatureSource will know what columns are available and will remove any extra columns when making calls to other core methods. For example if you have a FeatureSource that has three columns of information and the user calls a method and requests four columns of information, something they can do with custom fields, we will first compare what they are asking for to the results of the GetColumnsCore. In this way we can strip out custom columns before calling other Core methods which are only responsible for returning data in the FeatureSource. For more information on custom fields you can see the documentation on the OnCustomFieldsFetch.

GetBoundingBoxCore()

This method returns the bounding box which encompasses all of the features in the FeatureSource.

protected RectangleShape GetBoundingBoxCore()

Returns

RectangleShape

        This method returns the bounding box which encompasses all of the features in the
        FeatureSource.

Exceptions

InvalidOperationException
If the operation is done under source closed state it will throw a InvalidOperationException.

Remarks:

This protected virtual method is called from the concreate public method GetBoundingBox. It does not take into account any transaction activity as this is the responsibility of the concreate public method GetBoundingBox. In this way as a developer if you choose to override this method you do not have to consider transaction at all.

The default implementation of GetBoundingBoxCore uses the GetAllRecordsCore method to calculate the bounding box of the FeatureSource. We strongly recommend that you provide your own implementation for this method that will be more efficient

If you do not override this method the means it gets the BoundingBox is by calling the GetAllFeatureCore method and deriving it from each feature. This is a very inefficient way to get the BoundingBox in most data sources. It is highly recommended that you override this method and replace it with a highly optimized version. For example in a ShapeFile the BoundingBox is in the main header of the file. Similarly if you are using Oracle Spatial you can execute a simple query to get the BoundingBox of all of the record without returning them. In these ways you can greatly improve the performance of this method.

GetBoundingBoxByIdCore(String)

protected RectangleShape GetBoundingBoxByIdCore(string id)

Parameters

id String

Returns

RectangleShape

GetFeaturesOutsideBoundingBoxCore(RectangleShape, IEnumerable<String>)

This method returns all of the InternalFeatures of this FeatureSource outside of the specified bounding box.

protected Collection<Feature> GetFeaturesOutsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable<string> returningColumnNames)

Parameters

boundingBox RectangleShape

        This parameter represents the bounding box you with to find InternalFeatures outside
        of.

returningColumnNames IEnumerable<String>

        This parameter allows you to select the field names of the column data you wish
        to return with each Feature.

Returns

Collection<Feature>

        This method returns all of the InternalFeatures of this FeatureSource outside of the
        specified bounding box.

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which has not been opened it will throw an InvalidOperationException.

Remarks:

This method returns all of the InternalFeatures of this FeatureSource outside of the specified bounding box. If you are in a transaction and that transaction is live then it will also take that into consideration.


The default implementation of GetFeaturesOutsideBoundingBoxCore uses the GetAllRecordsCore method to determine which InternalFeatures are outside of the bounding box. We strongly recommend that you provide your own implementation for this method that will be more efficient

GetFeaturesInsideBoundingBoxCore(RectangleShape, IEnumerable<String>)

This method returns all of the InternalFeatures of this FeatureSource inside of the specified bounding box.

protected Collection<Feature> GetFeaturesInsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable<string> returningColumnNames)

Parameters

boundingBox RectangleShape

        This parameter represents the bounding box you with to find InternalFeatures inside
        of.

returningColumnNames IEnumerable<String>

        This parameter allows you to select the field names of the column data you wish
        to return with each Feature.

Returns

Collection<Feature>

        The return decimalDegreesValue is a collection of all of the InternalFeatures that are inside of the
        bounding box.

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which has not been opened it will throw an InvalidOperationException.

Remarks:

This method returns all of the InternalFeatures of this FeatureSource inside of the specified bounding box. If you are overriding this method you will not need to consider anything about transactions as this is handled by the concreate version of this method.

The default implementation of GetFeaturesInsideBoundingBoxCore uses the GetAllRecordsCore method to determine which InternalFeatures are inside of the bounding box. We strongly recommend that you provide your own implementation for this method that will be more efficient. It is especially important for this method as many other default virtual methods use this for their calculations. We highly recommend when you override this method that you use any spatial indexes you have at your disposal to make this method as fast as possible.

GetFeaturesByColumnValueCore(String, String, IEnumerable<String>)

protected Collection<Feature> GetFeaturesByColumnValueCore(string columnName, string columnValue, IEnumerable<string> returningColumnNames)

Parameters

columnName String

columnValue String

returningColumnNames IEnumerable<String>

Returns

Collection<Feature>

GetFeatureIdsForDrawing(RectangleShape, Double, Double)

public Collection<string> GetFeatureIdsForDrawing(RectangleShape boundingBox, double screenWidth, double screenHeight)

Parameters

boundingBox RectangleShape

screenWidth Double

screenHeight Double

Returns

Collection<String>

GetFeatureIdsForDrawingCore(RectangleShape, Double, Double)

protected Collection<string> GetFeatureIdsForDrawingCore(RectangleShape boundingBox, double screenWidth, double screenHeight)

Parameters

boundingBox RectangleShape

screenWidth Double

screenHeight Double

Returns

Collection<String>

GetFeaturesForDrawingCore(RectangleShape, Double, Double, IEnumerable<String>)

This method returns the InternalFeatures that will be used for drawing.

protected Collection<Feature> GetFeaturesForDrawingCore(RectangleShape boundingBox, double screenWidth, double screenHeight, IEnumerable<string> returningColumnNames)

Parameters

boundingBox RectangleShape
This parameter is the bounding box of the InternalFeatures you want to draw.

screenWidth Double

        This parameter is the width in screen pixels of the view you will draw
        on.

screenHeight Double

        This parameter is the height in screen pixels of the view you will draw
        on.

returningColumnNames IEnumerable<String>

        This parameter allows you to select the field names of the column data you wish
        to return with each Feature.

Returns

Collection<Feature>
This method returns the InternalFeatures that will be used for drawing.

Remarks:

This method returns all of the InternalFeatures of this FeatureSource inside of the specified bounding box. If you are overriding this method you will not need to consider anything about transactions as this is handled by the concreate version of this method.

The default implementation of GetFeaturesForDrawingCore uses the GetFeaturesInsodeBoundingBoxCore with some optimizations based on the screen width and height. For example we can determine is a feature is going to draw in only one to four pixels and in that case we may not draw the entire feature but just a subset.

GetFeaturesByIdsCore(IEnumerable<String>, IEnumerable<String>)

This method returns a collection of InternalFeatures by providing a group of Ids.

protected Collection<Feature> GetFeaturesByIdsCore(IEnumerable<string> ids, IEnumerable<string> returningColumnNames)

Parameters

ids IEnumerable<String>

        This parameter represents the group of Ids which uniquely identified the InternalFeatures
        in the FeatureSource.

returningColumnNames IEnumerable<String>

        This parameter allows you to select the field names of the column data you wish
        to return with each Feature.

Returns

Collection<Feature>
This method returns a collection of InternalFeatures by providing a group of Ids.

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which has not been opened it will throw an InvalidOperationException.

Remarks:

This method returns a collection of InternalFeatures by providing a group of Ids. The internal implementation calls the GetAllFeaturesCore. Because of this if you want an efficient version of this method then we high suggest you override the GetFeaturesByIdsCore method and provide a fast way to find a group of InternalFeatures by their Id.

GetCountCore()

This method returns the count of the number of records in this FeatureSource.

protected long GetCountCore()

Returns

Int64

        This method returns the count of the number of records in this
        FeatureSource.

Exceptions

InvalidOperationException
If the operation is done under source closed state it will throw a InvalidOperationException.

Remarks:

This protected virtual method is called from the concreate public method GetCount. It does not take into account any transaction activity as this is the responsibility of the concreate public method GetCount. In this way as a developer if you choose to override this method you do not have to consider transaction at all.

The default implementation of GetCountCore uses the GetAllRecordsCore method to calculate how many records there are in the FeatureSource. We strongly recommend that you provide your own implementation for this method that will be more efficient

If you do not override this method the means it gets the count is by calling the GetAllFeatureCore method and counting each feature. This is a very inefficient way to get the count in most data sources. It is highly recommended that you override this method and replace it with a highly optimized version. For example in a ShapeFile the record count is in the main header of the file. Similarly if you are using Oracle Spatial you can execute a simple query to get the count of all of the record without returning them. In these ways you can greatly improve the performance of this method.

CanGetCountQuicklyCore()

protected bool CanGetCountQuicklyCore()

Returns

Boolean

GetFirstFeaturesWellKnownTypeCore()

protected WellKnownType GetFirstFeaturesWellKnownTypeCore()

Returns

WellKnownType

GetDistinctColumnValuesCore(String)

protected Collection<DistinctColumnValue> GetDistinctColumnValuesCore(string columnName)

Parameters

columnName String

Returns

Collection<DistinctColumnValue>

GetAllFeaturesCore(IEnumerable<String>, Int32, Int32)

protected Collection<Feature> GetAllFeaturesCore(IEnumerable<string> returningColumnNames, int startIndex, int takeCount)

Parameters

returningColumnNames IEnumerable<String>

startIndex Int32

takeCount Int32

Returns

Collection<Feature>

CloneDeepCore()

protected FeatureSource CloneDeepCore()

Returns

FeatureSource

OnStreamLoading(StreamLoadingEventArgs)

This method allows you to raise the StreamLoading event.

protected void OnStreamLoading(StreamLoadingEventArgs e)

Parameters

e StreamLoadingEventArgs

        This parameter represents the event arguments you want to raise the StreamLoading
        event with.

Remarks:

This method allows you to raise the StreamLoading event. Normally events are not accessible to derived classes so we exposed a way to raise the event is necessary through this protected method.

OnBuildingIndex(BuildingIndexShapeFileFeatureSourceEventArgs)

This method allows you to raise the BuildingIndex event.

protected static void OnBuildingIndex(BuildingIndexShapeFileFeatureSourceEventArgs e)

Parameters

e BuildingIndexShapeFileFeatureSourceEventArgs

        This parameter represents the event arguments you want to raise the BuildingIndex
        event with.

Remarks:

This method allows you to raise the BuildingIndex event. Normally events are not accessible to derived classes so we exposed a way to raise the event is necessary through this protected method.

OnRebuilding(RebuildingShapeFileFeatureSourceEventArgs)

protected static void OnRebuilding(RebuildingShapeFileFeatureSourceEventArgs e)

Parameters

e RebuildingShapeFileFeatureSourceEventArgs

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, Int32)

public static void Rebuild(string shapePathFilename, ShapeFileSortingMode sortingMode, int sridForSorting)

Parameters

shapePathFilename String

sortingMode ShapeFileSortingMode

sridForSorting Int32

BuildIndexFile(String)

This method build a spatial index for the shape file which increases access speed.

public static void BuildIndexFile(string shapePathFilename)

Parameters

shapePathFilename String

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

Remarks:

This overload builds an index file with the same name as the shape file with only the extension being different. It will not do a rebuild if there is an existing index.

BuildIndexFile(String, BuildIndexMode)

This method build a spatial index for the shape file which increases access speed.

public static void BuildIndexFile(string shapePathFilename, BuildIndexMode buildIndexMode)

Parameters

shapePathFilename String

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

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, BuildIndexMode)

This method build a spatial index for the shape file which increases access speed.

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, BuildIndexMode)

This method build a spatial index for the shape file which increases access speed.

public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, ProjectionConverter projectionConverter, 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.

projectionConverter ProjectionConverter
This parameter specifies the projection used to build index file.

buildIndexMode BuildIndexMode
This parameter determines what will happen if there is an existing index file.

Remarks:

This overload builds an index file with the specified index file name and only build Index for those records satisfied the regularExpression. You can also specify if you want to rebuild an existing index file.

BuildIndexFile(String, String, String, String, BuildIndexMode)

This method build a spatial index for the shape file which increases access speed.

public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, string columnName, string regularExpression, 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.

columnName String
The columnName to be used to get the value to match the regex expression.

regularExpression String
This parameter specifies the regex expression to filter out thoese records to build index with.

buildIndexMode BuildIndexMode
This parameter determines what will happen if there is an existing index file.

Remarks:

This overload builds an index file with the specified index file name and only build Index for those records satisfied the regularExpression. You can also specify if you want to rebuild an existing index file.

BuildIndexFile(String, String, ProjectionConverter, String, String, BuildIndexMode)

This method build a spatial index for the shape file which increases access speed.

public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, ProjectionConverter projectionConverter, string columnName, string regularExpression, 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.

projectionConverter ProjectionConverter
This parameter specifies the projection used to build index file.

columnName String
The columnName to be used to get the value to match the regex expression.

regularExpression String
This parameter specifies the regex expression to filter out thoese records to build index with.

buildIndexMode BuildIndexMode
This parameter determines what will happen if there is an existing index file.

Remarks:

This overload builds an index file with the specified index file name and only build Index for those records satisfied the regularExpression. You can also specify if you want to rebuild an existing index file.

BuildIndexFile(String, String, ProjectionConverter, String, String, BuildIndexMode, Encoding)

This method build a spatial index for the shape file which increases access speed.

public static void BuildIndexFile(string shapePathFilename, string indexPathFilename, ProjectionConverter projectionConverter, string columnName, string regularExpression, BuildIndexMode buildIndexMode, Encoding encoding)

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.

projectionConverter ProjectionConverter
This parameter specifies the projection used to build index file.

columnName String
The columnName to be used to get the value to match the regex expression.

regularExpression String
This parameter specifies the regular expression pattern to filter out thoese records to build index with.

buildIndexMode BuildIndexMode
This parameter determines what will happen if there is an existing index file.

encoding Encoding
This parameter determines the Enconding system used in the dbf, and this will be used if the dbf is encoded in a different encoding with default.

Remarks:

This overload builds an index file with the specified index file name and only build Index for those records satisfied the regularExpression. You can also specify if you want to rebuild an existing index file.

BuildIndexFile(IEnumerable<Feature>, String)

This method build a spatial index for a passed group of featurs which increases access speed.

public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename)

Parameters

features IEnumerable<Feature>
This parameter specifies the target group of features that you want to build an index for.

indexPathFilename String
This parameter specifies the index file name.

Remarks:

This overload builds an index file with the specified index file name for a group of passed in features.

BuildIndexFile(IEnumerable<Feature>, String, ProjectionConverter)

This method build a spatial index for a passed group of featurs using the specified projection which increases access speed.

public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename, ProjectionConverter projectionConverter)

Parameters

features IEnumerable<Feature>
This parameter specifies the target group of features that you want to build an index for.

indexPathFilename String
This parameter specifies the index file name.

projectionConverter ProjectionConverter
This parameter specifies the projection used to build index file.

Remarks:

This overload builds an index file with the specified index file name for a group of passed in features.

BuildIndexFile(IEnumerable<Feature>, String, BuildIndexMode)

This method build a spatial index for a passed group of featurs which increases access speed.

public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename, BuildIndexMode buildIndexMode)

Parameters

features IEnumerable<Feature>
This parameter specifies the target group of features 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 specified index file name for a group of passed in features.

BuildIndexFile(IEnumerable<Feature>, String, ProjectionConverter, BuildIndexMode)

This method build a spatial index for a passed group of featurs which increases access speed.

public static void BuildIndexFile(IEnumerable<Feature> features, string indexPathFilename, ProjectionConverter projectionConverter, BuildIndexMode buildIndexMode)

Parameters

features IEnumerable<Feature>
This parameter specifies the target group of features that you want to build an index for.

indexPathFilename String
This parameter specifies the index file name.

projectionConverter ProjectionConverter
This parameter specifies the projection used to build index file.

buildIndexMode BuildIndexMode
This parameter determines what will happen if there is an existing index file.

Remarks:

This overload builds an index file with the specified index file name for a group of passed in features.

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>

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>

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 file name 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 file name 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 file name 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:

Exception will be thown when the target shape file exist while the override mode is set to DoNotOverwrite.

GetDbfColumns()

Get the dbf columns out from the shape file featureSource.

public Collection<DbfColumn> GetDbfColumns()

Returns

Collection<DbfColumn>
The dbfColumns in the shape file FeatureSource.

CloneShapeFileStructure(String, String)

Clone out the structure from the source shape file to the target shape file. After cloning the structure, the targetShapeFile has the same type and same dbf columns with the source shape file 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 with same structure with the source one after the structure cloned.

CloneShapeFileStructure(String, String, OverwriteMode)

Clone out the structure from the source shape file to the target shape file. After cloning the structure, the targetShapeFile has the same type and same dbf columns with the source shape file 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 with same structure with the source one after the structure cloned.

overwriteMode OverwriteMode
This parameter specifies the override mode when the target shape file exists.

Remarks:

Exception will be thown when the target shape file not extis while the override mode is set to DoNotOverwrite.

CloneShapeFileStructure(String, String, OverwriteMode, Encoding)

Clone out the structure from the source shape file to the target shape file. After cloning the structure, the targetShapeFile has the same type and same dbf columns with the source shape file 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 with same structure with the source one after the structure cloned.

overwriteMode OverwriteMode
This parameter specifies the override mode when the target shape file exists.

encoding Encoding
This parameter specifies the encoding information in the source shape file.

Remarks:

Exception will be thown when the target shape file not extis while the override mode is set to DoNotOverwrite.

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.

AddColumnBoolean(String)

This method adds a new Boolean column to the DBF file associated with the shape file.

public void AddColumnBoolean(string columnName)

Parameters

columnName String
This parameter is the column you want to add.

Remarks:

None

AddColumnDate(String)

This method adds a new Date column to the DBF file associated with the shape file.

public void AddColumnDate(string columnName)

Parameters

columnName String
This parameter is the column you want to add.

Remarks:

None

AddColumnDouble(String, Int32, Int32)

This method adds a new Double column to the DBF file associated with the shape file.

public void AddColumnDouble(string columnName, int totalLength, int precisionLength)

Parameters

columnName String
This parameter is the column you want to add.

totalLength Int32

        This is the total length of the field including both the digits to the left and
        right of the decimal point.

precisionLength Int32

        This parameter specifies how many digits after the decimal point you need to
        support.

Remarks:

None

AddColumnInteger(String, Int32)

This method adds a new Integer column to the DBF file associated with the shape file.

public void AddColumnInteger(string columnName, int length)

Parameters

columnName String
This parameter is the column you want to add.

length Int32
This parameter specifies the length of the integer.

Remarks:

None

AddColumnMemo(String)

This method adds a new Memo column to the DBF file associated with the shape file.

public void AddColumnMemo(string columnName)

Parameters

columnName String
This parameter is the column you want to add.

Remarks:

This method adds a new Memo column to the DBF file associated with the shape file.

Internally the DBF holds an integer column that is a pointer to the data in the memo file. The pointer is measured in 512 byte chunks. Our default decimalDegreesValue for the size of the pointer column is 10 which means you can have 9,999,999,999 pointers to the 512 byte blocks. The ramification of this is that if you have more than this many records and each record uses more then 512 bytes as part of its memo then there will not be enough space for storage. If you have special needs for this please use the other overload that allows you to specify the number of digits you can use for the pointer.

AddColumnMemo(String, Int32)

This method adds a new Memo column to the DBF file associated with the shape file.

public void AddColumnMemo(string columnName, int memoValueLength)

Parameters

columnName String
This parameter is the column you want to add.

memoValueLength Int32

        This parameter is the number of digits you need to hold the pointers to the data
        in the memo file.

Remarks:

This method adds a new Memo column to the DBF file associated with the shape file.

Internally the DBF holds an integer column that is a pointer to the data in the memo file. The pointer is measured in 512 byte chunks. Our default decimalDegreesValue for the size of the pointer column is 10 which means you can have 9,999,999,999 pointers to the 512 byte blocks. The ramification of this is that if you have more than this many records and each record uses more than 512 bytes as part of its memo then there will not be enough space for storage. Conversely if you know you have few records then you can decrease this number. A good rule of thumb is to multiply the number of records by the number of 512 byte chunks you expect each record to use and then get the resulting number of digits resulting for the multiplication.

Example

You have 1,000,000 records and expect to have 4K, 8 chunks of 512 bytes, of memo data for each record. This means you will use multiple 1,000,000 * 8 which is 8,000,000 and then total the number of digits which in this case is 7. Assuming the numbers above a length of 7 will support your needs.

AddColumnString(String, Int32)

This method adds a new String column to the DBF file associated with the shape file.

public void AddColumnString(string columnName, int length)

Parameters

columnName String
This parameter is the column you want to add.

length Int32
This parameter is the number of characters that the string can hold.

Remarks:

This method adds a new String column to the DBF file associated with the shape file.

GetDataFromDbf(String, String)

This method gets data directly from the DBF file associated with the shape file.

public string GetDataFromDbf(string id, string columnName)

Parameters

id String
This parameter is the Id for the Feature you want to find.

columnName String
This parameter is the column name you want to return.

Returns

String

        This method gets data directly from the DBF file associated with the shape
        file.

Remarks:

This method gets data directly from the DBF file associated with the shape file. When you specify the Id and column name it will get the decimalDegreesValue from the DBF.

GetDataFromDbf(String)

This method gets data directly from the DBF file associated with the shape file.

public Dictionary<string, string> GetDataFromDbf(string id)

Parameters

id String
This parameter is the Id of the Feature you want.

Returns

Dictionary<String, String>

        This method returns a dictionary holding all of the values from the DBF for the
        Id you specified.

Remarks:

This method returns a dictionary holding all of the values from the DBF for the Id you specified. In the dictionary the key is the column name and values are the values from the DBF.

GetDataFromDbf(String, IEnumerable<String>)

This method gets data directly from the DBF file associated with the shape file.

public Dictionary<string, string> GetDataFromDbf(string id, IEnumerable<string> returningColumnNames)

Parameters

id String
This parameter is the Id of the Feature you want.

returningColumnNames IEnumerable<String>
This parameter is the returning columns specified for the returning data.

Returns

Dictionary<String, String>

        This method returns a dictionary holding all of the values from the DBF for the
        Id you specified.

Remarks:

This method returns a dictionary holding all of the values from the DBF for the Id you specified. In the dictionary the key is the column name and values are the values from the DBF.

GetDataFromDbf(String, ReturningColumnsType)

This method gets data directly from the DBF file associated with the shape file.

public Dictionary<string, string> GetDataFromDbf(string id, ReturningColumnsType returningColumnNamesType)

Parameters

id String
This parameter is the Id of the Feature you want.

returningColumnNamesType ReturningColumnsType
This parameter is the returningColumnType specified for the returning data.

Returns

Dictionary<String, String>

        This method returns a dictionary holding all of the values from the DBF for the
        Id you specified.

Remarks:

This method returns a dictionary holding all of the values from the DBF for the Id you specified. In the dictionary the key is the column name and values are the values from the DBF.

GetDataFromDbf(IEnumerable<String>)

This method gets data directly from the DBF file associated with the shape file.

public Collection<Dictionary<string, string>> GetDataFromDbf(IEnumerable<string> ids)

Parameters

ids IEnumerable<String>
This parameter is the Ids of the Features you want.

Returns

Collection<Dictionary<String, String>>

        This method returns a collection of dictionary holding all of the values from the DBF for the
        Ids you specified.

Remarks:

This method returns a collection of dictionary holding all of the values from the DBF for the Ids you specified. In the dictionary the key is the column name and values are the values from the DBF.

GetDataFromDbf(IEnumerable<String>, String)

This method gets data directly from the DBF file associated with the shape file.

public Collection<Dictionary<string, string>> GetDataFromDbf(IEnumerable<string> ids, string columnName)

Parameters

ids IEnumerable<String>
This parameter is the Ids of the Features you want.

columnName String
This parameter is the returning columnName of the Features you want.

Returns

Collection<Dictionary<String, String>>

        This method returns a collection of dictionary holding all of the values from the DBF for the
        Ids you specified.

Remarks:

This method returns a collection of dictionary holding all of the values from the DBF for the Ids you specified. In the dictionary the key is the column name and values are the values from the DBF.

GetDataFromDbf(IEnumerable<String>, IEnumerable<String>)

This method gets data directly from the DBF file associated with the shape file.

public Collection<Dictionary<string, string>> GetDataFromDbf(IEnumerable<string> ids, IEnumerable<string> columnNames)

Parameters

ids IEnumerable<String>
This parameter is the Ids of the Features you want.

columnNames IEnumerable<String>
This parameter is the returning columnNames of the Features you want.

Returns

Collection<Dictionary<String, String>>

        This method returns a collection of dictionary holding all of the values from the DBF for the
        Ids you specified.

Remarks:

This method returns a collection of dictionary holding all of the values from the DBF for the Ids you specified. In the dictionary the key is the column name and values are the values from the DBF.

GetDataFromDbf(IEnumerable<String>, ReturningColumnsType)

This method gets data directly from the DBF file associated with the shape file.

public Collection<Dictionary<string, string>> GetDataFromDbf(IEnumerable<string> ids, ReturningColumnsType returningColumnNamesType)

Parameters

ids IEnumerable<String>
This parameter is the Ids of the Features you want.

returningColumnNamesType ReturningColumnsType
This parameter is the returning column type of the Features you want.

Returns

Collection<Dictionary<String, String>>

        This method returns a collection of dictionary holding all of the values from the DBF for the
        Ids you specified.

Remarks:

This method returns a collection of dictionary holding all of the values from the DBF for the Ids you specified. In the dictionary the key is the column name and values are the values from the DBF.

UpdateDbfData(String, String, String)

This method updates data in the DBF file associated with the shape file.

public void UpdateDbfData(string id, string columnName, string value)

Parameters

id String
This parameter is the Id of the feature you want to update.

columnName String
This parameter is the column name you want to update.

value String
This parameter is the decimalDegreesValue you want to set.

Remarks:

None

UpdateDbfData(String, IEnumerable<String>, IEnumerable<String>)

This method updates data in the DBF file associated with the shape file.

public void UpdateDbfData(string id, IEnumerable<string> columnNames, IEnumerable<string> values)

Parameters

id String
This parameter is the Id of the feature you want to update.

columnNames IEnumerable<String>
This parameter is the columnNames you want to update.

values IEnumerable<String>
This parameter is the target values you want to set.

Remarks:

None

GetShapeFileType()

Get shape file type for the shape file featureSource.

public ShapeFileType GetShapeFileType()

Returns

ShapeFileType
The shapeFileType for the ShapeFileFeatureSource.

BuildRecordIdColumn(String, String, BuildRecordIdMode)

Static API used to build RecordId, the id should start from 0 by default.

public static void BuildRecordIdColumn(string shapeFilename, string fieldname, BuildRecordIdMode rebuildNeeded)

Parameters

shapeFilename String
The target shape file name to build record id based on.

fieldname String
The fild name for the record id.

rebuildNeeded BuildRecordIdMode
The build record id mode.

BuildRecordIdColumn(String, String, BuildRecordIdMode, Int32)

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 target shape file name to build record id based on.

fieldname String
The fild name for the record id.

rebuildNeeded BuildRecordIdMode
The build record id mode.

startNumber Int32
The starting id number of the record id.

BuildRecordIdColumn(String, String, BuildRecordIdMode, Int32, 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 target shape file name to build record id based on.

fieldname String
The fild name for the record id.

rebuildNeeded BuildRecordIdMode
The build record id mode.

startNumber Int32
The starting id number of the record id.

encoding Encoding
This parameter specified the encoding information in dbf.

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.

OpenCore()

This method opens the FeatureSource so that it is initialized and ready to use.

protected void OpenCore()

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which has already been opened it will throw an InvalidOperationException.

Remarks:

This protected virtual method is called from the concreate public method Open. The open method play an important role as it is responsible for initializing the FeatureSource. Most methods on the FeatureSource will throw an exception if the state of the FeatureSource is not opened. When the map draws each layer it will open the FeatureSource as one of its first steps, then after it is finished drawing with that layer it will close it. In this way we are sure to release all resources used by the FeatureSource.

When implementing this abstract method consider opening files for file based source, connecting to databases in the database based sources and so on. You will get a chance to close these in the Close method of the FeatureSource.

CloseCore()

This method opens the FeatureSource so that it is initialized and ready to use.

protected void CloseCore()

Remarks:

This protected virtual method is called from the concreate public method Close. The close method plays an important role in the life cycle of the FeatureSource. It may be called after drawing to release any memory and other resources that were allocated since the Open method was called.

It is recommended that if you override this method that you take the following things into account. This method may be called multiple times so we suggest you write the so that that a call to a closed FeatureSource is ignored and does not generate an error. We also suggest that in the close you free all resources that have been opened. Remember that the object will not be destroyed but will be re-opened possibly in the near future.

CommitTransactionCore(TransactionBuffer)

This method will commit the existing transaction to its underlying source of data.

protected TransactionResult CommitTransactionCore(TransactionBuffer transactions)

Parameters

transactions TransactionBuffer

        This parameter encapsulates all of the adds, edits and deleted that make up the
        transaction. You will use this data to write the changes to your underlying data
        source.

Returns

TransactionResult

        The return decimalDegreesValue of this method is a TransactionResult class which gives you the
        status of the transaction you just committed. It includes how many of the updates,
        adds, and deletes were successful and any error that were encountered during the
        committing of the transaction.

Exceptions

InvalidOperationException
In the event you attempt to call this method on a feature source which is not in transaction it will throw an InvalidOperationException.

Remarks:

This method will commit the existing transaction to its underlying source of data. It will pass back the results of how the commit went to include any error received. If you are implementing your own FeatureSource then this is one of the crucial methods you must create. It should be fairly straight forward that you will loop through the transaction buffer and add, edit or delete the InternalFeatures in your underlying data source. Remember to build and pass back the TransactionResult class so that users of your FeatureSource can respond to failures you may encounter committing the InternalFeatures. We will handle the end of the transaction and also the cleanup of the transaction buffer. Your task will be to commit the records and produce a TransactionResult return.

The Transaction System

The transaction system of a FeatureSource sits on top of the inherited implementation of any specific source such as Oracle Spatial or Shape files. In this way it functions the same way for every FeatureSource. You start by calling the BeginTransaction. This allocates a collection of in memory change buffers that are used to store changes until you commit the transaction. So for example when you call the Add, Delete or Update method the changes to the feature are stored in memory only. If for any reason you choose to abandon the transaction you can call RollbackTransaction at any time and the in memory buffer will be deleted and the changes will be lost. When you are ready to commit the transaction you call the CommitTransaction and the collections of changes are then passed to the CommitTransactionCore method and the implementer of the specific FeatureSource is responsible for integrating your changes into the underlying FeatureSource. By default the IsLiveTransaction property is set to false which means that until you commit the changes the FeatureSource API will not reflect any changes that are in the temporary editing buffer.

In the case where the IsLiveTransaction is set to true then things function slightly differently. The live transaction concept means that all of the modification you perform during a transaction are live from the standpoint of the querying methods on the object.

To setup an example imagine that you have a FeatureSource that has 10 records in it. Next you begin a transaction and then call GetAllFeatures, the result would be 10 records. After that you call a delete on one of the records and call the GetAllFeatures again, this time you only get nine records. You receive nine records even though the transaction has not yet been committed. In the same sense you could have added a new record or modified an existing one and those changes are considered live though not committed.

In the case where you modify records such as expanding the size of a polygon those changes as well are reflected. So for example you expand a polygon by doubling its size and then do a spatial query that would not normally return the smaller record but would return the larger records, in this case the larger record is returned. You can set this property to be false as well in which case all of the spatial related methods would ignore anything that is currently in the transaction buffer waiting to be committed. In this case only after committing the transaction would the FeatureSource reflect the changes.

Events

StreamLoading

This event allows you to pass in your own stream to represent the files.

public event EventHandler<StreamLoadingEventArgs> StreamLoading;

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.

BuildingIndex

This event will be fired each time a record was built the rtree index.

You can choose to use this event to build the build index progess bar.

public static event EventHandler<BuildingIndexShapeFileFeatureSourceEventArgs> BuildingIndex;

Rebuilding

public static event EventHandler<RebuildingShapeFileFeatureSourceEventArgs> Rebuilding;

DrawingProgressChanged

public event EventHandler<DrawingProgressChangedEventArgs> DrawingProgressChanged;

GettingColumns

public event EventHandler<GettingColumnsFeatureSourceEventArgs> GettingColumns;

GottenColumns

public event EventHandler<GottenColumnsFeatureSourceEventArgs> GottenColumns;

GettingFeaturesByIds

public event EventHandler<GettingFeaturesByIdsFeatureSourceEventArgs> GettingFeaturesByIds;

GettingFeaturesForDrawing

public event EventHandler<GettingFeaturesForDrawingFeatureSourceEventArgs> GettingFeaturesForDrawing;

CustomColumnFetch

This event is raised when fields are requested in a feature source method that do not exist in the feature source. It allows you to supplement the data from any outside source you have.

public event EventHandler<CustomColumnFetchEventArgs> CustomColumnFetch;

Remarks:

This event is raised when fields are requested in a feature source method that do not exist in the feature source. It allows you to supplement the data from any outside source you have.

It is used primarily when you have data relating to a particular feature or set of features that is not within source of the data. For example, you may have a shape file of the world whose .dbf component describes the area and population of each country. Additionally, in an outside SQL Server table, you may also have data about the countries, and it is this data that you wish to use for determining how you want to color each country.

To integrate this SQL data, you simply create a file name that does not exist in the .dbf file. Whenever Map Suite is queried to return records that specifically require this field, the FeatureSource will raise this event and allow you the developer to supply the data. In this way, you can query the SQL table and store the data in some sort of collection, and then when the event is raised, simply supply that data.

As this is an event, it will raise for each feature and field combination requested. This means that the event can be raised quite often, and we suggest that you cache the data you wish to supply in memory. We recommend against sending out a new SQL query each time this event is raised. Image that you are supplementing two columns and your query returns 2,000 rows. This means that if you requested those fields, the event would be raised 4,000 times.

CommittingTransaction

This event is raised after the CommitTransaction method is called, but before the CommitTransactionCore is called. This allows you access to the TransactionBuffer before the transaction is committed. It also allows you to cancel the pending commit of the transaction.

public event EventHandler<CommittingTransactionEventArgs> CommittingTransaction;

Remarks:

This event is raised before the CommitTransactionCore is called and allows you access to the TransactionBuffer before the transaction is committed. It also allows you to cancel the pending transaction. The TransactionBuffer is the object that stores all of the pending transactions and is accessible through this event to allow you to either add, remove or modify transactions.

In the event that you cancel the CommitTransaction method, the transaction remains intact and you will still be editing. This makes it a nice place to possibly check for connectivity before the TransactionCore code is run, which is where the records are actually committed. Calling the RollBackTransaction method is the only way to permanently cancel a pending transaction without committing it.

CommittedTransaction

This event is raised after the CommitTransaction and the CommitTransactionCore are called and allows you access to the TransactionBuffer and the TransactionResults object before CommitTransaction method is returned.

public event EventHandler<CommittedTransactionEventArgs> CommittedTransaction;

Remarks:

This event is raised after the CommitTransactionCore is called and allows you access to the TransactionBuffer and the TransactionResults object before CommitTransaction method is returned.

With this event, you can analyse the results of the transaction and do any cleanup code necessary. In the event some of the records did not commit, you can handle those items here. The TransactionResults object is passed out of the CommitTransaction method so you could analyze it then; however, this is the only place where you have access to both the TransactionResults object and the TransactionBuffer object at the same time. These are useful together to try and determine what went wrong and possibly try and re-commit them.

At the time of this event you will technically be out of the current transaction.

OpeningFeatureSource

This event is called before the opening of the FeatureSource.

public event EventHandler<OpeningFeatureSourceEventArgs> OpeningFeatureSource;

Remarks:

This event is called before the opening of the FeatureSource. Technically, this event is called after the calling of the Open method on the FeatureSource, but before the protected OpenCore method.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.

OpenedFeatureSource

This event is called after the opening of the FeatureSource.

public event EventHandler<OpenedFeatureSourceEventArgs> OpenedFeatureSource;

Remarks:

This event is called after the opening of the FeatureSource. Technically, this event is called after the calling of the Open method on the FeatureSource and after the protected OpenCore method is called.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.

ClosingFeatureSource

This event is called before the closing of the FeatureSource.

public event EventHandler<ClosingFeatureSourceEventArgs> ClosingFeatureSource;

Remarks:

This event is called before the closing of the FeatureSource. Technically, this event is called after the calling of the Close method on the FeatureSource, but before the protected CloseCore method.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.

ClosedFeatureSource

This event is called after the closing of the FeatureSource.

public event EventHandler<ClosedFeatureSourceEventArgs> ClosedFeatureSource;

Remarks:

This event is called after the closing of the FeatureSource. Technically, this event is called after the calling of the Close method on the FeatureSource and after the protected CloseCore method.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.


< Back