Table of Contents

Class TinyGeoFeatureSource

Namespace
ThinkGeo.Core
Assembly
ThinkGeo.Core.dll

This class represents a FeatureSource of TinyGeo File by ThinkGeo.

public class TinyGeoFeatureSource : FeatureSource
Inheritance
TinyGeoFeatureSource
Inherited Members

Remarks

None

Constructors

TinyGeoFeatureSource()

This is the class constructor.

public TinyGeoFeatureSource()

Remarks

None

TinyGeoFeatureSource(string)

This is the class constructor.

public TinyGeoFeatureSource(string tinyGeoPathFilename)

Parameters

tinyGeoPathFilename string

This parameter represents the path and file name to the .tgeo file.

Remarks

None

TinyGeoFeatureSource(string, string)

This is the class constructor.

public TinyGeoFeatureSource(string tinyGeoPathFilename, string password)

Parameters

tinyGeoPathFilename string

This parameter represents the path and file name to the .tgeo file.

password string

This parameter represents the password to the .tgeo file.

Remarks

None

Properties

Password

This property gets or sets the password of the TinyGeo file.

public string Password { get; set; }

Property Value

string

TinyGeoPathFilename

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

public string TinyGeoPathFilename { 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.tgeo" 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.

Exceptions

ArgumentException

Setting an invalid FilePathName structure will thrown an ArgumentException.

Methods

CanGetBoundingBoxQuicklyCore()

protected override bool CanGetBoundingBoxQuicklyCore()

Returns

bool

CanGetCountQuicklyCore()

protected override bool CanGetCountQuicklyCore()

Returns

bool

CloseCore()

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

protected override 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.

CreateTinyGeoFile(string, string, GeographyUnit, IEnumerable<string>)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, IEnumerable<string> columnNames)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

columnNames IEnumerable<string>

This parameter specifies the columns in shape file which will be copied to TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, IEnumerable<string>, double)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, IEnumerable<string> columnNames, double precisionInMeter)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

columnNames IEnumerable<string>

This parameter specifies the columns in shape file which will be copied to TinyGeo file.

precisionInMeter double

This parameter spcifies in double what is the precision in Meter of the target TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, IEnumerable<string>, string)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, IEnumerable<string> columnNames, string password)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

columnNames IEnumerable<string>

This parameter specifies the columns in shape file which will be copied to TinyGeo file.

password string

This parameter spcifies the password of the target TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, IEnumerable<string>, string, double)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, IEnumerable<string> columnNames, string password, double precisionInMeter)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

columnNames IEnumerable<string>

This parameter specifies the columns in shape file which will be copied to TinyGeo file.

password string

This parameter spcifies the password of the target TinyGeo file.

precisionInMeter double

This parameter spcifies in double what is the precision in Meter of the target TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, IEnumerable<string>, string, double, Encoding)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, IEnumerable<string> columnNames, string password, double precisionInMeter, Encoding shapeEncoding)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

columnNames IEnumerable<string>

This parameter specifies the columns in shape file which will be copied to TinyGeo file.

password string

This parameter spcifies the password of the target TinyGeo file.

precisionInMeter double

This parameter spcifies in double what is the precision in Meter of the target TinyGeo file.

shapeEncoding Encoding

This parameter specifies the encoding of the existed shape file.

CreateTinyGeoFile(string, string, GeographyUnit, ReturningColumnsType)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, ReturningColumnsType returningColumnType)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

returningColumnType ReturningColumnsType

This parameter specifies whether the columns info in shape file will be copied to TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, ReturningColumnsType, double)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, ReturningColumnsType returningColumnType, double precisionInMeter)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

returningColumnType ReturningColumnsType

This parameter specifies whether the columns info in shape file will be copied to TinyGeo file.

precisionInMeter double

This parameter spcifies in double what is the precision in Meter of the target TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, ReturningColumnsType, string)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, ReturningColumnsType returningColumnType, string password)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

returningColumnType ReturningColumnsType

This parameter specifies whether the columns info in shape file will be copied to TinyGeo file.

password string

This parameter spcifies the password of the target TinyGeo file.

CreateTinyGeoFile(string, string, GeographyUnit, ReturningColumnsType, string, double)

Static API to create a new TinyGeo file from an existed shape file.

public static void CreateTinyGeoFile(string tinyGeoPathFilename, string shapePathFilename, GeographyUnit unitOfData, ReturningColumnsType returningColumnType, string password, double precisionInMeter)

Parameters

tinyGeoPathFilename string

This parameter specifies the file name for the target TinyGeo file.

shapePathFilename string

This parameter specifies the file name for the existed shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit of the data.

returningColumnType ReturningColumnsType

