ThinkGeo.com    |     Documentation    |     Premium Support

ConvertPrjToProj4 missing in v12

Hi,

I’ve used ConvertPrjToProj4 frequently when loading shapefiles to ensure the correct projection is used; however, in version 12 this is missing. How do I read prj file now and convert to projection?

Also, the entire setup for assigning the new Projection and using ProjectionConverter is very different. Can you give a summary and example of how to use these new features to convert coordinates?

Thanks,
Damian

Damian,
Here is some more detail about use the projection in mapsuite 12.

We changed the name Proj2Projection. We call it ProjectionConverter now. So in the Blazor/mapsuite 12.0 you can do it like this

layer.FeatureSource.ProjectionConverter = new ProjectionConverter(4326, 3857);

All stuff under ThinkGeo.MapSuite.Shapes in mapsuite 10 now moved to the ThinkGeo.Core in mapsuite 12. And it support both .net core and .net freamwork.

To conver the coordinates you can try
ProjectionConverter projectionConverter = new ProjectionConverter(4326, 3857);
projectionConverter.Open();
PointShape newCenterPoint = projectionConverter.ConvertToInternalProjection(centerPoint) as PointShape;

This could help you convert the point from 3857 to 4326.

if you use ConvertToExternalProjection it will convert from 4326 to 3857.

Thanks

Frank

Hi Frank,

Thanks for the information.

Specifically, I was asking about ConvertPrjToProj4 which took a shapefiles .prj string and converted it to proj4 for use in Proj4Projection. The only thing that seems like it may have replaced this is ConvertWktToProjString. Is that the equivalent?

The other thing that is confusing now is that a FeatureSource seems to have both a ProjectionConverter and a Projection. Do we have to set each one? Should Projection be what the shape is actually in (External) or what projection my map is in (Internal)?

In your example conversion, there are no shift parameters implied by specifying only the SRID of the projection. For your example to work properly on almost any other systems (e.g. WGS84 to ED50), you would need to supply additional +towgs parameters. Has anything else changed with that?

Thanks,
Damian

Thanks Damian,
Sorry for misunderstanding.

  1. Yes. It was replaced by ConvertWktToProjString. You can use
    string proj4String = Projection.ConvertWktToProjString(System.IO.File.ReadAllText([prj file path]));
  2. You only need set the ProjectionConverter. The Projection is the actual layer’s projection(Internal). You don’t need set this one. This is a read only property.
  3. For the constructor of the ProjectionConverter you can use the SRID to get the proj4 string. Use the SRID just a quick way to help the user get the proj4 string. You can also pass the proj4 string directly.

var converter = new ProjectionConverter("+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs", “+proj=lcc +lat_1=-76.66666666666667 +lat_2=-79.33333333333333 +lat_0=-90 +lon_0=-96 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs”);
This way you can specify more parameters.

Thanks

Frank

Thanks for clarifying Frank. It’s not always easy for us to cope when a bunch of parameters are renamed.

Ref point 2, it appears I don’t get any error (compile or runtime) when setting Projection property of FeatureSource. Also seems that setting it works. Maybe that’s a bug because you wouldn’t want to only set internal projection?

Thanks,
Damian

Thanks Damina,
Yes. I submit an internal ticket for the property for the FeatureSource.Projection. To avoid confuse we may need set it as read only property in future release .

Thanks

Frank