ThinkGeo.com    |     Documentation    |     Premium Support

Proj4Projection use west of 180 with meters

Hello,

I’m curious if there is a way to use a Proj4Projection for drawing on a map to points west of 180. Currently we have to use an UnmanagedProj4Projection to do so, but there are occasional errors thrown by the unmanaged projection (mostly accessing protected memory exceptions.)

Background:
For years we used a map unit of decimal degrees, and didn’t have any problems. This year we changed our projection to web mercator, and thus needed to use meters as our map unit. Our map runs from 0 degrees as the eastern boundary, to 10E (350) as our western boundary.

Since all of our data is in decimal degrees, everything needs to be converted before drawing on the map. What we found is that when using the Proj4Projection, nothing will draw west of 180. If you look at the lat/lon locations after a ConvertToExternalProjection call, the western edge maxes out at the 180 line (20037508.3428 meters.) That’s the reason for using the UnmanagedProj4Projection, as it will allow shapes/features to draw west of 180. However, the unmanaged projection throws errors at a surprising rate when ConvertToExternalProjection is called. Even if the call is wrapped in a Try…Catch, our program will crash on the initial error.

Is there anyway for us to use a Proj4Projection west of 180? I’ve tried setting the DecimalDegreeBoundary, but that didn’t make any difference.

Any thoughts would be helpful.

Thanks,
Dib

Hi Dib,

You means when you tried to convert your data to the coordinate for example -400, the Proj4Projection limited that, and the UnmanagedProj4Projection keep throw exception right?

Could you please find some records(The WKT) in your data, so we can try to convert them by UnmanagedProj4Projection and see what’s the issue here?

And please let us know you are using v9 or v10, if you are using v9, please upgrade your unmanaged dll to latest.

Regards,

Don

Don,

We are on version 10.

Here is my managed proj4 constructor:

    proj4 = New Proj4Projection With {
        .InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326),
        .ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString()
    }

If i were to to create a pointshape at -210,35 (-210 being 150E), and then run

vert1 = Me.proj4.ConvertToExternalProjection(vert1)

then the point would not draw. I would actually see the point at -180,35, as the convert X result would be -20037508.3428, which is the 180 line. Any X point west of -180 returns that number.

The unmanaged projection most often works, but it will occasionally throw an error. Given the amount of conversions that are done with every map redraw, it happens every now and then.

Can I create the managed projection with parameters that will allow for points west of 180?

Hi Dib,

The maximum extent of epsg 4326 is (-180, 90, 180, -90). The source point should be in the extent. we use the maximum value to calculate if the value out of range. The points west of 180 are out of range.

Wish it is helpful for you.

Thanks,
Bill