Skip to content

petlof/OpenTNF-library

 
 

Repository files navigation

OpenTNF-library

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.

Formats

This section describes the formats used by the reference implementation.

Storage

The reference implementation reads and writes OpenTNF data from and to a SQLite file database. See http://sqlite.org/.

Geometry

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.

Booleans

Boolean values are stored as integers, with the following interpretation:

Integer value Boolean value
0 false
1 true

Date

Date values are stored as DateTime. The time of day shall always be set to 00:00:00.

DateTime

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

Attribute values in the table tnf_property are serialized as XML. The library provides built-in serialization and deserialization of attribute values.

Limitations

This section describes all limitations that the reference implementation imposes on the OpenTNF standard.

Oids

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.

Extensions

This chapter describes extensions to the OpenTNF standard made in the reference implementation.

Tasks

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.

Areas

The table tnf_area can be used to store areas related to the dataset in the file.

Metadata Keys

The following additional metadata keys are defined:

Metadata key Description
GT_COORD_SYSTEM_ID GTrans name of the coordinate system used for the file.

Examples

Open an existing OpenTNF file

using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
    db.OpenGeoPackageDatabase();
    // Read and write...
    db.CloseConnection();
}

Create a new OpenTNF file

using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
    db.CreateGeoPackageDatabase(3006, null, "Example", DataSetType.Snapshot, null, false, true);
    db.OpenGeoPackageDatabase();
    // Read and write...
    db.CloseConnection();
}

Read LinkSequences

using (GeoPackageDatabase db = new GeoPackageDatabase(fileName))
{
    db.OpenGeoPackageDatabase();
    TnfLinkSequenceManager manager = db.GetTableManager<TnfLinkSequenceManager>();
    List<TnfLinkSequence> linkSequences = manager.GetPage(0, 1000);
    db.CloseConnection();
}

Write LinkSequences

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().

About

Reference implementations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%