diff --git a/changelog.d/+hydranten-markers-by-source.changed.md b/changelog.d/+hydranten-markers-by-source.changed.md
new file mode 100644
index 0000000..56e3e24
--- /dev/null
+++ b/changelog.d/+hydranten-markers-by-source.changed.md
@@ -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.
diff --git a/docs/screenshots/12-hydrantenkarte-naechste.png b/docs/screenshots/12-hydrantenkarte-naechste.png
index 24a9617..46d93d5 100644
Binary files a/docs/screenshots/12-hydrantenkarte-naechste.png and b/docs/screenshots/12-hydrantenkarte-naechste.png differ
diff --git a/docs/screenshots/13-hydrantenkarte-hydrant.png b/docs/screenshots/13-hydrantenkarte-hydrant.png
index 11e226e..b2627a1 100644
Binary files a/docs/screenshots/13-hydrantenkarte-hydrant.png and b/docs/screenshots/13-hydrantenkarte-hydrant.png differ
diff --git a/docs/screenshots/14-hydrantenkarte-pfeil.png b/docs/screenshots/14-hydrantenkarte-pfeil.png
index 0b501ad..5036f8e 100644
Binary files a/docs/screenshots/14-hydrantenkarte-pfeil.png and b/docs/screenshots/14-hydrantenkarte-pfeil.png differ
diff --git a/src/FwAssist.AppLogic/Services/Map/WaterPoint.cs b/src/FwAssist.AppLogic/Services/Map/WaterPoint.cs
index 622e774..880c516 100644
--- a/src/FwAssist.AppLogic/Services/Map/WaterPoint.cs
+++ b/src/FwAssist.AppLogic/Services/Map/WaterPoint.cs
@@ -43,16 +43,6 @@ public enum WaterPointSymbol
OffenesGewaesser,
}
-/// How the main a hydrant hangs on is fed.
-public enum WaterNetwork
-{
- /// Ringleitung: fed from both sides.
- Ring,
-
- /// Stichleitung: a dead end.
- Stich,
-}
-
///
/// A Wasserentnahmestelle from a Kartenpaket's water.geojson, as OpenStreetMap has it.
/// is the short text drawn beside it on a close map ("UH 100", a name, a
@@ -64,6 +54,8 @@ public sealed record WaterPoint(GeoPoint Position, WaterPointKind Kind, string L
{
private readonly WaterPointSymbol? symbol;
+ private readonly bool? independent;
+
/// The card's rows: Bauart, Durchmesser, Nummer and whatever else OSM holds.
public IReadOnlyList Details { get; init; } = [];
@@ -80,20 +72,31 @@ public WaterPointSymbol Symbol
init => symbol = value;
}
- /// What it can deliver, in l/min; null when nobody says.
- public int? FlowLitresPerMinute { get; init; }
-
///
- /// is an estimate (from the DN, a network model), not a
- /// measurement. water.geojson 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.
///
- public bool IsEstimated { get; init; }
+ public bool IsIndependent
+ {
+ get => independent ?? Kind != WaterPointKind.Hydrant;
+ init => independent = value;
+ }
/// The Nennweite of the main, DN; null when unknown.
public int? NominalDiameter { get; init; }
- /// Ring or Stich; null when unknown, as it always is from OSM, which has no tag for it.
- public WaterNetwork? Network { get; init; }
+ /// A Löschwasserbehälter's volume in m³; null when unknown.
+ public int? VolumeCubicMetres { get; init; }
+
+ /// Where it sits, "Fahrbahn", "Gehweg", "Grünfläche" or "Parkplatz"; null for anything else.
+ public string? Lage { get; init; }
+
+ /// Its outlets by Storz size, "A, 2×B", or only how many, "2 Abgänge"; null when unknown.
+ public string? Outlets { get; init; }
+
+ /// On private ground: OSM says access=private or no.
+ public bool IsPrivate { get; init; }
///
/// Außer Betrieb. A pack never holds one: its build drops every point OSM marks disused or
diff --git a/src/FwAssist.AppLogic/Services/Map/WaterPointLayer.cs b/src/FwAssist.AppLogic/Services/Map/WaterPointLayer.cs
index 1460b73..a3672c5 100644
--- a/src/FwAssist.AppLogic/Services/Map/WaterPointLayer.cs
+++ b/src/FwAssist.AppLogic/Services/Map/WaterPointLayer.cs
@@ -11,10 +11,10 @@ public static class WaterPointLayer
/// Further out, a Landkreis' thousands of hydrants are a red carpet, not information.
public const int MinZoom = 15;
- /// From here a point is a flag with its flow, not a disc.
+ /// From here a point is a flag with its glyph and first line, not a disc.
public const int MediumMinZoom = 16;
- /// From here a flag also says the unit, the DN and Ring or Stich.
+ /// From here a flag also says the Lage, the outlets and whether it is on private ground.
public const int FullMinZoom = 18;
/// How far from a symbol's centre a tap still means it: about a fingertip.
@@ -27,7 +27,7 @@ public static class WaterPointLayer
public static readonly WaterPointFlag MediumFlag = new(MastLength: 8, BodyHeight: 20, NominalWidth: 64);
/// The flag at .
- public static readonly WaterPointFlag FullFlag = new(MastLength: 10, BodyHeight: 32, NominalWidth: 100);
+ public static readonly WaterPointFlag FullFlag = new(MastLength: 10, BodyHeight: 32, NominalWidth: 120);
/// How much of a marker shows at ; null below , where none does.
public static WaterPointDetailLevel? LevelAt(int zoom) => zoom switch
@@ -55,15 +55,21 @@ public static class WaterPointLayer
///
/// Where 's marker lies in the stack, lowest first: the one whose card
- /// is open, , on top, the others by , 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, , 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.
///
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);
}
///
diff --git a/src/FwAssist.AppLogic/Services/Map/WaterPointMarking.cs b/src/FwAssist.AppLogic/Services/Map/WaterPointMarking.cs
index c3901e1..b1f320d 100644
--- a/src/FwAssist.AppLogic/Services/Map/WaterPointMarking.cs
+++ b/src/FwAssist.AppLogic/Services/Map/WaterPointMarking.cs
@@ -2,91 +2,55 @@
namespace FwAssist.AppLogic.Services.Map;
-///
-/// 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.
-///
-public enum FlowClass
-{
- /// Not recorded or not assessable.
- Unbekannt,
-
- /// Under 400 l/min: not enough for an attack on its own.
- Unter400,
-
- /// 400–799 l/min: one line, plan a feed.
- Bis799,
-
- /// 800–1.599 l/min: Grundschutz for housing, 48 m³/h.
- Bis1599,
-
- /// 1.600–3.199 l/min: higher demand, commercial, 96 m³/h.
- Bis3199,
-
- /// From 3.200 l/min: large buildings, 192 m³/h.
- Ab3200,
-}
-
/// How much of a water point its map marker shows, by the map's zoom.
public enum WaterPointDetailLevel
{
- /// A small dot in the class colour, in a ring filled by the class.
+ /// A small dot in the source's colour.
Punkt,
- /// A flag with the glyph and the flow.
+ /// A flag with the glyph and the first line.
Mittel,
- /// A flag with the flow and its unit, the DN and the Ring/Stich sign.
+ /// A flag with the first line and, below it, Lage, outlets and private access.
Voll,
}
///
-/// 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.
///
public static class WaterPointMarking
{
/// The value shown where nothing is known.
public const string Unknown = "?";
- /// The class of ; for null.
- 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 = " · ";
///
- /// 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.
///
- 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,
+ };
}
///
- /// The one line a 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.
///
- 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());
}
/// "DN 100", or "DN ?" when the Nennweite is unknown.
diff --git a/src/FwAssist.AppLogic/Services/Map/WaterPointsGeoJson.cs b/src/FwAssist.AppLogic/Services/Map/WaterPointsGeoJson.cs
index 83498a1..25d1439 100644
--- a/src/FwAssist.AppLogic/Services/Map/WaterPointsGeoJson.cs
+++ b/src/FwAssist.AppLogic/Services/Map/WaterPointsGeoJson.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using System.Text.Json;
using System.Text.RegularExpressions;
+using FwAssist.Core;
using FwAssist.Core.Map;
namespace FwAssist.AppLogic.Services.Map;
@@ -85,8 +86,12 @@ private static bool TryParseFeature(JsonElement feature, [MaybeNullWhen(false)]
{
Details = Details(properties),
Symbol = Symbol(k, properties),
- FlowLitresPerMinute = FlowRate(Text(properties, "flow_rate")),
+ IsIndependent = k != WaterPointKind.Hydrant || IsOffTheMains(Text(properties, "water_source")),
NominalDiameter = Diameter(Text(properties, "fire_hydrant:diameter")),
+ VolumeCubicMetres = Volume(Text(properties, "water_tank:volume")),
+ Lage = Lage(Text(properties, "fire_hydrant:position")),
+ Outlets = Outlets(Text(properties, "couplings:diameters", MaxDetailLength), Text(properties, "couplings")),
+ IsPrivate = Text(properties, "access") is "private" or "no",
};
return true;
}
@@ -106,31 +111,82 @@ private static bool TryParseFeature(JsonElement feature, [MaybeNullWhen(false)]
_ => WaterPointSymbol.OffenesGewaesser,
};
- // OSM's flow_rate in l/min: "1600" or "1600 l/min", or "96 m3/h" converted. A thousands point
- // ("1.600") is no l/min figure anyone can be sure of, and nothing beyond a fire boat's is a
- // hydrant's: either reads as unknown, and the card still shows the text as it is.
- private static int? FlowRate(string? value)
+ // OSM lets a fire_hydrant draw on open water, a well or a tank; without water_source, or with
+ // one it does not know, a hydrant hangs on the Trinkwassernetz.
+ private static bool IsOffTheMains(string? waterSource) =>
+ waterSource is "pond" or "river" or "stream" or "lake" or "groundwater" or "water_tank";
+
+ // A tank's volume in m³ from "250 m³", "300m3" or a bare "100". OSM documents the key in m³,
+ // but mappers often give litres: a bare figure of ten thousand or more is no Löschwasserbehälter's
+ // m³ and is read as litres. One between a thousand and that could be either, "2000" a big tank
+ // or a small one, and reads as unknown, as does anything else; the card still shows it as it is.
+ private static int? Volume(string? value)
{
- const int plausible = 100_000;
- if (value is null || FlowRateValue().Match(value) is not { Success: true } match)
+ if (value is null || VolumeValue().Match(value) is not { Success: true } match
+ || !double.TryParse(match.Groups["number"].Value.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var amount))
{
return null;
}
- var number = match.Groups["number"].Value.Replace(',', '.');
- if (!double.TryParse(number, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var amount))
+ if (!match.Groups["unit"].Success && amount is > 1000 and < 10_000)
{
return null;
}
- var perHour = match.Groups["unit"].Value.StartsWith('m') || match.Groups["unit"].Value.StartsWith('M');
- if (!perHour && number.Contains('.', StringComparison.Ordinal))
+ var cubicMetres = match.Groups["unit"].Success || amount <= 1000 ? amount : amount / 1000;
+ var rounded = (int)Math.Round(cubicMetres, MidpointRounding.AwayFromZero);
+ return rounded > 0 ? rounded : null;
+ }
+
+ // The well-known Lagen, short enough for the marker; anything written out stays on the card only.
+ private static string? Lage(string? value) => value switch
+ {
+ "lane" or "street" => "Fahrbahn",
+ "sidewalk" => "Gehweg",
+ "green" => "Grünfläche",
+ "parking_lot" => "Parkplatz",
+ _ => null,
+ };
+
+ // The outlets by Storz size, largest first and counted, "A, 2×B", from OSM's ";"-list of
+ // letters or millimetres ("B;B;A", "1A / 2B", "75;52"). A list in any other form is kept as
+ // written. Without a list, only how many couplings OSM counts, "2 Abgänge".
+ private static string? Outlets(string? diameters, string? couplings)
+ {
+ if (diameters is not null)
{
- return null;
+ return OutletSizes(diameters);
}
- var litres = perHour ? amount * 1000 / 60 : amount;
- return litres is > 0 and <= plausible ? (int)Math.Round(litres, MidpointRounding.AwayFromZero) : null;
+ return int.TryParse(couplings, NumberStyles.None, CultureInfo.InvariantCulture, out var count) && count is > 0 and < 10
+ ? count == 1 ? "1 Abgang" : $"{count} Abgänge"
+ : null;
+ }
+
+ private static string? OutletSizes(string diameters)
+ {
+ var counts = new SortedDictionary();
+ foreach (var token in OutletSeparator().Split(diameters))
+ {
+ if (token.Length == 0)
+ {
+ continue;
+ }
+
+ var match = OutletValue().Match(token);
+ char? size = !match.Success ? null
+ : match.Groups["letter"].Success ? char.ToUpperInvariant(match.Groups["letter"].Value[0])
+ : match.Groups["mm"].Value switch { "110" => 'A', "75" => 'B', "52" => 'C', "25" => 'D', _ => null };
+ if (size is not { } s)
+ {
+ return diameters.Length > MaxLabelPartLength ? diameters[..MaxLabelPartLength] : diameters;
+ }
+
+ var n = match.Groups["n"].Success ? match.Groups["n"].Value[0] - '0' : 1;
+ counts[s] = counts.GetValueOrDefault(s) + n;
+ }
+
+ return counts.Count == 0 ? null : string.Join(", ", counts.Select(c => c.Value == 1 ? $"{c.Key}" : $"{c.Value}×{c.Key}"));
}
// The Nennweite from "100", "DN 100", "DN100" or "100 mm"; anything else is unknown.
@@ -181,11 +237,14 @@ private static List Details(JsonElement properties)
("Volumen", Tag("water_tank:volume")),
("Kupplungen", Tag("couplings")),
("Kupplungsart", Tag("couplings:type")),
+ ("Abgänge", Tag("couplings:diameters") is { } diameters ? OutletSizes(diameters) : null),
("Lage", HydrantPosition(Tag("fire_hydrant:position"))),
("Wasser aus", WaterSource(Tag("water_source"))),
("Nummer", Tag("ref")),
("Name", Tag("name")),
("Betreiber", Tag("operator")),
+ ("Zugang", Access(Tag("access"))),
+ ("Zuletzt geprüft (OSM)", CheckDate(Tag("check_date") ?? Tag("survey:date"))),
("OSM", osm is not null && OsmId().IsMatch(osm) ? osm : null),
];
var details = new List();
@@ -200,6 +259,12 @@ private static List Details(JsonElement properties)
return details;
}
+ // OSM's "2025-03-01" said the German way, "01.03.2025"; "2025-03" or anything else as it is.
+ private static string? CheckDate(string? value) =>
+ DateOnly.TryParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date)
+ ? Formatting.Date(new DateTimeOffset(date, TimeOnly.MinValue, TimeSpan.Zero))
+ : value;
+
private static string? HydrantType(string? value) => value switch
{
"underground" => "Unterflur",
@@ -210,6 +275,15 @@ private static List Details(JsonElement properties)
_ => value,
};
+ private static string? Access(string? value) => value switch
+ {
+ "private" => "privat",
+ "no" => "kein",
+ "customers" => "Kunden",
+ "yes" or "permissive" => null,
+ _ => value,
+ };
+
private static string? HydrantPosition(string? value) => value switch
{
"sidewalk" => "Gehweg",
@@ -245,8 +319,14 @@ private static List Details(JsonElement properties)
[GeneratedRegex(@"\A(?:node|way|relation)/[0-9]{1,15}\z", RegexOptions.CultureInvariant)]
private static partial Regex OsmId();
- [GeneratedRegex(@"\A(?[0-9]{1,6}(?:[.,][0-9]{1,3})?)\s*(?l/min|m3/h|m³/h)?\z", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)]
- private static partial Regex FlowRateValue();
+ [GeneratedRegex(@"\A(?[0-9]{1,6}(?:[.,][0-9]{1,3})?)\s*(?m3|m³|cbm)?\z", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)]
+ private static partial Regex VolumeValue();
+
+ [GeneratedRegex(@"\s*[;,/]\s*", RegexOptions.CultureInvariant)]
+ private static partial Regex OutletSeparator();
+
+ [GeneratedRegex(@"\A\s*(?:(?:(?[1-9])\s*[x×]?\s*)?(?[A-D])|(?:(?[1-9])\s*[x×]\s*)?(?[0-9]{2,3}))\s*\z", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)]
+ private static partial Regex OutletValue();
[GeneratedRegex(@"\A(?:DN\s*)?(?[0-9]{2,4})(?:\s*mm)?\z", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)]
private static partial Regex DiameterValue();
diff --git a/src/FwAssist.Ui/Map/WaterPointMarkers.cs b/src/FwAssist.Ui/Map/WaterPointMarkers.cs
index d79eb83..33d5302 100644
--- a/src/FwAssist.Ui/Map/WaterPointMarkers.cs
+++ b/src/FwAssist.Ui/Map/WaterPointMarkers.cs
@@ -12,8 +12,9 @@ namespace FwAssist.Ui.Map;
/// a disc centred on it, from
/// a flag whose mast foot stands on it and whose body
/// grows to the right, so the body never covers the spot and close masts stay apart. The glyph in
-/// the coloured field says what it is, the colour the flow class, the numbers on white what is
-/// known, and the body is as wide as its text.
+/// the coloured field says what it is, the colour whether it hangs on the Trinkwassernetz (red) or
+/// is independent of it (blue), the text on white what OSM knows, and the body is as wide as its
+/// text.
///
public static class WaterPointMarkers
{
@@ -22,12 +23,12 @@ public static class WaterPointMarkers
private const double Halo = 3;
- // How wide the Ring/Stich sign after the DN is.
- private const double NetworkWidth = 14;
+ // The zoom-15 disc: the coloured dot's radius, and how far its white contour reaches.
+ private const double DiscRadius = 4;
+ private const double DiscReach = 6;
- // The zoom-15 disc: the class ring's radius, and how far its white contour reaches.
- private const double DiscRing = 5.5;
- private const double DiscReach = 7.5;
+ // Where a flag has no text, the field alone, with this much white after it.
+ private const double EmptyTextWidth = 2;
// How thick the outline of the chosen water point is, and how far its arrow keeps above it.
private const double SelectedOutline = 3.5;
@@ -40,32 +41,18 @@ public static class WaterPointMarkers
private static readonly CultureInfo De = CultureInfo.GetCultureInfo("de-DE");
private static readonly IImmutableBrush Ink = new ImmutableSolidColorBrush(Color.FromRgb(0x21, 0x21, 0x21));
- private static readonly IImmutableBrush UnitInk = new ImmutableSolidColorBrush(Color.FromRgb(0x5F, 0x6B, 0x78));
- private static readonly IImmutableBrush Track = new ImmutableSolidColorBrush(Color.FromRgb(0xD5, 0xD9, 0xDD));
private static readonly IPen HaloPen = new ImmutablePen(Brushes.White, Halo, lineJoin: PenLineJoin.Round);
private static readonly IPen GlyphPen = new ImmutablePen(Brushes.White, 1.4, lineCap: PenLineCap.Round, lineJoin: PenLineJoin.Round);
private static readonly IPen BlockingBar = new ImmutablePen(new ImmutableSolidColorBrush(Color.FromRgb(0xD3, 0x2F, 0x2F)), 2, lineCap: PenLineCap.Round);
private static readonly Typeface Regular = new(FontFamily.Default);
- /// No flow recorded, or none to assess.
- public static IImmutableBrush UnbekanntBrush { get; } = Solid(0x5F, 0x6B, 0x78);
+ /// A hydrant: fed from the Trinkwassernetz. 5.6:1 against the white body.
+ public static IImmutableBrush MainsBrush { get; } = Solid(0xC6, 0x28, 0x28);
- /// Under 400 l/min.
- public static IImmutableBrush Unter400Brush { get; } = Solid(0xB3, 0x26, 0x1E);
+ /// A Saugstelle, Brunnen, Behälter or Teich: independent of the mains. 5.7:1 against white.
+ public static IImmutableBrush IndependentBrush { get; } = Solid(0x15, 0x65, 0xC0);
- /// 400–799 l/min.
- public static IImmutableBrush Bis799Brush { get; } = Solid(0xD9, 0x73, 0x1A);
-
- /// 800–1.599 l/min.
- public static IImmutableBrush Bis1599Brush { get; } = Solid(0xB8, 0x96, 0x0F);
-
- /// 1.600–3.199 l/min.
- public static IImmutableBrush Bis3199Brush { get; } = Solid(0x2E, 0x7D, 0x46);
-
- /// From 3.200 l/min.
- public static IImmutableBrush Ab3200Brush { get; } = Solid(0x0F, 0x5C, 0x6E);
-
- /// Außer Betrieb: the colour gone, whatever the class.
+ /// Außer Betrieb: the colour gone, whatever the source.
public static IImmutableBrush OutOfServiceBrush { get; } = Solid(0x8A, 0x91, 0x99);
/// The arrow over the chosen water point: the app's signal red, on a day and a night map alike.
@@ -101,16 +88,12 @@ public static class WaterPointMarkers
+ "M1,6 Q2.5,4.5 4,6 Q5.5,7.5 7,6 Q8.5,4.5 10,6 L11,6 "
+ "M1,9 Q2.5,7.5 4,9 Q5.5,10.5 7,9 Q8.5,7.5 10,9 L11,9");
- /// The colour of a marker in .
- public static IImmutableBrush ClassBrush(FlowClass flowClass) => flowClass switch
+ /// The colour of 's marker: by its source, grey out of service.
+ public static IImmutableBrush SourceBrush(WaterPoint point)
{
- FlowClass.Unter400 => Unter400Brush,
- FlowClass.Bis799 => Bis799Brush,
- FlowClass.Bis1599 => Bis1599Brush,
- FlowClass.Bis3199 => Bis3199Brush,
- FlowClass.Ab3200 => Ab3200Brush,
- _ => UnbekanntBrush,
- };
+ ArgumentNullException.ThrowIfNull(point);
+ return point.IsOutOfService ? OutOfServiceBrush : point.IsIndependent ? IndependentBrush : MainsBrush;
+ }
/// The glyph of , drawn into a 12-unit square.
public static Geometry Glyph(WaterPointSymbol symbol) => symbol switch
@@ -126,7 +109,7 @@ public static class WaterPointMarkers
///
/// The markers of the inside the visible map, in the order they are
- /// drawn: weakest first, so a strong source lies on top, and the one whose card is open last.
+ /// drawn: by , and the one whose card is open last.
/// Below only the one whose card is open.
///
internal static List LayOut(IReadOnlyList points, GeoPoint center, int zoom, Size size, WaterPoint? selected, double rotation)
@@ -195,37 +178,14 @@ internal static void Draw(DrawingContext context, Marker marker, IImmutableBrush
}
}
- // A dot in the class colour, and around it a ring filled in proportion to the class: what the
- // colour says, said a second time for an eye that cannot tell red from green. No glyph: at
- // zoom 15 a town's hydrants stand a few pixels apart, and a glyph this small reads as a smudge.
+ // A dot in the source's colour on a white contour. No glyph: at zoom 15 a town's hydrants stand
+ // a few pixels apart, and a glyph this small reads as a smudge. Red and blue stay apart for an
+ // eye that cannot tell red from green.
private static void DrawDisc(DrawingContext context, Marker marker, IPen selected)
{
- const double disc = 3.5;
- var ring = DiscRing;
var at = marker.At;
context.DrawEllipse(Brushes.White, null, at, DiscReach, DiscReach);
- context.DrawEllipse(null, new ImmutablePen(Track, 2), at, ring, ring);
- var share = (double)marker.FlowClass / (double)FlowClass.Ab3200;
- if (share >= 1)
- {
- context.DrawEllipse(null, new ImmutablePen(marker.Colour, 2), at, ring, ring);
- }
- else if (share > 0)
- {
- // Clockwise from twelve o'clock.
- var angle = share * 2 * Math.PI;
- var arc = new StreamGeometry();
- using (var path = arc.Open())
- {
- path.BeginFigure(new Point(at.X, at.Y - ring), isFilled: false);
- path.ArcTo(new Point(at.X + (ring * Math.Sin(angle)), at.Y - (ring * Math.Cos(angle))), new Size(ring, ring), 0, share > 0.5, SweepDirection.Clockwise);
- path.EndFigure(isClosed: false);
- }
-
- context.DrawGeometry(null, new ImmutablePen(marker.Colour, 2, lineCap: PenLineCap.Flat), arc);
- }
-
- context.DrawEllipse(marker.Colour, null, at, disc, disc);
+ context.DrawEllipse(marker.Colour, null, at, DiscRadius, DiscRadius);
if (marker.IsSelected)
{
context.DrawEllipse(null, selected, at, DiscReach + 2, DiscReach + 2);
@@ -260,18 +220,15 @@ private static void DrawFlag(DrawingContext context, Marker marker, IPen selecte
DrawGlyph(context, marker.Point.Symbol, new Rect(field.Center.X - (glyph / 2), field.Center.Y - (glyph / 2), glyph, glyph));
var text = marker.TextLeft;
- if (marker.Unit is { } unit && marker.Diameter is { } diameter)
+ if (marker.Secondary is { } secondary)
{
- var top = body.Top + ((body.Height - marker.Flow.Height - diameter.Height) / 2);
- context.DrawText(marker.Flow, new Point(text, top));
- context.DrawText(unit, new Point(text + marker.Flow.Width + 3, top + marker.Flow.Baseline - unit.Baseline));
- var second = top + marker.Flow.Height;
- context.DrawText(diameter, new Point(text, second));
- DrawNetwork(context, marker.Point.Network, colour, new Point(text + diameter.Width + 5, second + (diameter.Height / 2)));
+ var top = body.Top + ((body.Height - marker.Primary.Height - secondary.Height) / 2);
+ context.DrawText(marker.Primary, new Point(text, top));
+ context.DrawText(secondary, new Point(text, top + marker.Primary.Height));
}
else
{
- context.DrawText(marker.Flow, new Point(text, body.Top + ((body.Height - marker.Flow.Height) / 2)));
+ context.DrawText(marker.Primary, new Point(text, body.Top + ((body.Height - marker.Primary.Height) / 2)));
}
if (marker.Point.IsOutOfService)
@@ -280,38 +237,6 @@ private static void DrawFlag(DrawingContext context, Marker marker, IPen selecte
}
}
- // Ringleitung a double arrow, Stichleitung an arrow against an end bar, unknown a dashed line
- // ending in two dots: the convention wasserkarte.info made familiar.
- private static void DrawNetwork(DrawingContext context, WaterNetwork? network, IImmutableBrush colour, Point start)
- {
- var pen = new ImmutablePen(colour, 1.4, lineCap: PenLineCap.Round, lineJoin: PenLineJoin.Round);
- var (x, y) = (start.X, start.Y);
- switch (network)
- {
- case WaterNetwork.Ring:
- context.DrawLine(pen, new Point(x, y), new Point(x + NetworkWidth, y));
- Head(context, pen, new Point(x, y), -1);
- Head(context, pen, new Point(x + NetworkWidth, y), 1);
- break;
- case WaterNetwork.Stich:
- context.DrawLine(pen, new Point(x, y), new Point(x + NetworkWidth - 2, y));
- Head(context, pen, new Point(x + NetworkWidth - 2, y), 1);
- context.DrawLine(pen, new Point(x + NetworkWidth, y - 3), new Point(x + NetworkWidth, y + 3));
- break;
- default:
- context.DrawLine(new ImmutablePen(colour, 1.4, new ImmutableDashStyle([1.5, 1.2], 0)), new Point(x, y), new Point(x + NetworkWidth - 4, y));
- context.DrawEllipse(colour, null, new Point(x + NetworkWidth - 1, y - 2), 0.9, 0.9);
- context.DrawEllipse(colour, null, new Point(x + NetworkWidth - 1, y + 2), 0.9, 0.9);
- break;
- }
- }
-
- private static void Head(DrawingContext context, IPen pen, Point tip, int direction)
- {
- context.DrawLine(pen, tip, new Point(tip.X - (3.0 * direction), tip.Y - 2.5));
- context.DrawLine(pen, tip, new Point(tip.X - (3.0 * direction), tip.Y + 2.5));
- }
-
private static void DrawGlyph(DrawingContext context, WaterPointSymbol symbol, Rect into)
{
var scale = into.Width / GlyphUnits;
@@ -327,13 +252,13 @@ private static void DrawGlyph(DrawingContext context, WaterPointSymbol symbol, R
/// A water point's marker as laid out on the screen: the anchor , and for a
/// flag its , as wide as its longest line of text.
///
- internal sealed record Marker(WaterPoint Point, WaterPointDetailLevel Level, Point At, bool IsSelected, FlowClass FlowClass, Rect Body, double FieldWidth, FormattedText Flow, FormattedText? Unit, FormattedText? Diameter)
+ internal sealed record Marker(WaterPoint Point, WaterPointDetailLevel Level, Point At, bool IsSelected, Rect Body, double FieldWidth, FormattedText Primary, FormattedText? Secondary)
{
/// Whether the marker carries text a map name must keep clear of: every flag, no disc.
public bool HasText => Level != WaterPointDetailLevel.Punkt;
- /// The marker's colour: its class's, or grey out of service.
- public IImmutableBrush Colour => Point.IsOutOfService ? OutOfServiceBrush : ClassBrush(FlowClass);
+ /// The marker's colour: its source's, or grey out of service.
+ public IImmutableBrush Colour => SourceBrush(Point);
/// Where the text starts, right of the coloured field.
public double TextLeft => Body.Left + FieldWidth + 5;
@@ -365,33 +290,21 @@ public Rect Bounds
public static Marker For(WaterPoint point, WaterPointDetailLevel level, Point at, bool isSelected)
{
- var flowClass = WaterPointMarking.Classify(point.FlowLitresPerMinute);
+ var primaryText = WaterPointMarking.PrimaryText(point);
if (WaterPointLayer.FlagFor(level) is not { } flag)
{
- return new Marker(point, level, at, isSelected, flowClass, default, 0, Text(WaterPointMarking.FlowText(point), 12, Ink), null, null);
+ return new Marker(point, level, at, isSelected, default, 0, Text(primaryText, 12, Ink), null);
}
var fieldWidth = Math.Round(flag.BodyHeight * 0.9);
- FormattedText flow;
- FormattedText? unit = null;
- FormattedText? diameter = null;
- double textWidth;
- if (level == WaterPointDetailLevel.Mittel)
- {
- flow = Text(WaterPointMarking.MediumText(point), 13, Ink);
- textWidth = flow.Width;
- }
- else
- {
- flow = Text(WaterPointMarking.FlowText(point), 14, Ink);
- unit = Text("l/min", 8, UnitInk);
- diameter = Text(WaterPointMarking.DiameterText(point), 10, Ink);
- textWidth = Math.Max(flow.Width + 3 + unit.Width, diameter.Width + 5 + NetworkWidth);
- }
-
- var width = Math.Ceiling(fieldWidth + 5 + textWidth + 6);
+ var full = level == WaterPointDetailLevel.Voll;
+ var primary = Text(primaryText, full ? 14 : 13, Ink);
+ var secondaryText = full ? WaterPointMarking.SecondaryText(point) : string.Empty;
+ var secondary = secondaryText.Length > 0 ? Text(secondaryText, 10, Ink) : null;
+ var textWidth = Math.Max(primary.Width, secondary?.Width ?? 0);
+ var width = textWidth > 0 ? Math.Ceiling(fieldWidth + 5 + textWidth + 6) : fieldWidth + EmptyTextWidth;
var body = new Rect(at.X, at.Y - flag.MastLength - flag.BodyHeight, width, flag.BodyHeight);
- return new Marker(point, level, at, isSelected, flowClass, body, fieldWidth, flow, unit, diameter);
+ return new Marker(point, level, at, isSelected, body, fieldWidth, primary, secondary);
}
private static FormattedText Text(string text, double size, IImmutableBrush ink) =>
diff --git a/tests/FwAssist.Acceptance.Tests/FictionalRegionPack.cs b/tests/FwAssist.Acceptance.Tests/FictionalRegionPack.cs
index 5855b7c..4dcc314 100644
--- a/tests/FwAssist.Acceptance.Tests/FictionalRegionPack.cs
+++ b/tests/FwAssist.Acceptance.Tests/FictionalRegionPack.cs
@@ -32,11 +32,11 @@ public static void Install(string root)
private const string WaterPoints = """
{"type": "FeatureCollection", "features": [
- {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2549, 48.1788]}, "properties": {"emergency": "fire_hydrant", "fire_hydrant:type": "underground", "fire_hydrant:diameter": "100", "flow_rate": "1600"}},
- {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2566, 48.1781]}, "properties": {"emergency": "fire_hydrant", "fire_hydrant:type": "pillar", "fire_hydrant:diameter": "150", "flow_rate": "192 m3/h"}},
- {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2537, 48.1776]}, "properties": {"emergency": "fire_hydrant", "fire_hydrant:type": "underground", "fire_hydrant:diameter": "80", "flow_rate": "600 l/min"}},
+ {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2549, 48.1788]}, "properties": {"emergency": "fire_hydrant", "fire_hydrant:type": "underground", "fire_hydrant:diameter": "100", "fire_hydrant:position": "lane"}},
+ {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2566, 48.1781]}, "properties": {"emergency": "fire_hydrant", "fire_hydrant:type": "pillar", "fire_hydrant:diameter": "150", "fire_hydrant:position": "sidewalk", "couplings:diameters": "B;B;A"}},
+ {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2537, 48.1776]}, "properties": {"emergency": "fire_hydrant", "fire_hydrant:type": "underground", "fire_hydrant:diameter": "80"}},
{"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2581, 48.1774]}, "properties": {"emergency": "suction_point", "name": "Musterbach"}},
- {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2560, 48.1792]}, "properties": {"emergency": "suction_point", "water_source": "groundwater", "name": "Brunnen Marktplatz"}}
+ {"type": "Feature", "geometry": {"type": "Point", "coordinates": [11.2560, 48.1792]}, "properties": {"emergency": "water_tank", "water_tank:volume": "100 m³", "access": "private"}}
]}
""";
diff --git a/tests/FwAssist.Acceptance.Tests/MapCanvasControlTests.cs b/tests/FwAssist.Acceptance.Tests/MapCanvasControlTests.cs
index 8d965b0..099cf3e 100644
--- a/tests/FwAssist.Acceptance.Tests/MapCanvasControlTests.cs
+++ b/tests/FwAssist.Acceptance.Tests/MapCanvasControlTests.cs
@@ -25,8 +25,9 @@ public class MapCanvasControlTests
private static readonly Color Land = Color.FromRgb(0xF2, 0xEF, 0xE9);
private static readonly Color Water = Color.FromRgb(0xAA, 0xD3, 0xDF);
- // The 1.600–3.199 l/min class.
- private static readonly Color Green = Color.FromRgb(0x2E, 0x7D, 0x46);
+ // A hydrant on the Trinkwassernetz, and a source independent of it.
+ private static readonly Color Red = Color.FromRgb(0xC6, 0x28, 0x28);
+ private static readonly Color Blue = Color.FromRgb(0x15, 0x65, 0xC0);
// The arrow over the water point whose card is open: the app's signal red.
private static readonly Color Signal = Color.FromRgb(0xFF, 0x3D, 0x2E);
@@ -213,30 +214,28 @@ public void Several_packs_are_drawn_one_over_the_other_in_their_order()
[AvaloniaFact]
public void From_zoom_16_a_water_point_is_a_flag_whose_mast_foot_stands_on_it()
{
- var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant(1600));
+ var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant());
using var frame = window.CaptureRenderedFrame()!;
// The mast narrows to the point; left of it and below it is the map.
- AssertNear(Green, PixelAt(frame, 200, 147));
+ AssertNear(Red, PixelAt(frame, 200, 147));
Assert.Equal(Land, PixelAt(frame, 194, 147));
Assert.Equal(Land, PixelAt(frame, 200, 158));
// The body is above and right of the point: the coloured field, then white.
- AssertNear(Green, PixelAt(frame, MediumField.X, MediumField.Y));
+ AssertNear(Red, PixelAt(frame, MediumField.X, MediumField.Y));
Assert.True(Has(frame, new PixelRect(220, 124, 30, 16), Colors.White));
}
[AvaloniaTheory]
- [InlineData(null, 0x5F6B78)]
- [InlineData(300, 0xB3261E)]
- [InlineData(600, 0xD9731A)]
- [InlineData(1200, 0xB8960F)]
- [InlineData(1600, 0x2E7D46)]
- [InlineData(3200, 0x0F5C6E)]
- public void The_flow_class_colours_the_flag_s_field(int? litresPerMinute, uint rgb)
+ [InlineData(WaterPointKind.Hydrant, 0xC62828)]
+ [InlineData(WaterPointKind.Saugstelle, 0x1565C0)]
+ [InlineData(WaterPointKind.Loeschwasserbehaelter, 0x1565C0)]
+ [InlineData(WaterPointKind.Loeschteich, 0x1565C0)]
+ public void The_source_colours_the_flag_s_field_red_on_the_mains_and_blue_independent_of_it(WaterPointKind kind, uint rgb)
{
- var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant(litresPerMinute));
+ var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant() with { Kind = kind, Label = "Amper" });
using var frame = window.CaptureRenderedFrame()!;
@@ -244,51 +243,49 @@ public void The_flow_class_colours_the_flag_s_field(int? litresPerMinute, uint r
}
[AvaloniaFact]
- public void A_stronger_source_lies_over_a_weaker_one_on_the_same_spot()
+ public void An_independent_source_lies_over_a_hydrant_on_the_same_spot()
{
- var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant(3200), Hydrant(300));
+ var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant() with { Kind = WaterPointKind.Loeschwasserbehaelter }, Hydrant());
using var frame = window.CaptureRenderedFrame()!;
- AssertNear(Color.FromRgb(0x0F, 0x5C, 0x6E), PixelAt(frame, MediumField.X, MediumField.Y));
+ AssertNear(Blue, PixelAt(frame, MediumField.X, MediumField.Y));
}
[AvaloniaFact]
- public void At_zoom_15_a_water_point_is_a_disc_on_it_whose_ring_fills_with_its_class()
+ public void At_zoom_15_a_water_point_is_a_dot_in_its_source_s_colour()
{
- var (window, _, _) = ShowWaterPoints(WaterPointLayer.MinZoom, Hydrant(1600));
+ var (window, _, _) = ShowWaterPoints(WaterPointLayer.MinZoom, Hydrant());
using var frame = window.CaptureRenderedFrame()!;
- AssertNear(Green, PixelAt(frame, 200, 148));
-
- // Four classes of five: from twelve o'clock clockwise past nine, the last fifth left grey.
- AssertNear(Green, PixelAt(frame, 205, 150));
- AssertNear(Green, PixelAt(frame, 194, 150));
- AssertNear(Color.FromRgb(0xD5, 0xD9, 0xDD), PixelAt(frame, 197, 145));
+ AssertNear(Red, PixelAt(frame, 200, 150));
+ AssertNear(Red, PixelAt(frame, 203, 150));
+ AssertNear(Colors.White, PixelAt(frame, 205, 150));
// No flag.
Assert.Equal(Land, PixelAt(frame, 215, 125));
}
[AvaloniaFact]
- public void A_four_digit_estimate_stays_inside_the_flag_s_frame()
+ public void The_full_flag_s_two_lines_stay_inside_its_frame()
{
- var (window, _, _) = ShowWaterPoints(WaterPointLayer.FullMinZoom, Hydrant(1600) with { IsEstimated = true, NominalDiameter = 100 });
+ var (window, _, _) = ShowWaterPoints(WaterPointLayer.FullMinZoom, Hydrant() with { Lage = "Fahrbahn", Outlets = "A, 2×B", IsPrivate = true });
using var frame = window.CaptureRenderedFrame()!;
// Body rows: the mast's 10 px above the point, then 32 px of body.
var (top, bottom) = (150 - 10 - 32, 150 - 10);
- var frameRight = Enumerable.Range(200, 200).Last(x => IsNear(Green, PixelAt(frame, x, (top + bottom) / 2)));
- Assert.True(HasText(frame, new PixelRect(230, top, frameRight - 230, bottom - top)));
+ var frameRight = Enumerable.Range(200, 200).Last(x => IsNear(Red, PixelAt(frame, x, (top + bottom) / 2)));
+ Assert.True(HasText(frame, new PixelRect(230, top, frameRight - 230, (bottom - top) / 2)));
+ Assert.True(HasText(frame, new PixelRect(230, (top + bottom) / 2, frameRight - 230, (bottom - top) / 2)));
Assert.False(HasText(frame, new PixelRect(frameRight + 1, top - 4, 399 - frameRight, bottom - top + 8)));
}
[AvaloniaFact]
public void Out_of_service_the_flag_loses_its_colour_and_is_struck_through_red()
{
- var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant(1600) with { IsOutOfService = true });
+ var (window, _, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, Hydrant() with { IsOutOfService = true });
using var frame = window.CaptureRenderedFrame()!;
@@ -299,7 +296,7 @@ public void Out_of_service_the_flag_loses_its_colour_and_is_struck_through_red()
[AvaloniaFact]
public void The_water_point_whose_card_is_open_is_framed_dark()
{
- var hydrant = Hydrant(1600);
+ var hydrant = Hydrant();
var (window, control, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, hydrant);
var frameTop = new PixelRect(225, 119, 20, 6);
using (var before = window.CaptureRenderedFrame()!)
@@ -319,7 +316,7 @@ public void The_water_point_whose_card_is_open_is_framed_dark()
[AvaloniaFact]
public void A_red_arrow_above_the_open_card_s_flag_points_down_at_it()
{
- var hydrant = Hydrant(1600);
+ var hydrant = Hydrant();
var (window, control, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, hydrant);
var arrow = new PixelRect(204, 95, 10, 15);
using (var before = window.CaptureRenderedFrame()!)
@@ -337,15 +334,15 @@ public void A_red_arrow_above_the_open_card_s_flag_points_down_at_it()
[AvaloniaFact]
public void Further_out_than_zoom_15_the_open_card_s_water_point_is_still_drawn_with_its_arrow()
{
- var chosen = Hydrant(1600);
- var other = new WaterPoint(new GeoPoint(Fuerstenfeldbruck.Latitude, Fuerstenfeldbruck.Longitude + 0.002), WaterPointKind.Hydrant, "UH 80") { FlowLitresPerMinute = 1600 };
+ var chosen = Hydrant();
+ var other = new WaterPoint(new GeoPoint(Fuerstenfeldbruck.Latitude, Fuerstenfeldbruck.Longitude + 0.002), WaterPointKind.Hydrant, "UH 80") { NominalDiameter = 80 };
var (window, control, _) = ShowWaterPoints(WaterPointLayer.MinZoom - 1, chosen, other);
control.SelectedWaterPoint = chosen;
Dispatcher.UIThread.RunJobs();
using var frame = window.CaptureRenderedFrame()!;
- AssertNear(Green, PixelAt(frame, 200, 150));
+ AssertNear(Red, PixelAt(frame, 200, 150));
Assert.True(Has(frame, new PixelRect(196, 110, 8, 15), Signal));
var (x, _) = WebMercator.ToWorldPixel(other.Position, WaterPointLayer.MinZoom - 1);
var (centreX, _) = WebMercator.ToWorldPixel(Fuerstenfeldbruck, WaterPointLayer.MinZoom - 1);
@@ -355,7 +352,7 @@ public void Further_out_than_zoom_15_the_open_card_s_water_point_is_still_drawn_
[AvaloniaFact]
public void On_the_night_map_the_open_card_s_flag_keeps_its_white_body_and_is_framed_light()
{
- var hydrant = Hydrant(1600);
+ var hydrant = Hydrant();
var (window, control, _) = ShowWaterPoints(WaterPointLayer.MediumMinZoom, hydrant);
control.IsNight = true;
control.SelectedWaterPoint = hydrant;
@@ -548,8 +545,8 @@ private static (Window Window, MapCanvasControl Control, MapViewport Viewport) S
return (window, control, viewport);
}
- private static WaterPoint Hydrant(int? litresPerMinute) =>
- new(Fuerstenfeldbruck, WaterPointKind.Hydrant, "UH 100") { FlowLitresPerMinute = litresPerMinute };
+ private static WaterPoint Hydrant() =>
+ new(Fuerstenfeldbruck, WaterPointKind.Hydrant, "UH 100") { NominalDiameter = 100 };
private static (Window Window, MapCanvasControl Control, MapViewport Viewport) ShowWaterPoints(int zoom, params WaterPoint[] points)
{
diff --git a/tests/FwAssist.AppLogic.Tests/WaterPointLayerTests.cs b/tests/FwAssist.AppLogic.Tests/WaterPointLayerTests.cs
index 11cfd68..0b2cb37 100644
--- a/tests/FwAssist.AppLogic.Tests/WaterPointLayerTests.cs
+++ b/tests/FwAssist.AppLogic.Tests/WaterPointLayerTests.cs
@@ -33,41 +33,52 @@ public void Of_two_points_in_reach_the_nearer_one_is_meant()
}
[Fact]
- public void Of_two_points_on_the_same_spot_the_stronger_one_drawn_on_top_is_meant()
+ public void Of_two_hydrants_on_the_same_spot_the_larger_dn_drawn_on_top_is_meant()
{
- var weak = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 80") { FlowLitresPerMinute = 600 };
- var strong = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "ÜH 150") { FlowLitresPerMinute = 3200 };
+ var small = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 80") { NominalDiameter = 80 };
+ var large = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "ÜH 150") { NominalDiameter = 150 };
- Assert.Same(strong, WaterPointLayer.At([weak, strong], Marktplatz, 17));
- Assert.Same(strong, WaterPointLayer.At([strong, weak], Marktplatz, 17));
+ Assert.Same(large, WaterPointLayer.At([small, large], Marktplatz, 17));
+ Assert.Same(large, WaterPointLayer.At([large, small], Marktplatz, 17));
+ }
+
+ [Fact]
+ public void An_independent_source_lies_over_a_hydrant_and_a_hydrant_of_unknown_dn_lies_lowest()
+ {
+ var unknown = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH");
+ var hydrant = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "ÜH 400") { NominalDiameter = 400 };
+ var tank = new WaterPoint(Marktplatz, WaterPointKind.Loeschwasserbehaelter, "Z 3");
+
+ Assert.True(WaterPointLayer.StackRank(unknown, null) < WaterPointLayer.StackRank(hydrant, null));
+ Assert.Same(tank, WaterPointLayer.At([tank, hydrant, unknown], Marktplatz, 17));
}
[Fact]
public void Of_two_points_on_the_same_spot_the_open_one_drawn_on_top_is_meant()
{
- var weak = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 80") { FlowLitresPerMinute = 600 };
- var strong = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "ÜH 150") { FlowLitresPerMinute = 3200 };
+ var small = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 80") { NominalDiameter = 80 };
+ var tank = new WaterPoint(Marktplatz, WaterPointKind.Loeschwasserbehaelter, "Z 3");
- Assert.Same(weak, WaterPointLayer.At([weak, strong], Marktplatz, 17, selected: weak));
+ Assert.Same(small, WaterPointLayer.At([small, tank], Marktplatz, 17, selected: small));
}
[Fact]
public void Of_two_equal_points_on_the_same_spot_the_later_one_drawn_over_the_other_is_meant()
{
- var first = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 100") { FlowLitresPerMinute = 1600 };
- var second = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 100") { FlowLitresPerMinute = 1600 };
+ var first = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 100") { NominalDiameter = 100 };
+ var second = new WaterPoint(Marktplatz, WaterPointKind.Hydrant, "UH 100") { NominalDiameter = 100 };
Assert.Same(second, WaterPointLayer.At([first, second], Marktplatz, 17));
}
- // Each edge of the full flag's body (mast 10, body 32 high, 100 wide), a finger's spare of 4 px
+ // Each edge of the full flag's body (mast 10, body 32 high, 120 wide), a finger's spare of 4 px
// beyond it: 2 px inside that reach still means the point, 2 px outside means none. Every tap is
// further from the foot than a fingertip, so only the flag can catch it.
[Theory]
[InlineData(-2, -44, true)]
[InlineData(-6, -44, false)]
- [InlineData(102, -26, true)]
- [InlineData(106, -26, false)]
+ [InlineData(122, -26, true)]
+ [InlineData(126, -26, false)]
[InlineData(50, -44, true)]
[InlineData(50, -48, false)]
[InlineData(50, -8, true)]
diff --git a/tests/FwAssist.AppLogic.Tests/WaterPointMarkingTests.cs b/tests/FwAssist.AppLogic.Tests/WaterPointMarkingTests.cs
index 394cb23..3fd40ad 100644
--- a/tests/FwAssist.AppLogic.Tests/WaterPointMarkingTests.cs
+++ b/tests/FwAssist.AppLogic.Tests/WaterPointMarkingTests.cs
@@ -8,52 +8,48 @@ public class WaterPointMarkingTests
private static readonly WaterPoint Hydrant = new(new GeoPoint(48.1785, 11.2555), WaterPointKind.Hydrant, "UH 100");
[Theory]
- [InlineData(null, FlowClass.Unbekannt)]
- [InlineData(0, FlowClass.Unter400)]
- [InlineData(399, FlowClass.Unter400)]
- [InlineData(400, FlowClass.Bis799)]
- [InlineData(799, FlowClass.Bis799)]
- [InlineData(800, FlowClass.Bis1599)]
- [InlineData(1599, FlowClass.Bis1599)]
- [InlineData(1600, FlowClass.Bis3199)]
- [InlineData(3199, FlowClass.Bis3199)]
- [InlineData(3200, FlowClass.Ab3200)]
- [InlineData(12000, FlowClass.Ab3200)]
- public void A_flow_falls_into_its_class_at_the_richtwerte(int? litresPerMinute, FlowClass expected) =>
- Assert.Equal(expected, WaterPointMarking.Classify(litresPerMinute));
+ [InlineData(100, "DN 100")]
+ [InlineData(null, "DN ?")]
+ public void A_hydrant_s_first_line_is_its_dn_or_a_question_mark(int? dn, string expected) =>
+ Assert.Equal(expected, WaterPointMarking.PrimaryText(Hydrant with { NominalDiameter = dn }));
+
+ [Theory]
+ [InlineData(100, "Z 3", "100 m³")]
+ [InlineData(null, "Z 3", "Z 3")]
+ [InlineData(null, "", "")]
+ public void A_tank_s_first_line_is_its_volume_or_else_its_label(int? volume, string label, string expected) =>
+ Assert.Equal(expected, WaterPointMarking.PrimaryText(Hydrant with { Kind = WaterPointKind.Loeschwasserbehaelter, Label = label, VolumeCubicMetres = volume }));
+
+ [Theory]
+ [InlineData(WaterPointKind.Saugstelle)]
+ [InlineData(WaterPointKind.Loeschteich)]
+ public void Open_water_s_first_line_is_its_label(WaterPointKind kind) =>
+ Assert.Equal("Amper", WaterPointMarking.PrimaryText(Hydrant with { Kind = kind, Label = "Amper", NominalDiameter = 100 }));
[Fact]
- public void The_classes_run_from_weakest_to_strongest_which_is_the_drawing_order() =>
+ public void The_second_line_joins_lage_outlets_and_private_access() =>
Assert.Equal(
- [FlowClass.Unbekannt, FlowClass.Unter400, FlowClass.Bis799, FlowClass.Bis1599, FlowClass.Bis3199, FlowClass.Ab3200],
- Enum.GetValues().Order());
+ "Fahrbahn · A, 2×B · privat",
+ WaterPointMarking.SecondaryText(Hydrant with { Lage = "Fahrbahn", Outlets = "A, 2×B", IsPrivate = true }));
- [Theory]
- [InlineData(null, false, "?")]
- [InlineData(null, true, "?")]
- [InlineData(300, false, "300")]
- [InlineData(1600, false, "1600")]
- [InlineData(9999, false, "9999")]
- [InlineData(10000, false, "10k")]
- [InlineData(12999, false, "12k")]
- [InlineData(1600, true, "(1600)")]
- [InlineData(12000, true, "(12k)")]
- public void The_flow_is_shown_short_with_brackets_for_an_estimate(int? litresPerMinute, bool estimated, string expected) =>
- Assert.Equal(expected, WaterPointMarking.FlowText(Hydrant with { FlowLitresPerMinute = litresPerMinute, IsEstimated = estimated }));
+ [Fact]
+ public void The_second_line_leaves_out_what_is_unknown_and_is_empty_without_anything()
+ {
+ Assert.Equal("Gehweg", WaterPointMarking.SecondaryText(Hydrant with { Lage = "Gehweg" }));
+ Assert.Equal(string.Empty, WaterPointMarking.SecondaryText(Hydrant));
+ }
[Theory]
- [InlineData(100, "DN 100")]
- [InlineData(null, "DN ?")]
- public void The_diameter_line_says_dn_or_a_question_mark(int? dn, string expected) =>
- Assert.Equal(expected, WaterPointMarking.DiameterText(Hydrant with { NominalDiameter = dn }));
+ [InlineData(WaterPointKind.Hydrant, false)]
+ [InlineData(WaterPointKind.Saugstelle, true)]
+ [InlineData(WaterPointKind.Loeschwasserbehaelter, true)]
+ [InlineData(WaterPointKind.Loeschteich, true)]
+ public void Only_a_hydrant_hangs_on_the_mains(WaterPointKind kind, bool independent) =>
+ Assert.Equal(independent, (Hydrant with { Kind = kind }).IsIndependent);
- [Theory]
- [InlineData(1600, 100, "1600")]
- [InlineData(null, 100, "DN 100")]
- [InlineData(null, null, "?")]
- [InlineData(800, null, "800")]
- public void A_medium_flag_shows_the_flow_or_without_one_the_dn(int? litresPerMinute, int? dn, string expected) =>
- Assert.Equal(expected, WaterPointMarking.MediumText(Hydrant with { FlowLitresPerMinute = litresPerMinute, NominalDiameter = dn }));
+ [Fact]
+ public void A_source_set_explicitly_is_kept() =>
+ Assert.True((Hydrant with { IsIndependent = true }).IsIndependent);
[Theory]
[InlineData(WaterPointKind.Hydrant, WaterPointSymbol.Unterflurhydrant)]
diff --git a/tests/FwAssist.AppLogic.Tests/WaterPointsGeoJsonTests.cs b/tests/FwAssist.AppLogic.Tests/WaterPointsGeoJsonTests.cs
index 34dcb4e..d84f76f 100644
--- a/tests/FwAssist.AppLogic.Tests/WaterPointsGeoJsonTests.cs
+++ b/tests/FwAssist.AppLogic.Tests/WaterPointsGeoJsonTests.cs
@@ -105,29 +105,126 @@ public void Each_kind_gets_the_glyph_of_what_OSM_says_it_is(string emergency, st
Assert.Equal(symbol, Assert.Single(Points(Feature(emergency, properties))).Symbol);
[Theory]
- [InlineData("1600", 1600)]
- [InlineData("1600 l/min", 1600)]
- [InlineData("1600l/min", 1600)]
- [InlineData("96 m3/h", 1600)]
- [InlineData("96 m³/h", 1600)]
- [InlineData("48,5 m3/h", 808)]
- public void A_flow_rate_is_read_in_litres_per_minute(string flowRate, int litresPerMinute) =>
- Assert.Equal(litresPerMinute, Assert.Single(Points(Feature("fire_hydrant", $"\"flow_rate\": \"{flowRate}\""))).FlowLitresPerMinute);
+ [InlineData("fire_hydrant", "\"osm\": \"node/1\"", false)]
+ [InlineData("fire_hydrant", "\"water_source\": \"main\"", false)]
+ [InlineData("fire_hydrant", "\"water_source\": \"pond\"", true)]
+ [InlineData("fire_hydrant", "\"water_source\": \"river\"", true)]
+ [InlineData("fire_hydrant", "\"water_source\": \"water_tank\"", true)]
+ [InlineData("fire_hydrant", "\"water_source\": \"groundwater\"", true)]
+ [InlineData("suction_point", "\"osm\": \"node/1\"", true)]
+ [InlineData("water_tank", "\"water_source\": \"main\"", true)]
+ public void A_hydrant_fed_from_open_water_a_well_or_a_tank_is_independent_of_the_mains(string emergency, string properties, bool independent) =>
+ Assert.Equal(independent, Assert.Single(Points(Feature(emergency, properties))).IsIndependent);
[Theory]
+ [InlineData("1600 l/min")]
[InlineData("1.600 l/min")]
[InlineData("viel")]
+ public void A_flow_rate_is_shown_on_the_card_as_OSM_spells_it(string flowRate) =>
+ Assert.Contains(new WaterPointDetail("Förderleistung", flowRate), Assert.Single(Points(Feature("fire_hydrant", $"\"flow_rate\": \"{flowRate}\""))).Details);
+
+ [Theory]
+ [InlineData("B;B;A", "A, 2×B")]
+ [InlineData("B;B;", "2×B")]
+ [InlineData("1A;2B", "A, 2×B")]
+ [InlineData("1A / 2B", "A, 2×B")]
+ [InlineData("C;C;B", "B, 2×C")]
+ [InlineData("75;52", "B, C")]
+ [InlineData("110;75;75", "A, 2×B")]
+ [InlineData("b; c", "B, C")]
+ public void The_outlets_are_counted_by_storz_size(string diameters, string outlets) =>
+ Assert.Equal(outlets, Assert.Single(Points(Feature("fire_hydrant", $"\"couplings:diameters\": \"{diameters}\""))).Outlets);
+
+ [Theory]
+ [InlineData("\"couplings:diameters\": \"2 x 3 Zoll\"", "2 x 3 Zoll")]
+ [InlineData("\"couplings\": \"2\"", "2 Abgänge")]
+ [InlineData("\"couplings\": \"1\"", "1 Abgang")]
+ [InlineData("\"couplings\": \"2\", \"couplings:diameters\": \"B;C\"", "B, C")]
+ public void Outlets_OSM_does_not_size_are_kept_as_written_or_counted(string properties, string outlets) =>
+ Assert.Equal(outlets, Assert.Single(Points(Feature("fire_hydrant", properties))).Outlets);
+
+ [Theory]
+ [InlineData("\"couplings\": \"150\"")]
+ [InlineData("\"couplings\": \"zwei\"")]
+ [InlineData("\"osm\": \"node/1\"")]
+ public void Without_a_plausible_outlet_count_there_are_no_outlets(string properties) =>
+ Assert.Null(Assert.Single(Points(Feature("fire_hydrant", properties))).Outlets);
+
+ [Theory]
+ [InlineData("lane", "Fahrbahn")]
+ [InlineData("street", "Fahrbahn")]
+ [InlineData("sidewalk", "Gehweg")]
+ [InlineData("green", "Grünfläche")]
+ [InlineData("parking_lot", "Parkplatz")]
+ public void A_well_known_lage_is_put_on_the_marker_in_german(string position, string lage) =>
+ Assert.Equal(lage, Assert.Single(Points(Feature("fire_hydrant", $"\"fire_hydrant:position\": \"{position}\""))).Lage);
+
+ [Fact]
+ public void A_lage_written_out_in_free_text_stays_off_the_marker_and_on_the_card()
+ {
+ var point = Assert.Single(Points(Feature("fire_hydrant", "\"fire_hydrant:position\": \"Fahrbahnrand\"")));
+
+ Assert.Null(point.Lage);
+ Assert.Contains(new WaterPointDetail("Lage", "Fahrbahnrand"), point.Details);
+ }
+
+ [Theory]
+ [InlineData("250 m³", 250)]
+ [InlineData("300m³", 300)]
+ [InlineData("150 m3", 150)]
+ [InlineData("100", 100)]
+ [InlineData("100000", 100)]
+ [InlineData("1000", 1000)]
+ [InlineData("10000", 10)]
+ [InlineData("20000", 20)]
+ public void A_tank_s_volume_is_read_in_cubic_metres_and_a_bare_figure_of_ten_thousand_or_more_as_litres(string volume, int cubicMetres) =>
+ Assert.Equal(cubicMetres, Assert.Single(Points(Feature("water_tank", $"\"water_tank:volume\": \"{volume}\""))).VolumeCubicMetres);
+
+ [Theory]
+ [InlineData("groß")]
[InlineData("0")]
- [InlineData("999999")]
- [InlineData("1600 bar")]
- public void A_flow_rate_that_is_no_sure_figure_reads_as_unknown_and_stays_on_the_card(string flowRate)
+ [InlineData("ca. 100")]
+ [InlineData("1001")]
+ [InlineData("2000")]
+ [InlineData("9999")]
+ public void A_volume_that_is_no_sure_figure_reads_as_unknown_and_stays_on_the_card(string volume)
+ {
+ var point = Assert.Single(Points(Feature("water_tank", $"\"water_tank:volume\": \"{volume}\"")));
+
+ Assert.Null(point.VolumeCubicMetres);
+ Assert.Contains(new WaterPointDetail("Volumen", volume), point.Details);
+ }
+
+ [Theory]
+ [InlineData("private", true, "privat")]
+ [InlineData("no", true, "kein")]
+ [InlineData("customers", false, "Kunden")]
+ [InlineData("yes", false, null)]
+ [InlineData("permissive", false, null)]
+ public void Access_is_said_on_the_card_and_private_ground_marked(string access, bool isPrivate, string? row)
{
- var point = Assert.Single(Points(Feature("fire_hydrant", $"\"flow_rate\": \"{flowRate}\"")));
+ var point = Assert.Single(Points(Feature("fire_hydrant", $"\"access\": \"{access}\"")));
- Assert.Null(point.FlowLitresPerMinute);
- Assert.Contains(new WaterPointDetail("Förderleistung", flowRate), point.Details);
+ Assert.Equal(isPrivate, point.IsPrivate);
+ Assert.Equal(row, point.Details.SingleOrDefault(d => d.Label == "Zugang")?.Value);
}
+ [Theory]
+ [InlineData("\"survey:date\": \"2018-03-24\"", "24.03.2018")]
+ [InlineData("\"check_date\": \"2025-03-01\", \"survey:date\": \"2018-03-24\"", "01.03.2025")]
+ [InlineData("\"check_date\": \"2025-03\"", "2025-03")]
+ [InlineData("\"check_date\": \"2025-02-30\"", "2025-02-30")]
+ [InlineData("\"survey:date\": \"2.2.2018\"", "2.2.2018")]
+ public void The_card_says_in_german_when_a_mapper_last_checked_the_point_and_keeps_any_other_spelling(string properties, string date) =>
+ Assert.Contains(new WaterPointDetail("Zuletzt geprüft (OSM)", date), Assert.Single(Points(Feature("fire_hydrant", properties))).Details);
+
+ [Fact]
+ public void The_card_lists_the_outlets_after_the_couplings() =>
+ Assert.Equal(
+ [("Kupplungen", "3"), ("Abgänge", "A, 2×B")],
+ Assert.Single(Points(Feature("fire_hydrant", "\"couplings\": \"3\", \"couplings:diameters\": \"B;B;A\""))).Details
+ .Where(d => d.Label is "Kupplungen" or "Abgänge").Select(d => (d.Label, d.Value)));
+
[Theory]
[InlineData("100", 100)]
[InlineData("DN 100", 100)]
@@ -145,14 +242,8 @@ public void A_diameter_spelled_any_other_way_reads_as_unknown(string diameter) =
Assert.Null(Assert.Single(Points(Feature("fire_hydrant", $"\"fire_hydrant:diameter\": \"{diameter}\""))).NominalDiameter);
[Fact]
- public void A_packs_point_is_never_estimated_out_of_service_or_on_a_known_network()
- {
- var point = Assert.Single(Points(Hydrant));
-
- Assert.False(point.IsEstimated);
- Assert.False(point.IsOutOfService);
- Assert.Null(point.Network);
- }
+ public void A_packs_point_is_never_out_of_service() =>
+ Assert.False(Assert.Single(Points(Hydrant)).IsOutOfService);
[Fact]
public void A_label_part_longer_than_its_cap_is_cut()