Map Class

The map of a region: its layers, read from the files of the map when they are loaded.

public abstract class Map

Remarks

The positions are longitudes and latitudes, in degrees (WGS 84).

The properties that MapLayer documents have the same type in every format: a format that does not store the types, such as GeoJSON, where every number is a Double, gets the documented types, such as an Int32 for the rank of a city. The other properties are returned as the format reads them.

Constructors

NameDescription
Map(MapMetadata)Initializes a new instance of the Map class.

Map(MapMetadata)

Map.cs

Initializes a new instance of the Map class.

protected Map(MapMetadata metadata)

Parameters

metadata MapMetadata
The description of the map.

Properties

NameDescription
AttributionGets the attribution the licenses of the data require, to show on the maps, or null when the metadata of the map has none.
BoundsGets the bounds of the region: the box of its borders, which the other layers are cut to. It comes from the metadata of the map, else from the MapLayer.Borders layer; null without either.
LayersGets the layers the map has: the layers whose source has nothing in the region, such as the coastline of a country without sea, are not there.
MetadataGets the description of the map, as its files store it.
NameGets the name of the region, from the metadata of the map, else Map.Region.
RegionGets the name of the region in its catalog, such as World, Europe or Switzerland.

Attribution

Map.cs

Gets the attribution the licenses of the data require, to show on the maps, or null when the metadata of the map has none.

public string? Attribution { get; }

Property value

string?

Bounds

Map.cs

Gets the bounds of the region: the box of its borders, which the other layers are cut to. It comes from the metadata of the map, else from the MapLayer.Borders layer; null without either.

public GeoBounds? Bounds { get; }

Property value

GeoBounds?

Remarks

Use it as the extent of a map of the region.

Layers

Map.cs

Gets the layers the map has: the layers whose source has nothing in the region, such as the coastline of a country without sea, are not there.

public IReadOnlyList<MapLayer> Layers { get; }

Metadata

Map.cs

Gets the description of the map, as its files store it.

public MapMetadata Metadata { get; }

Property value

MapMetadata

Name

Map.cs

Gets the name of the region, from the metadata of the map, else Map.Region.

public string Name { get; }

Property value

string

Region

Map.cs

Gets the name of the region in its catalog, such as World, Europe or Switzerland.

public string Region { get; }

Property value

string

Methods

NameDescription
HasLayer(MapLayer)Gets a value that indicates whether the map has a layer.
Load(MapLayer)Reads the features of a layer.
Load(MapLayer, GeoBounds)Reads the features of a layer whose bounds intersect a box, such as the cities of the part of the region a map shows.
LoadLayer(MapLayer, GeoBounds?)Reads the features of a layer the map has.

HasLayer(MapLayer)

Gets a value that indicates whether the map has a layer.

public abstract bool HasLayer(MapLayer layer)

Parameters

layer MapLayer
The layer.

Returns

bool true when the map has the layer; otherwise, false.

Load overloads

Load(MapLayer)

Map.cs

Reads the features of a layer.

public GeoFeatureCollection Load(MapLayer layer)
Parameters
layer MapLayer
The layer.
Returns

GeoFeatureCollection The features, in a collection named after the layer.

Exceptions
ArgumentOutOfRangeException
layer is not a layer.
KeyNotFoundException
The map does not have the layer.
FormatException
The layer is not valid.

Load(MapLayer, GeoBounds)

Map.cs

Reads the features of a layer whose bounds intersect a box, such as the cities of the part of the region a map shows.

public GeoFeatureCollection Load(MapLayer layer, GeoBounds bounds)
Parameters
layer MapLayer
The layer.
bounds GeoBounds
The box.
Returns

GeoFeatureCollection The features, in a collection named after the layer. They are not cut to the box: use GeoGeometry.Clip to cut them.

Exceptions
ArgumentOutOfRangeException
layer is not a layer.
KeyNotFoundException
The map does not have the layer.
FormatException
The layer is not valid.

LoadLayer(MapLayer, GeoBounds?)

Reads the features of a layer the map has.

protected abstract IEnumerable<GeoFeature> LoadLayer(MapLayer layer, GeoBounds? bounds)

Parameters

layer MapLayer
The layer, one that Map.HasLayer reports.
bounds GeoBounds?
The box the features must intersect, or null for every feature. The result can have more features, such as the features a spatial index finds: Map.Load keeps those whose bounds intersect the box.

Returns

IEnumerable<GeoFeature> The features.

Exceptions

FormatException
The layer is not valid.