Class MarineZoneLayer
NWS marine zones by UGC code, used to draw a CAP area that names only zone
codes (design note docs/design/weather-sources.md §6.1).
public sealed class MarineZoneLayer
- Inheritance
-
MarineZoneLayer
- Inherited Members
Remarks
Default is the layer bundled with this package: the NWS
coastal (mz16ap26) and offshore (oz16ap26) marine zone
shapefiles from https://www.weather.gov/gis/MarineZones, 699 zones,
simplified once to a compact GeoJSON (Douglas-Peucker at 0.005°, about
500 m, coordinates to four decimals) by tools/cap. The NWS
data is a US Government work in the public domain. The simplification
is fine for drawing a warning area on a chart; neighbouring zones may
overlap or leave slivers of up to a few hundred metres along shared edges.
Load(Stream) reads a newer or fuller layer in the same form:
a GeoJSON feature collection whose features carry the code as id
(or a properties.ID, as the NWS shapefile's attributes name it), a
name (or NAME), an optional wfo (or WFO), and a
Polygon or MultiPolygon.
Properties
Codes
The zone codes, in no particular order.
public IEnumerable<string> Codes { get; }
Property Value
Count
How many zones the layer holds.
public int Count { get; }
Property Value
Default
The bundled NWS coastal and offshore marine zones, read once on first use.
public static MarineZoneLayer Default { get; }
Property Value
Empty
An empty layer, which resolves no code.
public static MarineZoneLayer Empty { get; }
Property Value
Source
Where the layer came from, as its file says, or null.
public string? Source { get; }
Property Value
Methods
CodesIn(double, double, double, double)
The codes of the zones whose outline's bounding box meets the box from
south to north and
west to east (degrees; a box with
west greater than east crosses the
antimeridian), sorted: the marine zones to ask api.weather.gov
about for an area (#1075).
public IReadOnlyList<string> CodesIn(double south, double west, double north, double east)
Parameters
Returns
Create(IEnumerable<MarineZone>)
Builds a layer from zones, for tests and hosts that keep their own.
public static MarineZoneLayer Create(IEnumerable<MarineZone> zones)
Parameters
zonesIEnumerable<MarineZone>The zones; a later zone with the same code replaces an earlier one.
Returns
Find(string)
The zone with UGC code code, matched ignoring case, or null.
public MarineZone? Find(string code)
Parameters
codestringThe code, e.g.
"ANZ535".
Returns
Load(Stream)
Reads a marine zone layer from GeoJSON (see the remarks for its form). The stream is left open.
public static MarineZoneLayer Load(Stream stream)
Parameters
streamStreamThe GeoJSON.
Returns
Exceptions
- CapFormatException
The stream isn't a GeoJSON feature collection.