Click or drag to resize

Using Repository Objects to Manage Data

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release

This topic outlines how Repository objects should be used to manage local and remote data sources.

Locations of (GBFS) Data Files

Data files may be loaded from a specified filesystem location using a Repository.

However, when deploying an application it is often undesirable to place data files in a fixed location. GeoBase allows for this by automatically searching a number of locations for data files. To learn where GeoBase searches for data files read the Data Files Search Locations topic.

Tip Tip

Up to 192 GBFS data files can be installed on a GeoBase desktop platform.

Using a Repository

A Repository is used to create a collection of data sources which your application may then use. A Repository object allows for the following:

  • On-the-fly loading and unloading of GeoBase data files

  • Using GeoStream (networked) data sources

  • Loading of explicitly specified local data files

Use the following code snippet to set the default Repository object. This Repository object will be assigned to all newly created threads:

C#
Telogis.GeoBase.Repositories.Repository.Default = desiredRepository;

Each thread of your application has its own unique Repository object. The Repository object may be set on a per-thread basis:

C#
Telogis.GeoBase.Repositories.Repository.CurrentThreadRepository = desiredRepository;

desiredRepository is a SimpleRepository, LocalRepository, GeoStreamRepository or a MultiRepository (a MultiRepository object may contain one or more SimpleRepository, LocalRepository or MultiRepository objects, allowing you to create a nested hierarchy of Repository objects).

Loading and Unloading Data Files On-The-Fly

Tip Tip

There is a performance penalty in creating and destroying Repository objects. If you plan to load and unload Repository objects often you should retain handles to the objects to avoid incurring this performance penalty repeatedly.

Dynamic loading and unloading of data files may be performed using a MultiRepository. For example:

C#
// create two new SimpleRepository objects, referencing data files
SimpleRepository mexico = new SimpleRepository(@"..\Data\Mexico.gbfs");
SimpleRepository usa = new SimpleRepository(@"..\Data\USA.gbfs");

// add both SimpleRepository objects to a new MultiRepository
MultiRepository mr = new MultiRepository();
mr.AddRepository(mexico);
mr.AddRepository(usa);

// set our current thread to use our MultiRepository
Repository.CurrentThreadRepository = mr;
// ...we now have access to Mexican and USA map data

...

// if for some reason we decide to add Canadian data, and remove
// the Mexican data...
mr.RemoveRepository(mexico);
mr.AddRepository(new SimpleRepository(@"..\Data\Canada.gbfs"));
// ...note that we didn't retain a handle to the Canadian data,
// so we will not be able to manually unload it on-the-fly
Note Note

Note that when a gbfs data file has been added to a repository, it will remain locked by GeoBase until the process has terminated.

These map data files cannot be deleted even if they are added to a MultiRepository as a SimpleRepository or LocalRepository and subsequently removed using RemoveRepository.

Using Remote Data Sources

A GeoStreamRepository provides remote access to data. A GeoStreamRepository is created by specifying a server URL, pointing at a GeoStream installation:

C#
// specify one or more GeoStream servers...
string[] servers = {@"http://tiles.mycompany.net/GeoStream/" };

// ...use those GeoStream servers in the creation of our repository...
Repository.CurrentThreadRepository = new GeoStreamRepository(servers);

Specifying a Data File

To use a single data file, placed in a known location, use the following code snippet:

C#
Telogis.GeoBase.Repositories.Repository.CurrentThreadRepository =
  new Telogis.GeoBase.Repositories.SimpleRepository(@"C:\path_to_data\USA.gbfs");

The file path specified may be either relative or absolute.