[Proj] Import Proj native library in C#
zagot
maurelio at live.it
Sat Jul 16 08:19:02 PDT 2011
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.
More information about the Proj
mailing list