ThinkGeo.com    |     Documentation    |     Premium Support

Unable to apply projection to OpenStreetMapOverlay

In my WPF app, when attempting to apply a projection to the OpenStreetMapOverlay I get the following error message:

I was able to replicate this in the DisplayOpenStreetMapOverlaySample of the HowDoI sample app with the following code.

osmMapsOverlay.ProjectionConverterFromServerProjection = new ProjectionConverter(
       Projection.GetGoogleMapProjString(),
       Projection.GetProjStringByEpsgSrid(3348));

osmMapsOverlay.ProjectionConverterFromServerProjection.Open();

Cheers,
John

Hi John,

Did you try to install ThinkGeo.UnmanagedProj via nuget?

Thanks,
Leo

Hi Leo,

I’ve tried this on the HowDoI example WPF app with version 12.3.10 of ThinkGeo.UnmanagedProj.
I also tried updating all the packages included in the example app to the latest beta versions but the issue was still present.

Thanks,
John

Hi John,

We need to use UnmanagedProjectionConverter, and ThinkGeo.Dependency.Gdal is required also.

osmMapsOverlay.ProjectionConverterFromServerProjection = new UnmanagedProjectionConverter(
        Projection.GetGoogleMapProjString(),
        Projection.GetProjStringByEpsgSrid(3348));

Here’s a sample, feel free to download and play around with it.
WpfApp1.zip (10.5 KB)

Thanks,
Leo

Hello,
I know, this is an old thread, but I get an exception, when try to project OSM overlay with Gdal.
I use version 14.4 beta 059. My code:

ThinkGeo.Core.GdalProjectionConverter projectionConverter = new GdalProjectionConverter(3857, 25832);
this.ProjectionConverter = projectionConverter;
this.ProjectionConverter.Open();

this is OpenStreetMapOverlay,

Regards,
Torsten

Hi Juergen,

  1. we have several samples in the latest HowDoI showing how to reproject an XYZ based layer between Spherical Mercator (3857) and Decimal Degrees (4326).
  2. We found it does have some issues reprojecting to certain projections (including 25832) though, and we’ve fixed it in the latest beta (14.4.0-beta059).
  3. Please pull the latest beta and the following changes to the "Display Raster from XYZ Server will do the projection as expected:
   _osmLayer = new OpenStreetMapAsyncLayer();
   ......

  switch (radioButton.Tag.ToString())
  {
  case "3857":
      MapView.MapUnit = GeographyUnit.Meter;
      _osmLayer.ProjectionConverter = null;
      break;

  case "4326":
      MapView.MapUnit = GeographyUnit.Meter;
      _osmLayer.ProjectionConverter = new GdalProjectionConverter(3857, 25832);
      break;

  default:
      return;
  }

  await _osmLayer.CloseAsync();
  await _osmLayer.OpenAsync();

  var extentIn25832 = new RectangleShape(166021.4, 9328006,833978, 0);
  MapView.CenterPoint = extentIn25832.GetCenterPoint();
  MapView.CurrentScale = MapUtil.GetScale(MapView.MapUnit, extentIn25832, MapView.MapWidth, MapView.MapHeight);
  await MapView.RefreshAsync();

Here is what it looks like with the above changes on the existing HowDoI sample

Thanks,
Ben

Hallo Been,
it works like a charm…
Thanks,
Torsten

That’s Awesome ! :+1: