Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+hydranten-markers-by-source.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On the Hydrantenkarte every Löschwasser-Entnahmestelle is now coloured by where its water comes from, red for a hydrant on the Trinkwassernetz and blue for a source independent of it, and its flag says the DN or a Löschwasserbehälter's volume instead of an almost always unknown flow, close up also the Lage, the outlets by Storz size ("A, 2×B") and whether it stands on private ground, while its card adds the outlets, the access and when a mapper last checked it on site.
Binary file modified docs/screenshots/12-hydrantenkarte-naechste.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/13-hydrantenkarte-hydrant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/14-hydrantenkarte-pfeil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 21 additions & 18 deletions src/FwAssist.AppLogic/Services/Map/WaterPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ public enum WaterPointSymbol
OffenesGewaesser,
}

/// <summary>How the main a hydrant hangs on is fed.</summary>
public enum WaterNetwork
{
/// <summary>Ringleitung: fed from both sides.</summary>
Ring,

/// <summary>Stichleitung: a dead end.</summary>
Stich,
}

/// <summary>
/// A Wasserentnahmestelle from a Kartenpaket's <c>water.geojson</c>, as OpenStreetMap has it.
/// <see cref="Label"/> is the short text drawn beside it on a close map ("UH 100", a name, a
Expand All @@ -64,6 +54,8 @@ public sealed record WaterPoint(GeoPoint Position, WaterPointKind Kind, string L
{
private readonly WaterPointSymbol? symbol;

private readonly bool? independent;

/// <summary>The card's rows: Bauart, Durchmesser, Nummer and whatever else OSM holds.</summary>
public IReadOnlyList<WaterPointDetail> Details { get; init; } = [];

Expand All @@ -80,20 +72,31 @@ public WaterPointSymbol Symbol
init => symbol = value;
}

/// <summary>What it can deliver, in l/min; null when nobody says.</summary>
public int? FlowLitresPerMinute { get; init; }

/// <summary>
/// <see cref="FlowLitresPerMinute"/> is an estimate (from the DN, a network model), not a
/// measurement. <c>water.geojson</c> has no such field, so a pack's points are never estimated.
/// Fed from somewhere other than the Trinkwassernetz: open water, a well or a tank, which a
/// burst main or a weak network does not take down with the hydrants. Unless set, every kind
/// but a hydrant; a hydrant OSM says draws on a pond, a river or a tank is one too.
/// </summary>
public bool IsEstimated { get; init; }
public bool IsIndependent
{
get => independent ?? Kind != WaterPointKind.Hydrant;
init => independent = value;
}

/// <summary>The Nennweite of the main, DN; null when unknown.</summary>
public int? NominalDiameter { get; init; }

/// <summary>Ring or Stich; null when unknown, as it always is from OSM, which has no tag for it.</summary>
public WaterNetwork? Network { get; init; }
/// <summary>A Löschwasserbehälter's volume in m³; null when unknown.</summary>
public int? VolumeCubicMetres { get; init; }

/// <summary>Where it sits, "Fahrbahn", "Gehweg", "Grünfläche" or "Parkplatz"; null for anything else.</summary>
public string? Lage { get; init; }

/// <summary>Its outlets by Storz size, "A, 2×B", or only how many, "2 Abgänge"; null when unknown.</summary>
public string? Outlets { get; init; }

/// <summary>On private ground: OSM says <c>access=private</c> or <c>no</c>.</summary>
public bool IsPrivate { get; init; }

/// <summary>
/// Außer Betrieb. A pack never holds one: its build drops every point OSM marks disused or
Expand Down
22 changes: 14 additions & 8 deletions src/FwAssist.AppLogic/Services/Map/WaterPointLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public static class WaterPointLayer
/// <summary>Further out, a Landkreis' thousands of hydrants are a red carpet, not information.</summary>
public const int MinZoom = 15;

/// <summary>From here a point is a flag with its flow, not a disc.</summary>
/// <summary>From here a point is a flag with its glyph and first line, not a disc.</summary>
public const int MediumMinZoom = 16;

/// <summary>From here a flag also says the unit, the DN and Ring or Stich.</summary>
/// <summary>From here a flag also says the Lage, the outlets and whether it is on private ground.</summary>
public const int FullMinZoom = 18;

/// <summary>How far from a symbol's centre a tap still means it: about a fingertip.</summary>
Expand All @@ -27,7 +27,7 @@ public static class WaterPointLayer
public static readonly WaterPointFlag MediumFlag = new(MastLength: 8, BodyHeight: 20, NominalWidth: 64);

/// <summary>The flag at <see cref="WaterPointDetailLevel.Voll"/>.</summary>
public static readonly WaterPointFlag FullFlag = new(MastLength: 10, BodyHeight: 32, NominalWidth: 100);
public static readonly WaterPointFlag FullFlag = new(MastLength: 10, BodyHeight: 32, NominalWidth: 120);

/// <summary>How much of a marker shows at <paramref name="zoom"/>; null below <see cref="MinZoom"/>, where none does.</summary>
public static WaterPointDetailLevel? LevelAt(int zoom) => zoom switch
Expand Down Expand Up @@ -55,15 +55,21 @@ public static class WaterPointLayer

/// <summary>
/// Where <paramref name="point"/>'s marker lies in the stack, lowest first: the one whose card
/// is open, <paramref name="selected"/>, on top, the others by <see cref="FlowClass"/>, so a
/// strong source lies over a weak one. The map draws its markers in this order, and a tap on
/// markers that share a spot means the one on top.
/// is open, <paramref name="selected"/>, on top; under it an independent source, rarer and
/// still there when the mains fail; then the hydrants by DN, the larger over the smaller, one of
/// unknown DN lowest. The map draws its markers in this order, and a tap on markers that share
/// a spot means the one on top.
/// </summary>
public static int StackRank(WaterPoint point, WaterPoint? selected)
{
ArgumentNullException.ThrowIfNull(point);
var flowClass = (int)WaterPointMarking.Classify(point.FlowLitresPerMinute);
return ReferenceEquals(point, selected) ? (int)FlowClass.Ab3200 + 1 : flowClass;
const int independent = 10_000;
if (ReferenceEquals(point, selected))
{
return independent + 1;
}

return point.IsIndependent ? independent : Math.Clamp(point.NominalDiameter ?? 0, 0, independent - 1);
}

/// <summary>
Expand Down
76 changes: 20 additions & 56 deletions src/FwAssist.AppLogic/Services/Map/WaterPointMarking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,55 @@

namespace FwAssist.AppLogic.Services.Map;

/// <summary>
/// The Leistungsklasse a water point's marker is coloured by, along the Richtwerte of the
/// Löschwasserbedarf (48 / 96 / 192 m³/h). Ordered from weakest to strongest, which is also the
/// order the markers are drawn in, so a strong source lies on top.
/// </summary>
public enum FlowClass
{
/// <summary>Not recorded or not assessable.</summary>
Unbekannt,

/// <summary>Under 400 l/min: not enough for an attack on its own.</summary>
Unter400,

/// <summary>400–799 l/min: one line, plan a feed.</summary>
Bis799,

/// <summary>800–1.599 l/min: Grundschutz for housing, 48 m³/h.</summary>
Bis1599,

/// <summary>1.600–3.199 l/min: higher demand, commercial, 96 m³/h.</summary>
Bis3199,

/// <summary>From 3.200 l/min: large buildings, 192 m³/h.</summary>
Ab3200,
}

/// <summary>How much of a water point its map marker shows, by the map's zoom.</summary>
public enum WaterPointDetailLevel
{
/// <summary>A small dot in the class colour, in a ring filled by the class.</summary>
/// <summary>A small dot in the source's colour.</summary>
Punkt,

/// <summary>A flag with the glyph and the flow.</summary>
/// <summary>A flag with the glyph and the first line.</summary>
Mittel,

/// <summary>A flag with the flow and its unit, the DN and the Ring/Stich sign.</summary>
/// <summary>A flag with the first line and, below it, Lage, outlets and private access.</summary>
Voll,
}

/// <summary>
/// What a water point's map marker says, apart from how it is drawn: its class, its two lines of
/// text and how much of it shows at a zoom.
/// What a water point's map marker says, apart from how it is drawn: only what OpenStreetMap holds.
/// OSM knows the DN of most hydrants and the flow of almost none, and has no tag for Ring or Stich,
/// so a marker shows neither; the colour says only whether the point hangs on the Trinkwassernetz.
/// </summary>
public static class WaterPointMarking
{
/// <summary>The value shown where nothing is known.</summary>
public const string Unknown = "?";

/// <summary>The class of <paramref name="litresPerMinute"/>; <see cref="FlowClass.Unbekannt"/> for null.</summary>
public static FlowClass Classify(int? litresPerMinute) => litresPerMinute switch
{
null => FlowClass.Unbekannt,
< 400 => FlowClass.Unter400,
< 800 => FlowClass.Bis799,
< 1600 => FlowClass.Bis1599,
< 3200 => FlowClass.Bis3199,
_ => FlowClass.Ab3200,
};
private const string Separator = " · ";

/// <summary>
/// The flow as the marker shows it: "1600", without a thousands point so four digits stay
/// short; "12k" from 10.000; in brackets when it is an estimate; "?" when unknown.
/// The flag's first line: a hydrant's "DN 100", which the Hinweisschild says too, or "DN ?"; a
/// Löschwasserbehälter's volume, "100 m³", or else its Nummer or name; for open water its Nummer
/// or name. Empty when OSM says nothing worth showing.
/// </summary>
public static string FlowText(WaterPoint point)
public static string PrimaryText(WaterPoint point)
{
ArgumentNullException.ThrowIfNull(point);
if (point.FlowLitresPerMinute is not { } flow)
return point.Kind switch
{
return Unknown;
}

var text = flow >= 10_000 ? $"{Formatting.UngroupedNumber(flow / 1000)}k" : Formatting.UngroupedNumber(flow);
return point.IsEstimated ? $"({text})" : text;
WaterPointKind.Hydrant => DiameterText(point),
WaterPointKind.Loeschwasserbehaelter when point.VolumeCubicMetres is { } volume => $"{Formatting.UngroupedNumber(volume)} m³",
_ => point.Label,
};
}

/// <summary>
/// The one line a <see cref="WaterPointDetailLevel.Mittel"/> flag has room for: the flow, or,
/// where nobody recorded one, the DN rather than a "?". OpenStreetMap knows the DN of most
/// hydrants and the flow of almost none, and the DN is what the Hinweisschild says too. The
/// colour stays grey, so the DN is never mistaken for a flow.
/// The full flag's second line, "Fahrbahn · A, 2×B · privat": whatever of the three OSM holds,
/// empty when it holds none.
/// </summary>
public static string MediumText(WaterPoint point)
public static string SecondaryText(WaterPoint point)
{
ArgumentNullException.ThrowIfNull(point);
return point.FlowLitresPerMinute is null && point.NominalDiameter is not null ? DiameterText(point) : FlowText(point);
return string.Join(Separator, new[] { point.Lage, point.Outlets, point.IsPrivate ? "privat" : null }.OfType<string>());
}

/// <summary>"DN 100", or "DN ?" when the Nennweite is unknown.</summary>
Expand Down
Loading