This library is a reference implementation of the OpenTNF standard.
The implementation imposes some limitations in the standard, and includes a few (optional) extensions to the standard. These are described below.
This section describes the formats used by the reference implementation.
The reference implementation reads and writes OpenTNF data from and to a SQLite file database. See http://sqlite.org/.
The file conforms to the GeoPackage specification (see http://www.geopackage.org/), which means that additional tables are included that describe the spatial contents of the file.
Geometry data is stored as BLOB values using the Standard GeoPackageBinary format (see http://www.geopackage.org/spec/#gpb_format).
The reference implementation does not include logic for serializing and deserializing geometry data.
Boolean values are stored as integers, with the following interpretation:
Integer value | Boolean value |
---|---|
0 | false |
1 | true |
Date values are stored as DateTime. The time of day shall always be set to 00:00:00
.
DateTime values are stored in UTC time.
This does not apply to fields that are of type DateTime but contain only date information (see above).
Attribute values in the table tnf_property
are serialized as XML. The library provides built-in serialization and deserialization of attribute values.
This section describes all limitations that the reference implementation imposes on the OpenTNF standard.
The oid
column in the following tables can only contain integer values:
- TNF_NETWORK
- TNF_CATALOGUE
- TNF_PROPERTY_OBJECT_TYPE
- TNF_PROPERTY_OBJECT_PROPERTY_TYPE
- TNF_VALUE_DOMAIN
- TNF_STRUCTURED_VALUE_DOMAIN_PROPERTY_TYPE
- TNF_SECONDARY_LRS
- TNF_AREA
This also applies to any column that references the oid
column in any of the above tables with a foreign key.
This chapter describes extensions to the OpenTNF standard made in the reference implementation.
The tables tnf_task
and tnf_task_editable_type
tables are included, and can be used to store tasks related to the dataset in the file.
The table tnf_area
can be used to store areas related to the dataset in the file.
The following additional metadata keys are defined:
Metadata key | Description |
---|---|
GT_COORD_SYSTEM_ID | GTrans name of the coordinate system used for the file. |
using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
db.OpenGeoPackageDatabase();
// Read and write...
db.CloseConnection();
}
using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
db.CreateGeoPackageDatabase(3006, null, "Example", DataSetType.Snapshot, null, false, true);
db.OpenGeoPackageDatabase();
// Read and write...
db.CloseConnection();
}
using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
db.OpenGeoPackageDatabase();
TnfLinkSequenceManager manager = db.GetTableManager<TnfLinkSequenceManager>();
List<TnfLinkSequence> linkSequences = manager.GetPage(0, 1000);
db.CloseConnection();
}
using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
db.OpenGeoPackageDatabase();
TnfLinkSequenceManager manager = db.GetTableManager<TnfLinkSequenceManager>();
manager.Add(new TnfLinkSequence
{
Oid = "abc",
Vid = "abcd",
NetworkOid = 1,
NextFreePortNumber = 0,
Geometry = new byte[] {1, 2, 3, 4}
});
db.CloseConnection();
}
Note: When writing large amounts of data, it is recommended to use a transaction, beginning with db.BeginTransaction()
and completing with db.EndTransactionCommit()
.