1using System.Text.RegularExpressions;
21 return Position.LiesOutside(Min, Max,
false,
false,
false);
36 bool IncludeMin,
bool IncludeMax)
38 return Position.LiesOutside(Min, Max, IncludeMin, IncludeMax,
false);
54 bool IncludeMin,
bool IncludeMax,
bool IgnoreAltitude)
82 private static bool OutOfRange(
this double Value,
double? Min,
double? Max,
83 bool IncludeMin,
bool IncludeMax)
85 int MinComp = Min.HasValue ? Value.CompareTo(Min.Value) : 1;
86 int MaxComp = Max.HasValue ? Value.CompareTo(Max.Value) : -1;
88 if (MinComp < 0 || IncludeMin && MinComp == 0)
91 if (MaxComp > 0 || IncludeMax && MaxComp == 0)
97 private static bool InRange(
this double Value,
double? Min,
double? Max,
98 bool IncludeMin,
bool IncludeMax)
100 int MinComp = Min.HasValue ? Value.CompareTo(Min.Value) : 1;
101 int MaxComp = Max.HasValue ? Value.CompareTo(Max.Value) : -1;
103 if (MinComp < 0 || (!IncludeMin && MinComp == 0))
106 if (MaxComp > 0 || (!IncludeMax && MaxComp == 0))
124 return i > 0 || (IncludeReference && i == 0);
139 return i < 0 || (IncludeReference && i == 0);
154 return i > 0 || (IncludeReference && i == 0);
169 return i < 0 || (IncludeReference && i == 0);
181 return Position.NorthOf(Reference.
Max, !Reference.
IncludeMax);
193 return Position.SouthOf(Reference.
Min, !Reference.
IncludeMin);
206 return Position.EastOf(Reference.
Min, !Reference.
IncludeMin);
208 return Position.EastOf(Reference.
Max, !Reference.
IncludeMax);
221 return Position.WestOf(Reference.
Max, !Reference.
IncludeMax);
223 return Position.WestOf(Reference.
Min, !Reference.
IncludeMin);
252 Match M = Pattern.Match(GeoId);
254 return M.Success && M.Index == 0 && M.Length == GeoId.Length;
Extension methods for geo-spatial calculations.
static bool EastOf(this GeoPosition Position, IGeoBoundingBox Reference)
If a Position is east of a bounding box Reference .
static bool SouthOf(this GeoPosition Position, GeoPosition Reference, bool IncludeReference)
If a Position is south of a reference point Reference . The reference point itself will be included ...
static bool LiesOutside(this GeoPosition Position, GeoPosition Min, GeoPosition Max, bool IncludeMin, bool IncludeMax)
Checks if a position lies outside a given bounding box, using the Mercator projection....
static bool LiesOutside(this GeoPosition Position, GeoPosition Min, GeoPosition Max, bool IncludeMin, bool IncludeMax, bool IgnoreAltitude)
Checks if a position lies outside a given bounding box, using the Mercator projection....
static bool EastOf(this GeoPosition Position, GeoPosition Reference, bool IncludeReference)
If a Position is east of a reference point Reference . The reference point itself will be included i...
static bool LiesOutside(this GeoPosition Position, GeoPosition Min, GeoPosition Max)
Checks if a position lies outside a given bounding box, using the Mercator projection....
static bool SouthOf(this GeoPosition Position, IGeoBoundingBox Reference)
If a Position is south of a bounding box Reference .
static bool NorthOf(this GeoPosition Position, IGeoBoundingBox Reference)
If a Position is north of a bounding box Reference .
static bool WestOf(this GeoPosition Position, GeoPosition Reference, bool IncludeReference)
If a Position is west of a reference point Reference . The reference point itself will be included i...
static bool AltitudeCheck(this GeoPosition Position, IGeoBoundingBox Reference)
If the altitude defined by Position (if any) lies within the scope of the bounding box Reference (i...
static bool GeoIdPatternCheck(this string GeoId, Regex Pattern)
If the Geo-spatial ID matches a given pattern, defined as a regular expression.
static bool WestOf(this GeoPosition Position, IGeoBoundingBox Reference)
If a Position is west of a bounding box Reference .
static bool NorthOf(this GeoPosition Position, GeoPosition Reference, bool IncludeReference)
If a Position is north of a reference point Reference . The reference point itself will be included ...
Contains information about a position in a geo-spatial coordinate system.
double Longitude
Longitude in degrees.
double? Altitude
Altitude in meters. Can be null.
double Latitude
Latitude in degrees.
Interface for a geo-spatial bounding box using the Mercator Projection.
bool IncludeMax
If the max latitude/longitude/altitude should be considered as included in the boundoing box.
bool LongitudeWrapped
If the bounding box is longitude-wrapped, i.e. if the box passes the +-180 degrees longitude.
GeoPosition Max
Upper-right corner of bounding box.
bool IncludeMin
If the min latitude/longitude/altitude should be considered as included in the boundoing box.
GeoPosition Min
Lower-left corner of bounding box.