Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Visit the Wiki  |  Find us on: Twitter Facebook Google+ LinkedIn

Discussion Forums

The online community for users of Map Suite GIS components

Need a Spherical/Web Mercator projection/class
Last Post 01-20-2009 03:20 PM by Val. 6 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
SergeiUser is Offline
Level 2
Level 2
Posts:53
Avatar

--
01-12-2009 05:08 PM

Hello. I'm looking for a projection/class to convert shapes from Decimal Degrees to Spherical/Web Mercator.

I used following Mercator classes: MercatorProj, TransverseMercatorProj, and ObliqueMercatorProj.

Which projection is the best to represent Spherical/Web Mercator?

I put conversion classes below.
The GeodeticToTransverseMercator class is not rendering, perhaps something is missing.

The GeodeticToMercator class is working well when using EPSG:3395. Image and layers lined properly.

When I use EPSG:3785, image and layer is displaced significantly.

I need Spherical/Web Mercator projection in order to utilize EPSG:3785 code to get WMS images.

Public Class GeodeticToMercator
  Implements IProjection
  Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
    Dim p As New MercatorProj()

    Dim Easting As Double = 0
    Dim Northing As Double = 0

    p.ConvertGeodeticToMercator(Y, X, Easting, Northing)

    Return New PointR(Easting, Northing)
  End Function
End Class

Public Class GeodeticToTransverseMercator
  Implements IProjection
  Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
    Dim p As New TransverseMercatorProj

    Dim Easting As Double = 0
    Dim Northing As Double = 0

    p.ConvertGeodeticToTransverseMercator(Y, X, Easting, Northing)

    Return New PointR(Easting, Northing)
  End Function
End Class

Public Class GeodeticToObliqueMercator
  Implements IProjection
  Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As PointR Implements MapSuite.Geometry.IProjection.ProjectPoint
    Dim p As New ObliqueMercatorProj

    Dim Easting As Double = 0
    Dim Northing As Double = 0

    p.ConvertGeodeticToObliqueMercator(Y, X, Easting, Northing)

    Return New PointR(Easting, Northing)
  End Function
End Class

 

Tnanks.

 

SergeiUser is Offline
Level 2
Level 2
Posts:53
Avatar

--
01-13-2009 02:21 PM

In example below I use MapSuite Geometry GeodeticToTransverseMercator.

Any idea why layer is not showing on the map?

Map1.MapUnit = MapLengthUnits.metres
Dim prj As MapSuite.Geometry.GeodeticToTransverseMercator = New MapSuite.Geometry.GeodeticToTransverseMercator
Dim lr As Layer = New Layer("C:\DATA\US\WA\20\County.shp", prj, True)

lr.ZoomLevel01.GeoStyle = GeoAreaStyles.GetSimpleAreaStyle(GeoColor.KnownColors.LightGray, GeoColor.KnownColors.Black)
lr.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.ZoomLevel18
lr.ZoomLevel01.Active = True

Map1.Layers.Add(lr)
Map1.CurrentExtent = Map1.FullExtent

Map1.Refresh() 'Does not help - layer is not shown???

Thanks.

ScottUser is Offline
MVP
MVP
Posts:732
Avatar

--
01-14-2009 01:59 AM
Sergei,

I have tested the code above, but I can't reproduce the problem what you said, I wrote the following code in the Load event of Winform:

map1.MapUnit = MapLengthUnits.metres;

GeodeticToTransverseMercator projection = new GeodeticToTransverseMercator();
Layer layerCntry = new Layer(@"..\..\SampleData\projection\cntry02.shp", projection, true);
layerCntry.ZoomLevel01.GeoStyle = GeoAreaStyles.GetSimpleAreaStyle(GeoColor.KnownColors.LightGray, GeoColor.KnownColors.Black);
layerCntry.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.ZoomLevel18;
layerCntry.ZoomLevel01.Active = True;

map1.Layers.Add(layerCntry);

map1.Refresh();

