Skip to content

Commit a685e0b

Browse files
authored
Add support for Lambert Tangential Conformal Conic Projection (#133)
1 parent e665f8e commit a685e0b

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

src/ProjNet/CoordinateSystems/Projections/LambertConformalConic2SP.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ protected LambertConformalConic2SP(IEnumerable<ProjectionParameter> parameters,
113113
Name = "Lambert_Conformal_Conic_2SP";
114114
Authority = "EPSG";
115115
AuthorityCode = 9802;
116-
117-
//Check for missing parameters
118-
double lat1 = DegreesToRadians(_Parameters.GetParameterValue("standard_parallel_1"));
119-
double lat2 = DegreesToRadians(_Parameters.GetParameterValue("standard_parallel_2"));
116+
117+
//Check for missing parameters
118+
//Since this implementation supports conic 1SP and 2SP we add the support for the 1SP implementation here.
119+
//There is no need for standard_parallel_1 and standard_parallel_2 parameters in this version: https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/lambert-conformal-conic.htm
120+
double lat1 = DegreesToRadians(_Parameters.GetParameterValue("standard_parallel_1", new[] { "latitude_of_origin" }));
121+
double lat2 = DegreesToRadians(_Parameters.GetParameterValue("standard_parallel_2", new[] { "latitude_of_origin" }));
120122

121123
double sin_po; /* sin value */
122124
double cos_po; /* cos value */

src/ProjNet/CoordinateSystems/Projections/ProjectionsRegistry.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,22 @@ static ProjectionsRegistry()
2525
Register("mercator_auxiliary_sphere", typeof(MercatorAuxiliarySphere));
2626
Register("pseudo_mercator", typeof(PseudoMercator));
2727
Register("popular_visualisation_pseudo_mercator", typeof(PseudoMercator));
28-
Register("google_mercator", typeof(PseudoMercator));
28+
Register("google_mercator", typeof(PseudoMercator));
2929

3030
Register("transverse_mercator", typeof(TransverseMercator));
3131
Register("gauss_kruger", typeof(TransverseMercator));
3232

33-
Register("albers", typeof(AlbersProjection));
33+
Register("albers", typeof(AlbersProjection));
3434
Register("albers_conic_equal_area", typeof(AlbersProjection));
35-
35+
3636
Register("krovak", typeof(KrovakProjection));
37-
37+
3838
Register("polyconic", typeof(PolyconicProjection));
3939

40-
Register("lambert_conformal_conic", typeof(LambertConformalConic2SP));
40+
Register("lambert_conformal_conic", typeof(LambertConformalConic2SP));
4141
Register("lambert_conformal_conic_2sp", typeof(LambertConformalConic2SP));
4242
Register("lambert_conic_conformal_(2sp)", typeof(LambertConformalConic2SP));
43+
Register("lambert_tangential_conformal_conic_projection", typeof(LambertConformalConic2SP));
4344

4445
Register("lambert_azimuthal_equal_area", typeof(LambertAzimuthalEqualAreaProjection));
4546

test/ProjNet.Tests/CoordinateTransformTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,29 @@ public void TestPopularVisualizationPseudoMercatorProjectionRegistry()
11661166
Assert.NotNull(transformation);
11671167
}
11681168

1169+
[Test]
1170+
public void TestLamberTangentialConformalConicProjectionRegistryAndTransformation()
1171+
{
1172+
string sourceWkt = "PROJCS[\"WORLD-LM-TAN\",GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722356]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Lambert Tangential Conformal Conic Projection\"],PARAMETER[\"false_easting\",0.000],PARAMETER[\"false_northing\",0.000],PARAMETER[\"scale_factor\",1.000000000000],PARAMETER[\"central_meridian\",0.00000000000000],PARAMETER[\"latitude_of_origin\",1.00000000000000],UNIT[\"Meter\",1.00000000000000]]";
1173+
string targetWkt = "PROJCS[\"WGS84.PseudoMercator\",GEOGCS[\"LL84\",DATUM[\"WGS84\",SPHEROID[\"WGS84\",6378137.000,298.25722356]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Popular Visualisation Pseudo Mercator\"],PARAMETER[\"false_easting\",0.000],PARAMETER[\"false_northing\",0.000],PARAMETER[\"central_meridian\",0.00000000000000],UNIT[\"Meter\",1.00000000000000]]";
1174+
1175+
var sourceCoordinateSystem = GetCoordinateSystem(sourceWkt);
1176+
Assert.NotNull(sourceCoordinateSystem);
1177+
1178+
var targetCoordinateSystem = GetCoordinateSystem(targetWkt);
1179+
Assert.NotNull(targetCoordinateSystem);
1180+
1181+
var transformation = GetTransformation(sourceCoordinateSystem, targetCoordinateSystem);
1182+
Assert.NotNull(transformation);
1183+
1184+
// Test the transformation with a known points. Tested with AutoCAD map 3D
1185+
double[] pGeo = new[] { 4101119.6855, -229063.8661 }; // Nairobi, Kenya
1186+
double[] pUtm = transformation.MathTransform.Transform(pGeo);
1187+
1188+
double[] expected = new[] { 4098998.6422, -142387.5532 };
1189+
Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.05), TransformationError("LambertConicConformal2SP", expected, pUtm));
1190+
}
1191+
11691192
internal static CoordinateSystem GetCoordinateSystem(string wkt)
11701193
{
11711194
var coordinateSystemFactory = new CoordinateSystemFactory();

0 commit comments

Comments
 (0)