Skip to content

Commit

Permalink
Corrected definitions of proj4 strings for Swedish grids. They includ…
Browse files Browse the repository at this point in the history
…e the towgs parameter which fixes re-projection errors. Closes DotSpatial#861.
  • Loading branch information
pedwik authored and mogikanin committed Oct 3, 2016
1 parent d1c3900 commit c065a77
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 30 deletions.
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
- Changed Filename to absolute path so it stays the same even if CurrentDirectory is changed
- Renamed IntervalMethod.Quantile to IntervalMethod.EqualFrequency for better consistency.
- IHeaderControl.Add() now returns object which represents added GUI item.
- Added authority and authority code as optional parameters to method ProjectionInfo.FromProj4String.

### Removed
- Removed DotSpatial.Topology assembly (#633)
Expand Down Expand Up @@ -67,4 +68,5 @@ All notable changes to this project will be documented in this file.
- Problem in rendering ECW images (#824)
- Polygon layer - scheme partially resets when open properties window (#842)
- Index Glitch in GdalRaster with Very Large Rasters (#849)
- Map Frame Dragging (#772)
- Map Frame Dragging (#772)
- Fixed reprojection errors between RT90 and SWEREF99, caused by missing TOWGS parameters in transformation attributes (#861)
1 change: 1 addition & 0 deletions Contributors
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Christoph Perger <[email protected]>
Gerrit Schoups <[email protected]>
Martin Karing <[email protected]>
Florian Fuchs <[email protected]>
Peder Wikstrom <[email protected]>
47 changes: 47 additions & 0 deletions Source/DotSpatial.Projections.Tests/ReprojectTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Configuration;
using System.Security.Cryptography;
using NUnit.Framework;

namespace DotSpatial.Projections.Tests
Expand Down Expand Up @@ -84,5 +86,50 @@ public void OSGB36_Reprojection()
Assert.AreEqual(expectedX, xy[0], eps);
Assert.AreEqual(expectedY, xy[1], eps);
}

[TestCase(3021, 3006, new double[] { 1366152.968, 6851307.390 }, new double[] { 408700, 6847800 }, 0.08)] // tolerance 8 cm
[TestCase(3006, 3021, new double[] { 408700, 6847800 }, new double[] { 1366152.968, 6851307.390 }, 0.08)] // tolerance 8 cm
[TestCase(3013, 3006, new double[] { 19061.000, 6851822.032 }, new double[] { 408700, 6847800 }, 1E-3)] // tolerance 1 mm
[TestCase(3022, 3021, new double[] { 1536875.736, 7037950.238 }, new double[] { 1649079.352, 7041217.283 }, 1E-3)] // tolerance 1 mm
public void Reproject_Swedish_Projections_Using_AuthorityCodes(int fromEpsgCode, int toEpsgCode, double[] xy, double[] expected, double tolerance )
{
var sourceProjection = ProjectionInfo.FromAuthorityCode("EPSG", fromEpsgCode);
var targetProjection = ProjectionInfo.FromAuthorityCode("EPSG", toEpsgCode);
Reproject.ReprojectPoints(xy, null, sourceProjection, targetProjection, 0, 1);
Assert.AreEqual(expected[0], xy[0], tolerance);
Assert.AreEqual(expected[1], xy[1], tolerance);
}

[TestCase(3021, 3006, new double[] { 1366152.968, 6851307.390 }, new double[] { 408700, 6847800 }, 0.08)] // tolerance 8 cm
[TestCase(3006, 3021, new double[] { 408700, 6847800 }, new double[] { 1366152.968, 6851307.390 }, 0.08)] // tolerance 8 cm
[TestCase(3013, 3006, new double[] { 19061.000, 6851822.032 }, new double[] { 408700, 6847800 }, 1E-3)] // tolerance 1 mm
[TestCase(3022, 3021, new double[] { 1536875.736, 7037950.238 }, new double[] { 1649079.352, 7041217.283 }, 1E-3)] // tolerance 1 mm
public void Reproject_Swedish_Projections_Using_KnownCrsNames(int fromEpsgCode, int toEpsgCode, double[] xy, double[] expected, double tolerance)
{
var sourceProjection = getProjectionUsingKnownCrsName(fromEpsgCode);
var targetProjection = getProjectionUsingKnownCrsName(toEpsgCode);
Reproject.ReprojectPoints(xy, null, sourceProjection, targetProjection, 0, 1);
Assert.AreEqual(expected[0], xy[0], tolerance);
Assert.AreEqual(expected[1], xy[1], tolerance);
}

private ProjectionInfo getProjectionUsingKnownCrsName(int epsgCode)
{
ProjectionInfo proj = null;
if (epsgCode == 3021)
proj = KnownCoordinateSystems.Projected.NationalGridsSweden.RT9025gonV;
else if (epsgCode == 3022)
proj = KnownCoordinateSystems.Projected.NationalGridsSweden.RT900gon;
else if (epsgCode == 3013)
proj = KnownCoordinateSystems.Projected.NationalGridsSweden.SWEREF991545;
else if (epsgCode == 3006)
proj = KnownCoordinateSystems.Projected.NationalGridsSweden.SWEREF99TM;
else
throw new Exception("Not included in this test");

Assert.AreEqual(epsgCode,proj.AuthorityCode);
return proj;

}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -989,10 +989,10 @@ EPSG:3017 +proj=tmerc +lat_0=0 +lon_0=21.75 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80
EPSG:3018 +proj=tmerc +lat_0=0 +lon_0=23.25 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
EPSG:3019 +proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3020 +proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3021 +proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3022 +proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3023 +proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3024 +proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3021 +proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs
EPSG:3022 +proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs
EPSG:3023 +proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs
EPSG:3024 +proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs
EPSG:3025 +proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3026 +proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
EPSG:3027 +proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,56 @@ public class NationalGridsSweden : CoordinateSystemCategory
/// </summary>
public NationalGridsSweden()
{
RT380gon = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT3825gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT3825gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT385gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT385gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT3875gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT900gon = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT9025gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT9025gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT905gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT905gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
RT9075gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ");
SWEREF991200 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=12 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991330 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=13.5 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991415 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=14.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991500 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991545 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15.75 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991630 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=16.5 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991715 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=17.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991800 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF991845 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18.75 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF992015 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=20.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF992145 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=21.75 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF992315 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=23.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +units=m +no_defs ");
SWEREF99TM = ProjectionInfo.FromProj4String("+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs ");
// EPSG:3028
RT380gon = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ", "EPSG", 3028);
// EPSG:3029
RT3825gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ", "EPSG", 3029);
// EPSG:3027
RT3825gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ", "EPSG", 3027);
// EPSG:3030
RT385gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ", "EPSG", 3030);
// EPSG:3026
RT385gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ", "EPSG", 3026);
// EPSG:3025
RT3875gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1.000000 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs ", "EPSG", 3025);
// EPSG:3022
RT900gon = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18.05827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs ", "EPSG", 3022);
// EPSG:3023
RT9025gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=20.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs ", "EPSG", 3023);
// EPSG:3021
RT9025gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs ", "EPSG", 3021);
// EPSG:3024
RT905gonO = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=22.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs ", "EPSG", 3024);
// EPSG:3020
RT905gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=13.55827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs ", "EPSG", 3020);
// EPSG:3019
RT9075gonV = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=11.30827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=419.384,99.3335,591.345,0.850389,1.81728,-7.86224,-0.99496 +units=m +no_defs ", "EPSG", 3019);
// EPSG:3007
SWEREF991200 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3007);
// EPSG:3008
SWEREF991330 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=13.5 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3008);
// EPSG:3012
SWEREF991415 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=14.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG");
// EPSG:3009
SWEREF991500 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3009);
// EPSG:3013
SWEREF991545 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=15.75 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3013);
// EPSG:3010
SWEREF991630 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=16.5 +k=1 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3010);
// EPSG:3014
SWEREF991715 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=17.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3014);
// EPSG:3011
SWEREF991800 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3011);
// EPSG:3015
SWEREF991845 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=18.75 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3015);
// EPSG:3016
SWEREF992015 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=20.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3016);
// EPSG:3017
SWEREF992145 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=21.75 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3017);
// EPSG:3018
SWEREF992315 = ProjectionInfo.FromProj4String("+proj=tmerc +lat_0=0 +lon_0=23.25 +k=1.000000 +x_0=150000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3018);
// EPSG:3006
SWEREF99TM = ProjectionInfo.FromProj4String("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ", "EPSG", 3006);
RT380gon.Name = "RT38_0_gon";
RT3825gonO.Name = "RT38_25_gon_O";
RT3825gonV.Name = "RT38_25_gon_V";
Expand Down

0 comments on commit c065a77

Please sign in to comment.