GeoApiProjection protected properties

This commit is contained in:
Clemens 2022-01-21 16:55:00 +01:00
parent 544ac32ee3
commit be0e06f581
3 changed files with 13 additions and 24 deletions

View file

@ -30,13 +30,14 @@ namespace MapControl.Projections
private double scaleFactor;
private string bboxFormat;
public GeoApiProjection(string wkt = null)
protected GeoApiProjection()
{
if (wkt != null)
}
public GeoApiProjection(string wkt)
{
WKT = wkt;
}
}
/// <summary>
/// Gets or sets an OGC Well-known text representation of a coordinate system,
@ -46,7 +47,7 @@ namespace MapControl.Projections
public string WKT
{
get { return CoordinateSystem?.WKT; }
set { CoordinateSystem = new CoordinateSystemFactory().CreateFromWkt(value); }
protected set { CoordinateSystem = new CoordinateSystemFactory().CreateFromWkt(value); }
}
/// <summary>
@ -55,7 +56,7 @@ namespace MapControl.Projections
public ICoordinateSystem CoordinateSystem
{
get { return coordinateSystem; }
set
protected set
{
coordinateSystem = value ?? throw new ArgumentNullException(nameof(value));

View file

@ -9,10 +9,6 @@ namespace MapControl.Projections
{
public class UtmProjection : GeoApiProjection
{
public UtmProjection()
{
}
public UtmProjection(int zone, bool north)
{
SetZone(zone, north);
@ -20,17 +16,12 @@ namespace MapControl.Projections
public UtmProjection(Location location)
{
SetZone(location);
var zone = Math.Min((int)Math.Floor(Location.NormalizeLongitude(location.Longitude) + 180d) / 6 + 1, 60);
SetZone(zone, location.Latitude >= 0d);
}
public void SetZone(Location location)
{
var zoneNumber = Math.Min((int)(Location.NormalizeLongitude(location.Longitude) + 180d) / 6 + 1, 60);
SetZone(zoneNumber, location.Latitude >= 0d);
}
public void SetZone(int zone, bool north)
protected void SetZone(int zone, bool north)
{
if (zone < 1 || zone > 60)
{

View file

@ -25,10 +25,7 @@ namespace ProjectionDemo
{
viewModel.Projections.Add(new MapControl.Projections.WebMercatorProjection());
viewModel.Projections.Add(new GeoApiProjection
{
WKT = await httpClient.GetStringAsync("https://epsg.io/25832.wkt") // ETRS89 / UTM zone 32N
});
viewModel.Projections.Add(new GeoApiProjection(await httpClient.GetStringAsync("https://epsg.io/25832.wkt"))); // ETRS89 / UTM zone 32N
viewModel.Layers.Add(
"OpenStreetMap WMS",