Skip to content
Switch branches/tags

Latest commit

   * Refactoring FareZoneRepositoryImpl
   * Refactoring TariffZoneRepositoryImpl

Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Tiamat is the Stop Place Register. It is used nationally in Norway, and other places. Tiamat is created with technologies like Spring Boot, Hibernate, Postgis, Jersey and Jackson.


Core functionality

NeTEx imports

  • Supports different pre steps and merging options for stop places, handling bad data quality.
  • Assigns unique IDs to stop places (if desired).
  • Validates incoming data against the XML schema.

NeTEx exports

Supports exporting stop places and other entities to the format. There are many options for exports:

  • Asynchronous exports to google cloud storage. Asynchronous exports handles large amount of data, even if exporting thousands of stop places.
  • Synchronous exports directly returned
  • Several export parameters and filtering (ex: query or administrative polygons filtering)
  • Exports can be validated against the NeTEx schema, ensuring quality.


Tiamat provides a rich GraphQL API for stop places, topographic places, path links, tariff zones and so on, support the same parameters as the NeTEx export API. It also supports mutations. So you can update or create entities. There are also graphql processes (named functions) which allows functionality like merging quays or stop places.

A ReactJS Frontend

A frontend for Tiamat is available. It's name is Abzu. See

Supports running multiple instances

Tiamat uses Hazelcast memory grid to communicate with other instances in kubernetes. This means that you can run multiple instances.

Mapping of IDs

After import stop places and assigning new IDs to stop places, tiamat keeps olds IDs in a mapping table. The mapping table between old and new IDs is available through the GraphQL API and a REST endpoint.

Automatic topographic place and tariff zone lookup

Tiamat supports looking up and populating references to tariff zones and topographic places from polygon matches when saving a stop place.


Stop places and other entities are versioned. This means that you have full version history of stop places and what person that made those changes. Tiamat also includes a diff tool. This is used to compare and show the difference between two versions of a stop place (or other entity).


mvn clean install

You need the directory /deployments/data with rights for the user who performs the build.

Tiamat currently depends on snapshot dependencies. These are open source as well. You might have to build those first (or fallback to latest release in the pom.xml file)

Run with in-memory GeoDB (H2)

mvn spring-boot:run -Dspring.config.location=src/test/resources/