This parameter specifies whether the columns info in shape file will be copied to TinyGeo file.

password string

This parameter spcifies the password of the target TinyGeo file.

precisionInMeter double

This parameter spcifies in double what is the precision in Meter of the target TinyGeo file.

CreateTinyGeoFile(string, FeatureLayer, GeographyUnit, IEnumerable<string>, string, double, Encoding, WellKnownType)

public static void CreateTinyGeoFile(string tinyGeoPathFilename, FeatureLayer featureLayer, GeographyUnit unitOfData, IEnumerable<string> columnNames, string password, double precisionInMeter, Encoding shapeEncoding, WellKnownType type)

Parameters

tinyGeoPathFilename string
featureLayer FeatureLayer
unitOfData GeographyUnit
columnNames IEnumerable<string>
password string
precisionInMeter double
shapeEncoding Encoding
type WellKnownType

DecryptTinyGeoFile(string, string, string)

Decrypt an existed encrypted TinyGeo File and save it as a new TinyGeo File.

public static void DecryptTinyGeoFile(string encryptedTinyGeoPathFilename, string decryptedTinyGeoPathFilename, string password)

Parameters

encryptedTinyGeoPathFilename string

This parameter specifies the file name for the source encrypted TinyGeo file.

decryptedTinyGeoPathFilename string

This parameter specifies the file name for the target decrypted TinyGeo file.

password string

This parameter specified the password of the source encrypted TinyGeo file.

EncryptTinyGeoFile(string, string, string)

Encrypt an existed TinyGeo File and save it as a new TinyGeo File.

public static void EncryptTinyGeoFile(string unencryptedTinyGeoPathFilename, string encryptedTinyGeoPathFilename, string password)

Parameters

unencryptedTinyGeoPathFilename string

This parameter specifies the file name for the source unencrypted TinyGeo file.

encryptedTinyGeoPathFilename string

This parameter specifies the file name for the target encrypted TinyGeo file.

password string

This parameter specified the password of the target encrypted TinyGeo file.

GetAllFeaturesCore(IEnumerable<string>)

This method returns all of the InternalFeatures in the FeatureSource.

protected override 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.

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.

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.

GetAllFeaturesCore(IEnumerable<string>, int, int)

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

Parameters

returningColumnNames IEnumerable<string>
startIndex int
takeCount int

Returns

Collection<Feature>

GetBoundingBoxCore()

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

protected override RectangleShape GetBoundingBoxCore()

Returns

RectangleShape

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

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.

Exceptions

InvalidOperationException

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

GetColumnsCore()

This method returns the columns available for the FeatureSource.

protected override Collection<FeatureSourceColumn> GetColumnsCore()

Returns

Collection<FeatureSourceColumn>

This method returns the columns available for the FeatureSource.

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.

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.

GetFeaturesByIdsCore(IEnumerable<string>, IEnumerable<string>)

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

Parameters

ids IEnumerable<string>
returningColumnNames IEnumerable<string>

Returns

Collection<Feature>

GetFeaturesInsideBoundingBoxCore(RectangleShape, IEnumerable<string>)

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

protected override 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.

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.

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.

GetOptimalPrecision(string, GeographyUnit, DistanceUnit, TinyGeoPrecisionMode)

Get the precision of a shape file for creating a tinyGeo file.

public static double GetOptimalPrecision(string shapePathFilename, GeographyUnit unitOfData, DistanceUnit returningDistanceUnit, TinyGeoPrecisionMode precisionMode)

Parameters

shapePathFilename string

This parameter specifies the file name for the shape file.

unitOfData GeographyUnit

This parameter specifies the Geography Unit for the shape file.

returningDistanceUnit DistanceUnit

This parameter specifies the Distance Unit for the return precision.

precisionMode TinyGeoPrecisionMode

This parameter specifies the mode of getting the return precision.

Returns

double

GetOptimalPrecision(FeatureLayer, GeographyUnit, DistanceUnit, TinyGeoPrecisionMode)

public static double GetOptimalPrecision(FeatureLayer featureLayer, GeographyUnit unitOfData, DistanceUnit returningDistanceUnit, TinyGeoPrecisionMode precisionMode)

Parameters

featureLayer FeatureLayer
unitOfData GeographyUnit
returningDistanceUnit DistanceUnit
precisionMode TinyGeoPrecisionMode

Returns

double

GetTinyGeoFileType()

public TinyGeoFileType GetTinyGeoFileType()

Returns

TinyGeoFileType

OnStreamLoading(StreamLoadingEventArgs)

This method allows you to raise the StreamLoading event.

protected virtual 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.

OpenCore()

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

protected override void OpenCore()

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.

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.

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 TinyGeoPathFilename property.