ThinkGeo.com    |     Documentation    |     Premium Support

Proj4 shiftgrid gr3df97a - Lambert IIe

Hello,


I'I'm looking to the projection that we call "French Lambert IIe".

This projection use a shiftgrid "gr3df97a"


According to Proj.4. web site, this grid does not seem to be implemented.

Can you help me


- either found the correct API to use this grid

- or providing my own implementation as I already did for MapSuite v2?


Regards

Patrick.



Patrick,


You can write your own “French Lambert IIe” projection class by inheriting from Projection class and override the following two methods with V2.0 logic.



public class MyProjection : Projection
{
    protected override Vertex[] ConvertToExternalProjectionCore(double[] x, double[] y)
    {
    }

    protected override Vertex[] ConvertToInternalProjectionCore(double[] x, double[] y)
    {
    }
}

Following code shows how to use your projection on a layer:



ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer();
MyProjection myProjection = new MyProjection();
layer.FeatureSource.Projection = myProjection ;

Hope it helps.


Thanks,

ThinkGeo Support



 Hi,


I'm now migrating this code from v3 to v5; 


to make it build, I've changed



public class MyProjection : Projection
to
public class MyProjection : ManagedProj4Projection  and the code build;  however, at runtime, I've an exception on MyProjection.open() which says: "Parameter is null"  Please advise Patrick





Ok, I get it, 
  
 we need to override also: 
  
     protected override void OpenCore() 
     { 
     } 
  
     protected override void CloseCore() 
     { 
     } 
  
 Best 
 Patrick.

Well, I can build it but still get an exception at runtime; may you explain me again how to proceed with 5.5 ? 
  
 I’ve a function that convert Geodesic_to_Lambert and another one to convert Lambert_to_geodesic with v2 logic. 
  
 I now need to build a managedproj4projection to convert any EpsgParametersString from/to my lambert. 
  
 Thank you in advance. 
 Patrick.

Hello Patrick, 
  
 Thanks for your further information, there are two possibility that will cause this exception. 
 1. You didn’t set the internalProjectionString and extenalProjectionString properties. 
 2. Your projection is some special format that our managedproj4projection does not support, for that, you need to set MemoryMode to UnManaged. 
  
 Regards, 
  
 Gary

Gary, 
  
 my code is pure C# so your item #2 is not valid. 
 I found that I need to override CanReproject too;. 
  
 What to put has internalprojection/external projection string ? 
  
 Thank you 
 Patrick.

Hello Patrick,


 


InternalProjectionParametersString is the original projection you data file use, and ExternalProjectionParametersString is the new projection you want to your data file shows.


Please see the code below:



            ManagedProj4Projection proj4Projection = new ManagedProj4Projection();
            proj4Projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
            proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

This means you want to change your data file's projection from decimal degree to google map projection. 


Regards,


Gary



Gary,  
  
 thank you for you code, but this is not at all what I’m expected. 
  
 Let me rephrase my question. 
  
 I do have a custom projection (Lambert IIe with grid) not supported by Proj4. 
 I’ve 2 functions that works with MS2 logic (geodesic_to_custom & custom_to_geodesic) 
  
 I need to re-implement this with MS5 logic. 
  
 1. How to implement this custom projection ? 
 2. how to declare a proj4Projection from mycustom to google? 
  
 Thank you for your help 
 Patrick.

Hello Patrick, 
  
 Sorry for waiting, for your first question, it’s a little complicated, the projecting in 2.0 is totally different with 5.0 now, the way I can think about is create a point object, first using the 2.0 old way(exist way in your code) to transform the original data to this point, then using the 5.0 to transform this point to final data to draw, but this will cause you refer both 2.0 and 5.0 MapSuite, I’m not sure it’s a very good idea. Otherwise, you just rewrote the whole custom projection with 5.0 new way. 
  
 For the second question, you only need override ConvertToExternalProjectionCore and ConvertToInternalProjectionCore methods, and handle your logic how to transform your custom projection to goolg. 
  
 Maybe I’m not say it clearly, please let me know if you have any queries. 
  
 Regards, 
  
 Gary

 No it's not clear at all, sorry.


Can you provide a dummy sample of how to implement a custom projection (wgs84-custom)

and how to use it to project from/to any existing EPSG.


Best regards,

Patrick.



 Hi Patrick,


I take over this post and any question please feel free to let me know.


I attached a sample shows how to implement a custom projection, you just need to create a custom class that inherit from Projection class, and


override the method  protected override Vertex[] ConvertToExternalProjectionCore(double[] x, double[] y) , x and y represent the internal vertex array, and in the method you can


use MapSuite 2.0 API to convert them from Wgs84 to custom, and then return them as vertex array.


Thanks,


James



WpfDesktopEditionSample_CustomRotationProjecti.zip (16.7 KB)