mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Added enum Hemisphere
This commit is contained in:
parent
4166bd34d1
commit
1f75e9feea
6 changed files with 47 additions and 41 deletions
|
|
@ -3,8 +3,9 @@
|
|||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// WGS84 Universal Transverse Mercator Projection with
|
||||
/// automatic zone selection from projection center.
|
||||
/// WGS84 Universal Transverse Mercator Projection with automatic zone selection from
|
||||
/// the projection center. If the CRS Id passed to the constructor is null or empty,
|
||||
/// appropriate CRS Ids EPSG:32601 to EPSG:32660 and EPSG:32701 to EPSG:32760 are used.
|
||||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
|
|
@ -16,11 +17,8 @@ namespace MapControl.Projections
|
|||
// XAML needs parameterless constructor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the crsId parameter is null or empty, the projection will use EPSG:32***.
|
||||
/// </summary>
|
||||
public Wgs84AutoUtmProjection(string crsId)
|
||||
: base(31, true)
|
||||
: base(31, Hemisphere.North)
|
||||
{
|
||||
autoCrsId = crsId;
|
||||
|
||||
|
|
@ -41,11 +39,11 @@ namespace MapControl.Projections
|
|||
|
||||
var lon = Location.NormalizeLongitude(value.Longitude);
|
||||
var zone = (int)Math.Floor(lon / 6d) + 31;
|
||||
var north = value.Latitude >= 0d;
|
||||
var hemisphere = value.Latitude >= 0d ? Hemisphere.North : Hemisphere.South;
|
||||
|
||||
if (Zone != zone || IsNorth != north)
|
||||
if (Zone != zone || Hemisphere != hemisphere)
|
||||
{
|
||||
SetZone(zone, north);
|
||||
SetZone(zone, hemisphere);
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ namespace MapControl.Projections
|
|||
public const int LastZoneSouthEpsgCode = 32700 + LastZone;
|
||||
|
||||
public int Zone { get; private set; }
|
||||
public bool IsNorth { get; private set; }
|
||||
public Hemisphere Hemisphere { get; private set; }
|
||||
|
||||
public Wgs84UtmProjection(int zone, bool north)
|
||||
public Wgs84UtmProjection(int zone, Hemisphere hemisphere)
|
||||
{
|
||||
SetZone(zone, north);
|
||||
SetZone(zone, hemisphere);
|
||||
}
|
||||
|
||||
protected void SetZone(int zone, bool north)
|
||||
protected void SetZone(int zone, Hemisphere hemisphere)
|
||||
{
|
||||
if (zone < FirstZone || zone > LastZone)
|
||||
{
|
||||
|
|
@ -31,8 +31,8 @@ namespace MapControl.Projections
|
|||
}
|
||||
|
||||
Zone = zone;
|
||||
IsNorth = north;
|
||||
CoordinateSystem = ProjectedCoordinateSystem.WGS84_UTM(Zone, IsNorth);
|
||||
Hemisphere = hemisphere;
|
||||
CoordinateSystem = ProjectedCoordinateSystem.WGS84_UTM(Zone, hemisphere == Hemisphere.North);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue