[Proj] Import Proj native library in C#
support.mn at elisanet.fi
support.mn at elisanet.fi
Sun Jul 17 05:58:25 EST 2011
Zagot,
the real juice is in the pdf document
http://www.polardist.com/pub/PROJ.4.3.pdf
starting from page 26 chapter:
"Programming with the Cartographic Library"
You should read that and it gives all the answers
needed to use that in your C-sharp program. Do
not add any classes. Everything is already in the
headers.
You just need to include the header file and
start to use the procedures and data available.
Regards: Janne.
---------------------------------------------------------
zagot [maurelio at live.it] kirjoitti:
> Sorry I have read the manuals
>
> e.g. I follow this sample
> http://trac.osgeo.org/proj/wiki/ProjAPI
>
> but if I try to import this code in C# as follow
> unsafe class Program
> {
> public struct projUV {public double u; public double v; }
>
> [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", CharSet =
> CharSet.Auto,
> EntryPoint = "pj_free")]
> static extern void pj_free(void* p);
>
> [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", CallingConvention =
> CallingConvention.Cdecl, EntryPoint = "pj_init_plus")]
> static extern void*
> pj_init_plus([MarshalAs(UnmanagedType.LPStr)]string m);
>
> [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", CallingConvention =
> CallingConvention.Cdecl, CharSet = CharSet.Auto, EntryPoint = "pj_inv")]
> static extern projUV pj_inv(projUV px, void* py);
>
> [DllImport(@"C:\Users\t\Desktop\Lib\proj.dll", EntryPoint =
> "pj_transform")]
> static extern int pj_transform(void* src, void* dst, long
> point_count, int point_offset,
> double* x, double* y, double* z);
>
> static void Main(string[] args) {
>
> string proSrc = "+proj=merc +ellps=clrk66 +lat_ts=33";
> string proDst = "+proj=latlong +ellps=clrk66";
>
> void* projSrc = pj_init_plus(proSrc);
> void* projDst = pj_init_plus(proDst);
>
> double x = 15000;
> double y = 10000;
> double z = 0.0;
>
> double ris = pj_transform(projSrc, projDst, 1, 0, &x, &y, &z);
>
> }
> }
>
> I have this error:Attempted to read or write protected memory. This is
> often an indication that other memory is corrupt.
>
> Note: in the official sample there are this declaration:
> projPJ pj_merc, pj_latlong;
>
> I use void* when call pj_init_plus (projPJ is defined as void* in
> proj_api.h)
>
> what I wrong?
>
> thanks
> p.s. sorry for my english
> G.
>
>
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Import-Proj-native-library-in-C-tp6589496p6589769.html
> Sent from the PROJ.4 mailing list archive at Nabble.com.
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>
More information about the Proj
mailing list