(default profiles are set in

Run with external properties file and PostgreSQL

To run with PostgreSQL you ned an external Below is an example of



To start Tiamat with this configuration, specify spring.config.location:

mvn spring-boot:run -Dspring.config.location=/path/to/



Tiamat is using HikariCP. Most properties should be be possible to be specified in in, like spring.datasource.initializationFailFast=false. More information here. See also


Run postgres/gis for tiamat in docker for development

docker run -p 5435:5432 -e POSTGRES_USER=tiamat -e POSTGRES_PASSWORD=<insertpasswordhere>" -e POSTGRES_INITDB_ARGS="-d" mdillon/postgis:9.6

ID Generation


During the implementation of Tiamat was desirable to produce NeTEx IDs for stop places more or less gap less. The reason for this implementation was legacy systems with restrictions of maximum number of digits.

Configure ID generation

It is possible to control wether IDs should be generated outside Tiamat or not. See the class ValidPrefixList. Setting the property netex.validPrefix tells Tiamat to generate IDs for new entities. Please note that it is not possible to do an initial import (see ImportType) multiple times with the same IDs.

How its all connected

It's all initiated by an entity listener annotated with PrePersist on the class IdentifiedEntity called IdentifiedEntityListener. NetexIdAssigner determines if the entity already has an ID or not. NetexIdProvider either return a new ID or handles explicity claimed IDs if the configured prefix matches. See ValidPrefixList for the configuration of valid prefixes, and prefixes for IDs generated elsewhere. The GaplessIdGeneratorService uses Hazelcast to sync state between instances and avoid conflicts.


Both Tiamat and Abzu are set up to be used with Keycloak or Auth0.

Keycloak configuraiton

  • Create realm e.g. Entur
  • Create client for frontend e.g. abzu
  • Under client setting configure Mapper e.g. entur-roles
  • Create Roles e.g. deleteStop, editStop, viewStop
  • Add User and assign roles
  • Add User attribute roles {"r":"editStops","o":"NSB","e":{"StopPlaceType":["*"]}}##{"r":"editStops","o":"RB","e":{"EntityType":["*"]}}##{"r":"deleteStops","o":"RB","e":{"EntityType":["StopPlace"]}}##{"r":"deleteStops","o":"RB"}##{"r":"editRouteData","o":"RUT"}

Validation for incoming and outgoing NeTEx publication delivery

It is possible to configure if tiamat should validate incoming and outgoing NeTEx xml when unmarshalling or marshalling publication deliveries. Default values are true. Can be deactivated with setting properties to false.


Synchronous NeTEx export with query params

It is possible to export stop places and topographic places directly to NeTEx format. This is the endpoint:

Query by name example:

Query by ids that contains the number 3115

Query by stop place type

It is also possible with multiple types.

Query by municipality ID

Query by county ID

Limit size of results


ID list

You can specify a list of NSR stop place IDs to return

All Versions

allVersions. Acceptable values are true or false. If set to true, all versions of matching stop places will be returned. If set to false, the highest version by number will be returned for matching stop places. This parameter is not enabled when using the version valitity parmaeter.

Stop places without location

Match only stop places without location Use the parameter: withoutLocationOnly=true

Topographic export mode

The parameter topographicPlaceExportMode can be set to NONE, RELEVANT or ALL Relevant topographic places will be found from the exported list of stop places.

Tariff Zone export mode

The parameter tariffZoneExportMode can be set to NONE, RELEVANT or ALL Relevant tariff zones with be found from the exported list of stop places. Because stop places can have a list of tariff zone refs.

Group of stop places export mode

The parameter groupOfStopPlacesExportMode can be set to NONE, RELEVANT or ALL Relevant group of stop places can be found from the exported list of stop places.

Version validity

The versionValidity parameter controls what stop places to return.

  • ALL: returns all stops in any version (See allVersions attribute), regardless of version validity
  • CURRENT: returns only stop place versions valid at the current time
  • FUTURE_CURRENT: returns only stop place versions valid at the current time, as well as versions valid in the future.


Returns stop places with current version validity now, matching the query 'Nesbru' and exists in municipality 0220. Fetches relevant tariff zones and topographic places.

Async NeTEx export from Tiamat

Asynchronous export uploads exported data to google cloud storage. When initiated, you will get a job ID back. When the job is finished, you can download the exported data.

Most of the parameters from synchronous export works with asynchronous export as well!

Start async export:


Pro tip: Pipe the output from curl to xmllint to format the output:

curl | xmllint --format -

Check job status:


When job is done. Download it:

curl | zcat | xmllint --format - > export.xml

See also

Truncate data in tiamat database

Clean existing data in postgresql (streamline if frequently used):

TRUNCATE topographic_place CASCADE;

Import data into Tiamat

If you are running this from spring:run, then you need to make sure that you have enough memory available for the java process (in case of large data sets). Another issue is thread stack size, which might need to be increased when coping with really large NeTEx imports. Example:

export MAVEN_OPTS='-Xms256m -Xmx1712m -Xss256m -XX:NewSize=64m -XX:MaxNewSize=128m -Dfile.encoding=UTF-8'

Import NeTEx file without NSR IDs

This NeTEx file should not contain NSR ID. (The NSR prefix is configurable in the class ValidPrefixList)

  • Tiamat will match existing stops based on name and coordinates.
  • Tiamat will merge Quays inside stops that are close, have the same original ID and does not have too different compass bearing.

Tiamat will return the modified NeTEx structure with it's own NSR IDs. Original IDs will be present in key value list on each object.

curl  -XPOST -H"Content-Type: application/xml" -d@my-nice-netex-file.xml http://localhost:1997/services/stop_places/netex

Importing with importType=INITIAL

When importing with importType=INITIAL, a parallel stream will be created, spawning the original process. During import, user authorizations is checked, thus accessing SecurityContextHolder. By default, SecurityContextHolder use DEFAULT_LOCAL_STRATEGY. When using INITIAL importType, you should tell Spring to use MODE_INHERITABLETHREADLOCAL for SecurityContextHolder, allowing Spring to duplicate Security Context in spawned threads. This can be done setting env variable :

If not, the application may complain about user not being authenticated if Spring tries to check authorization in a spawned process


GraphQL endpoint is available on

Tip: GraphiQL UI available on using GraphiQL: (Use e.g. Modify Headers for Chrome to add bearer-token for mutations)


To create the database for tiamat, download and use the flyway command line tool:


Migrations are executed when tiamat is started.

Schema changes

Create a new file according to the flyway documentation in the folder resources/db/migrations. Commit the migration together with code changes that requires this schema change. Follow the naming convention.

Tiamat scripts

Various queries and scripts related to tiamat, has been collected here:


Tiamat is built using CircleCI. See the .circleci folder.


Module also known as the backend for Stop Place Register ("nasjonalt stoppestedregister - nsr")





No packages published