I compared the code above with your code, I think they are almost the same except the shape data, can you use the cntry02.shp test it again so that we can find out where is the problem exactly.

Thanks,
SergeiUser is Offline
Level 2
Level 2
Posts:53
Avatar

--
01-14-2009 12:44 PM

Scott,

I downloaded DesktopEditionFullSetup2.55.0.zip from the Customer Portal and reinstalled MapSuite to test Transverse Mercator projection.

I'm not sure if Transverse Mercator projection display is correct. I added to the samples VBSampleApps-ProjectionApp another tab to display Transverse Mercator map.
I had to comment out  layerEarthBackground layer rendering because it throwing an exception when using Transverse Mercator projection.

I added following case to the  TabControl1_SelectedIndexChanged sub:

Case "Transverse Mercator"
  If Not mIsTransverseMercatorLoaded Then
    Dim prj As New GeodeticToTransverseMercator()

    DrawMap(MapTransverseMercator, prj)

    mIsTransverseMercatorLoaded = True
  End If

  Exit Select
 
Here is DrawMap method:
Private Sub DrawMap(ByVal map As Map, ByVal projection As IProjection)
  map.CanvasGeoColor = GeoColor.KnownColors.LightGray

  map.MapUnit = MapLengthUnits.metres

  'Dim layerEarthBackground As New Layer("..\..\SampleData\projection\earthbackground.shp", projection, True)
  'layerEarthBackground.ZoomLevel01.GeoStyle.SymbolRenderers.Add(New SymbolRenderer(mCustomAreaSymbol1))
  'layerEarthBackground.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.ZoomLevel18

  Dim layerCntry As New Layer("..\..\SampleData\projection\cntry02.shp", projection, True)
  LoadLayerCountries(layerCntry)

  Dim layerLatlong As New Layer("..\..\SampleData\projection\latlong.shp", projection, True)
  layerLatlong.ZoomLevel01.GeoStyle = GeoLineStyles.GetSimpleLineStyle(GeoColor.FromArgb(200, GeoColor.KnownColors.DarkGray), 1)
  layerLatlong.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.ZoomLevel18

  'map.Layers.Add(layerEarthBackground)
  map.Layers.Add(layerCntry)
  map.Layers.Add(layerLatlong)

  'map.CurrentExtent = layerCntry.Extent

  map.Refresh()
End Sub

Here is the screenshot of the Transverse Mercator map:

I replaced shape file path with my shape file path.

Here is USA in Miller projection:

Here is USA in Transverse Mercator projection:

So, Washington Benton county (the shape I'm using) does not render at all, width and height is 0.

I would like to know if Transverse Mercator projection is the same as Spherical/Web Mercator.

If not, which projection corresponds to Spherical/Web Mercator.

Thanks.

ScottUser is Offline
MVP
MVP
Posts:732
Avatar

--
01-14-2009 09:59 PM
Sergei,

The Transverse Mercator is the same as Spherical/Web Mercator, it is not the same as the ObliqueMercator projection. Did you have any exact questions about it or did you think there are any problems?

Thanks,
SergeiUser is Offline
Level 2
Level 2
Posts:53
Avatar

--
01-15-2009 10:21 AM

Scott,

Thanks for reply.

This is what I expected.

I just don't understand why shape is rendered incorrectly (see my previous reply).

I was planning to use it and it seems that Transverse Mercator projection is not usable for me.

Is this because I'm using older MapSuite release?

Does it works properly on your map?

How to resolve this issue?

Thanks.

ValUser is Offline
MVP
MVP
Posts:1634
Avatar

--
01-20-2009 03:20 PM
GeoTrans is the projection library used for Map Suite 2.0. When a point to project is outside the expected range of values based on the projection paramters, the projected point returns with the values 0, 0. That explains why you see those lines converging to the same point (0,0).
This behavior is happening inside GeoTrans and the Map Suite development team has no control on that. In Map Suite 3.0, the default projection library has been replaced by Proj4 that handles more gracefully those cases.
You are not authorized to post a reply.

Active Forums 4.2