Tech Tip
Map Suite I-Projection Interface: How You Can Implement Your Own Projections
It is very probable that you will acquire geographic data in decimal degrees (Lat/Long or Geodetic), since this is a very common coordinate system. However, when you display the map layers without applying any projection, you may notice that your displays are a little unusual. This is because most countries have their own standard projections, as seen in atlases and wall maps. Therefore, you may want to display your map layers in a way that is most familiar to your viewers.
For example, we are accustomed to seeing the contiguous USA in a way that uses the Lambert Conformal Conic projection with the following parameters:
- Origin Latitude: 39
- Central Meridian: -96
- Standard Parallel 1: 33
- Standard Parallel 2: 45
You can go from Geodetic to Lambert Conformal Conic projection by using a Projection class that implements the I-Projection interface. In addition, you may want to see the coordinate in Lat/Long while you move your mouse around on the Map. In this case, you are going to need a class to go the other way, from Lambert Conformal Conic to Geodetic.
In VB.NET:
Dim GeoLambertUSA As New GeodeticToLambertForConterminousUSA
Dim Layer As New Layer("..\..\sampledata\usa\states.shp", GeoLambertUSA, True)
Dim T As New Threshold(Double.MaxValue, 0)
Dim SR As New SymbolRenderer(New AreaSymbol(Pens.Black, Brushes.LightGreen))
T.SymbolRenderers.Add(SR)
Layer.Thresholds.Add(T)
Map1.Layers.Add(Layer)
Map1.Refresh()
Public Class GeodeticToLambertForConterminousUSA
Implements IProjection
Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As MapSuite.Geometry.PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
Dim LambertProj As New LambertConformalConicProj
Dim Origin_Latitude As Double = 39
Dim Central_Meridian As Double = -96
Dim Std_Parallel_1 As Double = 33
Dim Std_Parallel_2 As Double = 45
Dim False_Easting As Double = 0
Dim False_Northing As Double = 0
Dim Easting As Double = 0
Dim Northing As Double = 0
LambertProj.Set_LambertConformalConic_Parameters(Origin_Latitude, Central_Meridian, Std_Parallel_1, Std_Parallel_2, False_Easting, False_Northing)
LambertProj.ConvertGeodeticToLambertConformalConic(Y, X, Easting, Northing)
Return New PointR(Easting, Northing)
End Function
End Class
Private Sub Map1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Map1.MouseMove
Dim WorldPointR As PointR
WorldPointR = Map1.ToWorldCoordinate(e.X, e.Y)
Dim LambertUSAGeodetic As New LambertForConterminousUSAToGeodetic
Dim GeoPointR As PointR = LambertUSAGeodetic.ProjectPoint(WorldPointR.X, WorldPointR.Y)
StatusBar1.Panels(1).Text = DecimalDegrees.DecimalDegreesToDMS(GeoPointR)
End Sub
Public Class LambertForConterminousUSAToGeodetic
Implements IProjection
Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As MapSuite.Geometry.PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
Dim LambertProj As New LambertConformalConicProj
Dim Origin_Latitude As Double = 39
Dim Central_Meridian As Double = -96
Dim Std_Parallel_1 As Double = 33
Dim Std_Parallel_2 As Double = 45
Dim False_Easting As Double = 0
Dim False_Northing As Double = 0
Dim Longitude As Double = 0
Dim Latitude As Double = 0
LambertProj.Set_LambertConformalConic_Parameters(Origin_Latitude, Central_Meridian, Std_Parallel_1, Std_Parallel_2, False_Easting, False_Northing)
LambertProj.ConvertLambertConformalConicToGeodetic(X, Y, Latitude, Longitude)
Return New PointR(Longitude, Latitude)
End Function
End Class
As you can see, map layers in Decimal Degrees are displayed in the projection that you are the most familiar with for your country. Below are a few more examples:
Standard projection for Canada:
Public Class GeodeticToLambertForCanada
Implements IProjection
Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As MapSuite.Geometry.PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
Dim LambertProj As New LambertConformalConicProj
Dim Origin_Latitude As Double = 40
Dim Central_Meridian As Double = -96
Dim Std_Parallel_1 As Double = 50
Dim Std_Parallel_2 As Double = 70
Dim False_Easting As Double = 0
Dim False_Northing As Double = 0
Dim Easting As Double = 0
Dim Northing As Double = 0
LambertProj.Set_LambertConformalConic_Parameters(Origin_Latitude, Central_Meridian, Std_Parallel_1, Std_Parallel_2, False_Easting, False_Northing)
LambertProj.ConvertGeodeticToLambertConformalConic(Y, X, Easting, Northing)
Return New PointR(Easting, Northing)
End Function
End Class
Standard projection for Spain:
Public Class GeodeticToTransverseMercatorSpain : Implements IProjection
Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As MapSuite.Geometry.PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
Dim TransverseMercatorProj As New MapSuiteProjection.TransverseMercatorProj
Dim Easting, Northing As Double
TransverseMercatorProj.Set_TransverseMercatorProj_Parameters(0, 3, 500000, 0, 0.9996)
TransverseMercatorProj.ConvertGeodeticToTransverseMercator(Y, X, Easting, Northing)
Return New PointR(Easting, Northing)
End Function
End Class