Use custom projection

Hello again!

I’ve been new to MapWinGIS and am trying to solve a use case with a custom application in .NET using the 64 bit MapWinGIS OCX.

  1. The case needs OSM layer to be the basemap.
  2. There are some admin boundaries shapefile datasets in custom LCC projection that needs to be added.
  3. There needs to be a file chooser where a zipped shapefile should be uploaded and overlaid on the above layers.

I’m able to do the above steps 1 and 2, but not the 3rd in entirety.

I’m uploading the shapefile via FileChooser and unzipping it to load it. This shapefile is loading on the map but being in different projection, it doesn’t overlays correctly.
The same shapefile if uploaded in the same custom LCC projection, however does. This may not be the exact case in production. The user may have this shape file in 4326 or 3857 as well.

The issues I’m facing now are.

  1. The shapefile to upload should always overlay in the exact place over the admin boundaries irrespective of its projection (4326 or 3857).
  2. Once uploaded, I should be able to get the shapefile extents in 4326 always for another use case.

What I’ve done so far while uploading the shapefile, to achieve this is

var sf = new Shapefile();
sf.Open(shapeFile, null);
sf.GeoProjection = axMap1.GeoProjection;

This above does not assigns the mapviewer projection to the shapefile.

I also have the following settings done initially, but that doesn’t works either.

GlobalSettings gs = new GlobalSettings();
gs.ReprojectLayersOnAdding = true;

I’m not sure whether I’m doing this correctly, but there should be another way/example to reproject the shapefile before displaying.

I cannot use the GdalUtils.GdalVectorReproject since I do not have the EPSG Code for the custom projection, which I believe is required as the target projection

I also tried to read the EPSG code by combining something by looking into this forum and the reference from

var shpGP = new MapWinGIS.GeoProjection();
bool success = shpGP.ImportFromWKT(File.ReadAllText(Path.ChangeExtension(shapeFile, “.prj”)));

bool proj = shpGP.TryAutoDetectEpsg(out int epsgCode);

The epsgCode returns -1.

Sorry for making a long post to explain, just wanted to put everything I faced. Hope I’m able to explain my problem.

Thanks,
Shadab