using System.Text.Json.Serialization; namespace Cepis; /// /// The CEP's coordinate, when the database has one. /// /// /// /// The point is the median of the coordinates of that CEP's addresses, /// not the mean: one badly geocoded address 40 km away shifts a mean and does /// not move a median. /// /// /// Always check before using and /// for distance. "logradouro" means the point is a /// stretch of street and lands around 100–150 m — good for /// maps and for distance. "localidade" means the CEP is the whole /// municipality (a city-wide general CEP) and the point is its centroid, with /// running from 7 km to 40 km; computing shipping from that /// is wrong by tens of kilometres. /// /// /// is the radius containing 90% of that CEP's addresses. It /// exists precisely so that error cannot pass unnoticed. /// /// /// The property names are the API's own, with only the casing adapted: /// lat, lon, raio_m and precisao on the wire. /// /// public sealed record Geo { /// Latitude in decimal degrees, WGS 84. Wire name lat. [JsonPropertyName("lat")] public double Lat { get; init; } /// Longitude in decimal degrees, WGS 84. Wire name lon. [JsonPropertyName("lon")] public double Lon { get; init; } /// /// The radius, in metres, containing 90% of that CEP's addresses. Wire name /// raio_m. /// [JsonPropertyName("raio_m")] public int RaioM { get; init; } /// /// What the point describes: "logradouro" for a stretch of street, /// "localidade" for a municipality centroid. Wire name /// precisao. /// [JsonPropertyName("precisao")] public string Precisao { get; init; } = ""; /// /// when the coordinate points at a street rather than /// a municipality. /// /// /// Shorthand for Precisao == "logradouro", which is the check to make /// before using the point to measure distance. /// [JsonIgnore] public bool IsPrecise => Precisao == "logradouro"; }