Sample of a C++ interface |
/************************************************************************/ /* Sample of a C++ interface */ /* for some functions of the 32 bit Dynamic Link Library GeoDLL */ /* The interface must be extended for other functions if necessary. */ /* The interface can be included in the C++ source code directly */ /* or can be used as a header file. */ /* */ /* Author: Killet GeoSoftware Ing.-GbR */ /* */ /* In the calling directory of GeoDLL the files geodll32.dll */ /* and geodllbn.bin must be present. */ /************************************************************************/
/* Includes *************************************************************/ #include <windows.h> #include <iostream.h> #include <stdlib.h> #include <stdio.h>
/* Declare functions ****************************************************/ /* Load Geodll32.dll */ short int __cdecl GeoDllLoadLib (void);
/* Unlock the DLL function groups */ short int __cdecl GeoDllSetunlockcode (char* cFreiSchaltCode, char* cLizenznehmer);
/* Coordinate Transformation */ short int __cdecl GeoDllTrans ( double dKoordXQ, /* X coordinate of the source Coordinate System */ double dKoordYQ, /* Y coordinate of the source Coordinate System */ short int sKoordSysQ, /* Flag for the source Coordinate System */ short int sBezSysQ, /* Flag for the source Reference System */ short int sNotationQ, /* Flag for the notation of the source coord. */ double *dKoordXZ, /* X coordinate of the target Coordinate System */ double *dKoordYZ, /* Y coordinate of the target Coordinate System */ short int sKoordSysZ, /* Flag for the target Coordinate System */ short int sBezSysZ, /* Flag for the target Reference System */ short int sNotationZ, /* Flag for the notation of the target coord. */ short int sStreifenZ); /* Flag for the target meridian strip */
/* Transformation parameter for a Reference System */ short int __cdecl GeoDllSetuserrefsys ( short int sRefSysTyp, /* Flag to set the Reference System */ double dTranslX, /* Translation on the X axis */ double dTranslY, /* Translation on the Y axis */ double dTranslZ, /* Translation on the Z axis */ double dRotX, /* Rotation of the X axis */ double dRotY, /* Rotation of the Y axis */ double dRotZ, /* Rotation of the Z axis */ double dMasstab); /* Measure factor in ppm */
/* Semi axes for the source ellipsoid */ short int __cdecl GeoDllSetuserellsource ( short int sEllSource, /* Flag to set the source ellipsoid */ double dHalbAchsGrQ, /* Semi-major axis of the source ellipsoid */ double dHalbAchsKlQ); /* Semi-minor axis of the source ellipsoid */
/* Semi axes for the target ellipsoid */ short int __cdecl GeoDllSetuserelltarget ( short int sEllTarget, /* Flag to set the target ellipsoid */ double dHalbAchsGrZ, /* Semi-major axis of the target ellipsoid */ double dHalbAchsKlZ); /* Semi-minor axis of the target ellipsoid */
/* Distance between two coordinate pairs */ short int __cdecl GeoDllDistancegeo ( double dGeoLaenge1, /* Longitude of the first coordinate */ double dGeoBreite1, /* Latitude of the first coordinate */ double dGeoLaenge2, /* Longitude of the second coordinate */ double dGeoBreite2, /* Latitude of the second coordinate */ double *dStrecke, /* Calculated distance */ short int sEllipsoid); /* Flag for the geodetic ellipsoid */
/* Set pointer to the DLL function setunlockcode() */ short int (_stdcall *pfnSetunlockcode) ( char *, char *) = NULL;
/* Set pointer to the DLL function coordtrans3() */ short int (_stdcall *pfnTrans) ( double, double, short int, short int, short int, double *, double *, short int, short int, short int, short int) = NULL;
/* Set pointer to the DLL function setuserrefsys() */ short int (_stdcall *pfnSetuserrefsys) ( short int, double, double, double, double, double, double, double) = NULL;
/* Set pointer to the DLL function setuserellsource() */ short int (_stdcall *pfnSetuserellsource) ( short int, double, double) = NULL;
/* Set pointer to the DLL function setuserelltarget() */ short int (_stdcall *pfnSetuserelltarget) ( short int, double, double) = NULL;
/* Set pointer to the DLL function distancegeo() */ short int (_stdcall *pfnDistancegeo) ( double, double, double, double, double *, short int) = NULL;
/* Function GeoDllLoadLib ***********************************************/ /* Load Dynamic Link Library GeoDLL and set pointer to the DLL */ /* functions */ short int __cdecl GeoDllLoadLib (void) { HINSTANCE hDLL; short int sReturn = 1; if (pfnTrans == NULL) { if ((hDLL = LoadLibrary("Geodll32.dll")) != NULL) { if ((pfnSetunlockcode = (short int (_stdcall *)(char*,char*)) GetProcAddress(hDLL, "setunlockcode")) == NULL) sReturn = 0; if ((pfnTrans = (short int (_stdcall *)(double, double, short int, short int, short int, double *, double *, short int, short int, short int, short int)) GetProcAddress(hDLL, "coordtrans3")) == NULL) sReturn = 0; if ((pfnSetuserrefsys = (short int (_stdcall *)(short int, double, double, double, double, double, double, double)) GetProcAddress(hDLL, "setuserrefsys")) == NULL) sReturn = 0; if ((pfnSetuserellsource = (short int (_stdcall *)(short int, double, double)) GetProcAddress(hDLL, "setuserellsource")) == NULL) sReturn = 0; if ((pfnSetuserelltarget = (short int (_stdcall *)(short int, double, double)) GetProcAddress(hDLL, "setuserelltarget")) == NULL) sReturn = 0; } if ((pfnDistancegeo = (short int (_stdcall *)(double, double, double, double, double *, short int)) GetProcAddress(hDLL, "distancegeo")) == NULL) sReturn = 0; } else sReturn = 0; } return (sReturn); }
/* Function GeoDllSetunlockcode *****************************************/ /* Unlock the DLL function groups */ /* The parameters descriptions are in the file GeoDLL_e.chm */ short int __cdecl GeoDllSetunlockcode (char* cFreiSchaltCode, char* cLizenznehmer) { short int sReturn = 0; sReturn = pfnSetunlockcode(cFreiSchaltCode, cLizenznehmer); return (sReturn); }
/* Function GeoDllTrans *************************************************/ /* Perform Coordinate Transformation */ /* The parameters descriptions are in the file GeoDLL_e.chm */ short int __cdecl GeoDllTrans (double dKoordXQ, double dKoordYQ, short int sKoordSysQ, short int sBezSysQ, short int sNotationQ, double *dKoordXZ, double *dKoordYZ, short int sKoordSysZ, short int sBezSysZ, short int sNotationZ, short int sStreifenZ) { short int sReturn = 0; sReturn = pfnTrans(dKoordXQ, dKoordYQ, sKoordSysQ, sBezSysQ, sNotationQ, dKoordXZ, dKoordYZ, sKoordSysZ, sBezSysZ, sNotationZ, sStreifenZ); return (sReturn); }
/* Function GeoDllSetuserrefsys *****************************************/ /* Define user Reference System with seven Helmert transformation */ /* parameters */ /* The parameters descriptions are in the file GeoDLL_e.chm */ short int __cdecl GeoDllSetuserrefsys (short int sRefSysTyp, double dTranslX, double dTranslY, double dTranslZ, double dRotX, double dRotY, double dRotZ, double dMasstab) { short int sReturn = 0; sReturn = pfnSetuserrefsys(sRefSysTyp, dTranslX, dTranslY, dTranslZ, dRotX, dRotY, dRotZ, dMasstab); return (sReturn); }
/* Function GeoDllSetuserellsource *******************************************/ /* Define user source ellipsoid with both semi axes */ /* The parameters descriptions are in the file GeoDLL_e.chm */ short int __cdecl GeoDllSetuserellsource (short int sEllSource, double dHalbAchsGrQ, double dHalbAchsKlQ) { short int sReturn = 0; sReturn = pfnSetuserellsource(sEllSource, dHalbAchsGrQ, dHalbAchsKlQ); return (sReturn); }
/* Function GeoDllSetuserelltarget ******************************************/ /* Define user target ellipsoid with both semi axes */ /* The parameters descriptions are in the file GeoDLL_e.chm */ short int __cdecl GeoDllSetuserelltarget (short int sEllTarget, double dHalbAchsGrZ, double dHalbAchsKlZ) { short int sReturn = 0; sReturn = pfnSetuserelltarget(sEllTarget, dHalbAchsGrZ, dHalbAchsKlZ); return (sReturn); }
/* Function GeoDllDistancegeo **********************************************/ /* Perform distance calculation */ /* The parameters descriptions are in the file GeoDLL_e.chm */ short int __cdecl GeoDllDistancegeo (double dGeoLaenge1, double dGeoBreite1, double dGeoLaenge2, double dGeoBreite2, double *dStrecke, short int sEllipsoid) { short int sReturn = 0; sReturn = pfnDistancegeo(dGeoLaenge1, dGeoBreite1, dGeoLaenge2, dGeoBreite2, dStrecke, sEllipsoid); return (sReturn); }
/************************************************************************/ /* Samples of function calls to the functions */ /* defined in the C++ interface with access to the */ /* Dynamic Link Library GeoDLL */ /* */ /* This source code does not belong to the C++ interface */ /* */ /* Author: Killet GeoSoftware Ing.-GbR */ /************************************************************************/
void main(void) {
/* Variables */ double dEastValue, dNorthValue, dDistance;
/* Load GeoDLL */ if (!GeoDllLoadLib()) { printf("Error in GeoDllLoadLib"); Sleep(10000); exit(1); }
/* Unlock function group "Coordinate Transformations" */ /* This unlock parameters do not work! */ /* The originals must be acquired from Killet GeoSoftware Ing.-GbR! */ /* Full version: Unlock parameters must be correct at the first input! */ /* Test version: Function may not be called! */ /* The test version without unlocking works per program run a short time!*/ /* if (!GeoDllSetunlockcode("123454321-678901234","MacroModia GmbH")) */ /* { */ /* printf("Error in GeoDllSetunlockcode\n"); */ /* Sleep(10000); */ /* exit(1); */ /* } */
/* Unlock function group "user definitions" */ /* Consider the references specified above! */ /* if (!GeoDllSetunlockcode("234566543-789014545","MacroModia GmbH")) */ /* { */ /* printf("Error in GeoDllSetunlockcode\n"); */ /* Sleep(10000); */ /* exit(1); */ /* } */
/* Unlock function group "distance calculations" */ /* Consider the references specified above! */ /* if (!GeoDllSetunlockcode("345678876-890120987","MacroModia GmbH")) */ /* { */ /* printf("Error in GeoDllSetunlockcode\n"); */ /* Sleep(10000); */ /* exit(1); */ /* } */
/* Define user Reference System */ /* The function must be used only, if an own Reference System is */ /* to be difined */ if (!GeoDllSetuserrefsys(1, -661.9, 155.2, -441.3, 0.332, 0.172, -2.994, -8.99)) printf("Error in GeoDllSetuserrefsys\n");
/* Define user source ellipsoid */ /* The function must be used only, if an own Reference System is */ /* to be difined */ if (!GeoDllSetuserellsource(1000, 6378127.0, 6356752.3)) printf("Error in GeoDllSetuserellsource\n");
/* Define user target ellipsoid */ /* The function must be used only, if an own Reference System is */ /* to be difined */ if (!GeoDllSetuserelltarget(1000, 6377397.0, 6356078.0)) printf("Error in GeoDllSetuserelltarget\n");
/* Coordinate Transformation */ /* Geographic Coordinates to Gauss-Krueger */ /* Continuing the Bessel Reference System */ /* Decimal notation of the source coordinates */ /* Calculation for the third Gauss-Krueger meridian strip */ if (!GeoDllTrans(10.2349934, 52.3188386, 1, 1, 0, &dEastValue, &dNorthValue, 2, 1, 0, 3)) printf("Error in GeoDllTrans\n"); else printf("Result: Easting %f Northing: %f\n",dEastValue,dNorthValue);
/* Coordinate Transformation */ /* Geographic Coordinates to Gauss-Krueger */ /* Usage of with GeoDllSetuserrefsys() defined Reference Systems */ /* Decimal notation of the source coordinates */ /* Calculation for the third Gauss-Krueger meridian strip */ if (!GeoDllTrans(10.2349934, 52.3188386, 1, 1000, 0, &dEastValue, &dNorthValue, 2, 100, 0, 3)) printf("Error in GeoDllTrans\n"); else printf("Result: Easting %f Northing: %f\n",dEastValue,dNorthValue);
/* Distance calculation */ /* Bessel ellipsoid */ /* Decimal notation of the coordinates */ if (!GeoDllDistancegeo(10.2349934, 52.3188386, 10.3216545, 52.1343436, &dDistance, 1)) printf("Error in GeoDllDistancegeo\n"); else printf("Result: Distance %f\n",dDistance);
/* Wait for a key stroke */ Sleep(10000); exit(0); }
|