MapCatalog Class
The maps of a folder: a folder or a file per region, in one of the formats of the catalog.
public sealed class MapCatalogRemarks
By default, a catalog reads the folder formats, MapFormat.FlatGeobuf and MapFormat.GeoJson: a region is a folder with a file per layer and a metadata.json file. Pass the formats to read other formats, such as the GeoPackageMapFormat of Meziantou.Framework.Geo.Maps.GeoPackage. The tools/Meziantou.Framework.Geo.Maps.Tool tool of the repository writes the maps; the packages it makes with --package-content files copy them to a maps folder next to the application. The published packages, Meziantou.Framework.Geo.Maps.Data.<Key>, embed the map in an assembly instead, opened with a static extension property of Map, such as Map.Region_France.
Constructors
| Name | Description |
|---|---|
| MapCatalog(string) | Initializes a new instance of the MapCatalog class that reads the folder formats, MapFormat.FlatGeobuf and MapFormat.GeoJson. |
| MapCatalog(string, IEnumerable<MapFormat>) | Initializes a new instance of the MapCatalog class. |
MapCatalog overloads
MapCatalog(string)
MapCatalog.csInitializes a new instance of the MapCatalog class that reads the folder formats, MapFormat.FlatGeobuf and MapFormat.GeoJson.
public MapCatalog(string directory)Parameters
directorystring- The folder that holds the maps.
MapCatalog(string, IEnumerable<MapFormat>)
MapCatalog.csInitializes a new instance of the MapCatalog class.
public MapCatalog(string directory, IEnumerable<MapFormat> formats)Parameters
directorystring- The folder that holds the maps.
formatsIEnumerable<MapFormat>- The formats of the maps, in order of preference: when a region has maps in several formats, the first format wins.
Exceptions
ArgumentExceptionformatsis empty.
Properties
| Name | Description |
|---|---|
| Default | Gets the catalog of the maps folder next to the application, where the packages of map bundles made with --package-content files copy their regions, with the default formats. |
| DefaultFormats | Gets the formats a catalog reads by default: MapFormat.FlatGeobuf, then MapFormat.GeoJson. |
| Directory | Gets the full path of the folder of the catalog. |
| Formats | Gets the formats of the catalog, in order of preference. |
| Regions | Gets the names of the regions of the catalog, in ordinal order, or an empty list when the folder does not exist. |
Default
MapCatalog.csGets the catalog of the maps folder next to the application, where the packages of map bundles made with --package-content files copy their regions, with the default formats.
public static MapCatalog Default { get; }Property value
DefaultFormats
MapCatalog.csGets the formats a catalog reads by default: MapFormat.FlatGeobuf, then MapFormat.GeoJson.
public static IReadOnlyList<MapFormat> DefaultFormats { get; }Property value
Directory
MapCatalog.csFormats
MapCatalog.csGets the formats of the catalog, in order of preference.
public IReadOnlyList<MapFormat> Formats { get; }Property value
Regions
MapCatalog.csGets the names of the regions of the catalog, in ordinal order, or an empty list when the folder does not exist.
public IReadOnlyList<string> Regions { get; }Property value
Methods
| Name | Description |
|---|---|
| Contains(string) | Gets a value that indicates whether the catalog has the map of a region. |
| GetMap(string) | Gets the map of a region. |
| TryGetMap(string, Map?) | Gets the map of a region, when the catalog has it. |
Contains(string)
MapCatalog.csGets a value that indicates whether the catalog has the map of a region.
Parameters
regionstring- The name of the region, such as
World,EuropeorSwitzerland.
Returns
bool true when the catalog has a map of the region in one of its formats; otherwise, false.
Exceptions
ArgumentExceptionregionis empty or is not the name of a file.
GetMap(string)
MapCatalog.csGets the map of a region.
Parameters
regionstring- The name of the region, such as
World,EuropeorSwitzerland.
Returns
Map The map.
Exceptions
ArgumentExceptionregionis empty or is not the name of a file.KeyNotFoundException- The catalog has no map of this region in its formats.
FormatException- The metadata of the map is not valid.
TryGetMap(string, Map?)
MapCatalog.csGets the map of a region, when the catalog has it.
Parameters
regionstring- The name of the region, such as
World,EuropeorSwitzerland. mapMap?- The map, or
nullwhen the catalog does not have it.
Returns
bool true when the catalog has the map of the region; otherwise, false.
Exceptions
ArgumentExceptionregionis empty or is not the name of a file.FormatException- The metadata of the map is not valid.