pur
Killet GeoSoftware Ing.-GbR - short: KilletSoft - is a software company, which was established in the year 1991. The society is divided into the ranges "Geodetic Standard Software", "Development Tools for Geoinformatics" and "German Geodata". The focal trades of the companies supplied by KilletSoft are consulting engineers, GIS developers, Internet marketing, public utilities, logistics, telecommunications, security and public services.
 •  Print page content  •  link_in Company •  link_in Contact •  link_in Imprint
Deutsch English

GeoDLL - Development environment for a programming example with geodetic functions

GeoDLL Formula GeoDLL Example Program

GeoDLL - Programming example

You can link_in download this programming example as C/C++ 32 Bit Microsoft Visual Studio Project including the executable program. And you can link_in download it as C/C++ 64 Bit Microsoft Visual Studio Project including the executable program.
   
/******************************************************************************/
/*                                                                            */
/*           Template of a C / C++ program as Visual Studio Project           */
/* for some function calls of the 32 bit Geodetic Development Kit GeoDLL.     */
/* The template can be extended for other GeoDLL function calls if necessary. */
/*                                                                            */
/*----------------------------------------------------------------------------*/
/*                                                                            */
/* Required external files:                                                   */
/*   1. GeoDLL32.h:   Include the header file in the Visual Studio project    */
/*   2. GeoDLL32.lib: Include the library file in the Visual Studio project   */
/*   3. GeoDLL32.dll: The DLL must be present in the EXE start directory      */
/*   4. GeoDLLbn.bin: The Binary must be present in the EXE start directory   */
/*                                                                            */
/* Download of the complete Visual Studio project GeoTestCpp:                 */
/*   https://www.killetsoft.de/zip/geotestcpp.zip                             */
/*                                                                            */
/* Online user manual with all function declarations:                         */
/*   https://www.killetsoft.de/h_geodll_e/handbuch_e.htm in English langeuage */
/*   https://www.killetsoft.de/h_geodll_e/handbuch_d.htm in German langeuage  */
/*                                                                            */
/* In the GeoDLL download included help files with all function declarations: */
/*   GeoDLL_e.chm in English langeuage                                        */
/*   GeoDLL_e.chm in German langeuage                                         */
/*                                                                            */
/* Author of this source and GeoDLL:                                          */
/*   Dipl.-Ing. Fred Killet                                                   */
/*   Killet GeoSoftware Ing.-GbR                                              */
/*   https://www.killetsoft.de                                                */
/*                                                                            */
/******************************************************************************/


//============================================================================== 

// English:
// Program for testing some functions of the Geodetic Software Development Kit
// GeoDLL, provided by Killet GeoSoftware Ing.-GbR.

// The program is written in the programming language C++ and devoloped under
// Microsoft Visual Studio 2010. It shell exemplary explain the creation of own
// applications, which use geodetic functions from GeoDLL. 

// For linking the GeoDLL functions to your own application, the supplied files
// GeoDLL32.h and GeoDll32.lib are used in the project. The files GeoDLL32.dll
// and GeoDLLbn.bin must be available in your applications start directory.

//============================================================================== 

// German:
// Programm zum Testen einiger Funktionen aus dem von Killet GeoSoftware Ing.-GbR
// entwickelten Geodätischen Software Development Kit GeoDLL.

// Das Programm ist in der Programmiersprache C++ geschrieben und unter
// Microsoft Visual Studio 2010 entwickelt worden. Es soll beispielhaft die
// Erstellung eigener Applikationen unter Verwendung von geodätischen Funktionen
// aus der GeoDLL erläutern.

// Zum Linken der GeoDLL-Funktionen in Ihre eigene Applikation werden die
// mitgelieferten Dateien GeoDLL32.h und GeoDll32.lib verwendet. Die Dateien
// GeoDLL32.dll und GeoDLLbn.bin müssen im Aufrufverzeichnis Ihrer Applikation
// vorhanden sein.

//==============================================================================


//------------------------------------------------------------------------------
// Includes Plattform SDK
//------------------------------------------------------------------------------
#include 
#include 
#include 
#include 


//------------------------------------------------------------------------------
// Project Spezific Includes 
//------------------------------------------------------------------------------

// Header of alle GeoDLL functions
#include "geodll32.h"


//------------------------------------------------------------------------------
// Modul internal Prototypes
//------------------------------------------------------------------------------
void wait(int iSeconds);


//------------------------------------------------------------------------------
// Main Function with GeoDLL function calls
//------------------------------------------------------------------------------
int main(int argc,char* argv[])
{

  // Variables
  long int nRet;
  unsigned short nTimezone,nTzType,nFast;
  unsigned long nDstStart,nDstEnd,lIsDstActiv,lIsSouthHemi;
  double dCoordXQ,dCoordYQ,dEllHgtQ,dCoordXZ,dCoordYZ,dEllHgtZ,dLongitude,
         dLatitude,dGeoLon1,dGeoLat1,dGeoLon2,dGeoLat2,dDistance,dAzimut;
  float fLocalTime,fUtc,fDst;
  char pszCoordQ[20],pszDummy[20],pszTitle[100];
  char *ppszVersion,*ppszDummy,*ppszError,*ppszCoordZ,*ppszTzFile,*ppszTimezone;

  // Console title
  getdllversion(&ppszVersion);
  sprintf_s(pszTitle,100,"KilletSoft GeoDLL %s --- Template with some Function calls",ppszVersion);
  SetConsoleTitle(pszTitle);

  // Suppress GeoDLL message about shareware version and write it to EventLog
  setsilence(true);

  // Set GeoDLL internal language to English
  setlanguage(2);
  
  // Explanation
  printf("You can use all features of GeoDLL in your own application initially free.\n");
  printf("However, the number of function calls per program run is limited to 100\n");
  printf("geodetic calculations. Also in the free test version a message appears\n");
  printf("on the screen or is written to the EventLog and a tone sequence is sounded.\n");
  printf("\n");
  printf("By purchasing a licence the restrictions will be canceled. For unlocking\n");
  printf("you get an user name and an unlock code from KilletSoft.\n");
  printf("\n");
  printf("The GeoDLL function groups required by your application must be unlocked\n");
  printf("in the initialization part of your program with the function setunlockcode().\n");
  printf("The function gets the user name and the unlock code as parameters.\n");
  printf("\n");
  printf("How to do that I will show you here. Of course, these unlock parameters\n");
  printf("are fictitious and do not work. Therefore the error message and following\n");
  printf("tone sequence are correct in this case!\n");
  printf("\n");
  printf("nRet = setunlockcode(\"123456789-987654321\",\"MicroModia GmbH\");\n");
  printf("if(! nRet)\n");
  printf("  geterrorcode(&ppszError);\n");
  printf("\n");

  // Calling setunlockcode()
  // Set the original unlock parameters you got from Killetsoft here:
  nRet = setunlockcode(
         "123456789-987654321",  // char *pszUnlockkey  Unlock key
         "MicroModia GmbH");     // char *pszLicensee   User name

  // Output of the results.
  if(nRet)
    printf("GeoDLL functions unlocked!\n");
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL functions remain locked!\n");
    printf("No problem! Continue in trial mode!\n");
    printf("Error: %s\n",ppszError);
  }

  // Wait for Key Press or Mouse Click.
  wait(60);

//------------------------------------------------------------------------------
// Coordinate Transformations with the function coordtrans()
//------------------------------------------------------------------------------

  // Explanation
  printf("Now we start transforming coordinates. Here only the use of the GeoDLL\n");
  printf("function coordtrans() is demonstrated. But you can also use any other\n");
  printf("function for coordinate transformations available in GeoDLL. The required\n");
  printf("Coordinate Systems and Reference Systems you find sorted by countries in\n");
  printf("the User Manual GeoDLL_e.chm, chapter \"Coodinate Transformations\", in the\n");
  printf("file README.DOC or in the Online User Manual.\n");
  printf("\n");

  // Gauss-Kueger, DHDN --> UTM, ETRS89 
  dCoordXQ = 2531365.9784407;
  dCoordYQ = 5695802.9495895;
  nRet =  coordtrans(
          dCoordXQ,            // double dCoordXQ
          dCoordYQ,            // double dCoordYQ
          pszDummy,            // char *pszCoordQ               
          (unsigned short)2,   // unsigned short nCoordSysQ  Gauss-Krueger
          (unsigned short)17,  // unsigned short nRefSysQ    DHDN
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          &ppszDummy,          // char **pszCoordZ
          (unsigned short)3,   // unsigned short nCoordSysZ  UTM
          (unsigned short)4,   // unsigned short nRefSysZ    ETRS89
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("Gauss-Kueger, DHDN --> UTM, ETRS89\n");
    printf("Gauss-Krueger Easting =  %.8f\n",dCoordXQ);
    printf("Gauss-Krueger Northing = %.8f\n",dCoordYQ);
    printf("UTM Easting =            %.8f\n",dCoordXZ);
    printf("UTM Northing =           %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // UTM, ETRS89 -- > UTMRef (Centimeter Grid), ED50 (Europe)
  // Note:
  // GeoDLL is able to allocate memory for returnable PSZ parameters internally
  // and makes them accessible to the calling program by global stored addresses.
  // In the calling program then neither memory must allocated nor memory must
  // released later. For more information see function setstringallocate().
  dCoordXQ = dCoordXZ;
  dCoordYQ = dCoordYZ;
  nRet =  coordtrans(
          dCoordXQ,            // double dCoordXQ
          dCoordYQ,            // double dCoordYQ
          pszDummy,            // char *pszCoordQ
          (unsigned short)3,   // unsigned short nCoordSysQ  UTM
          (unsigned short)4,   // unsigned short nRefSysQ    ETRS89
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          &ppszCoordZ,         // char **pszCoordZ
          (unsigned short)661,  // unsigned short nCoordSysZ  UTMref (Centimeter Grid)
          (unsigned short)2,   // unsigned short nRefSysZ    ED50
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("UTM, ETRS89 -- > UTMRef (Centimeter Grid), ED50 (Europe)\n");
    printf("UTMRef grid coordinate = %s\n",ppszCoordZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // UTMRef (Centimeter Grid), ED50 (Europe) --> Geographic Coordinates, WGS84
  strcpy_s(pszCoordQ, ppszCoordZ);
  nRet =  coordtrans(
          (double)0.0,         // double dCoordXQ
          (double)0.0,         // double dCoordYQ
          pszCoordQ,           // char *pszCoordQ
          (unsigned short)661, // unsigned short nCoordSysQ  UTMref (Centimeter Grid)
          (unsigned short)2,   // unsigned short nRefSysQ    ED50
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          &ppszDummy,          // char **pszCoordZ
          (unsigned short)6,   // unsigned short nCoordSysZ  Geo. Coord
          (unsigned short)10,  // unsigned short nRefSysZ    WGS84
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("UTMRef (Centimeter Grid), ED50 (Europe) --> Geographic Coordinates, WGS84\n");
    printf("Longitude =              %.8f\n",dCoordXZ);
    printf("Latitude =               %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // Geographic Coordinates, WGS84 --> Gauss-Kueger, DHDN
  dCoordXQ = dCoordXZ;
  dCoordYQ = dCoordYZ;
  nRet =  coordtrans(
          dCoordXQ,            // double dCoordXQ
          dCoordYQ,            // double dCoordYQ
          pszCoordQ,           // char *pszCoordQ
          (unsigned short)6,   // unsigned short nCoordSysQ  Geo. Coord
          (unsigned short)10,  // unsigned short nRefSysQ    WGS84
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          &ppszDummy,          // char **pszCoordZ
          (unsigned short)2,   // unsigned short nCoordSysZ  Gauss-Krueger
          (unsigned short)17,  // unsigned short nRefSysZ    DHN
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("Geographic Coordinates, WGS84 --> Gauss-Kueger, DHDN\n");
    printf("Gauss-Krueger Easting =  %.8f\n",dCoordXZ);
    printf("Gauss-Krueger Northing = %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // Wait for Key Press or Mouse Click.
  wait(60);

//------------------------------------------------------------------------------
// The simplest Coordinate Transformations with the function coordtrans4()
//------------------------------------------------------------------------------

  // Explanation
  printf("The easiest way to transform coordinates is to use the coordtrans4\n");
  printf("function. However, alphanumeric coordinate transformations and also 3D\n");
  printf("transformations are not possible with this function.\n");
  printf("Here are some examples:\n");
  printf("\n");

  // Gauss-Kueger, DHDN --> UTM, ETRS89
  dCoordXQ = 2531365.9784407;
  dCoordYQ = 5695802.9495895;
  nRet =  coordtrans4(
          dCoordXQ,            // double dCoordXQ
          dCoordYQ,            // double dCoordYQ
          (unsigned short)2,   // unsigned short nCoordSysQ  Gauss-Krueger
          (unsigned short)17,  // unsigned short nRefSysQ    DHDN
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          (unsigned short)3,   // unsigned short nCoordSysZ  UTM
          (unsigned short)4,   // unsigned short nRefSysZ    ETRS89
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("Gauss-Kueger, DHDN --> UTM, ETRS89\n");
    printf("Gauss-Krueger Easting =  %.8f\n",dCoordXQ);
    printf("Gauss-Krueger Northing = %.8f\n",dCoordYQ);
    printf("UTM Easting =            %.8f\n",dCoordXZ);
    printf("UTM Northing =           %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // Geographic coord. [deg], WGS84 --> Geographic coord. [deg], ETRS89
  dCoordXQ = 9.469242;
  dCoordYQ = 47.663119;
  nRet =  coordtrans4(
          dCoordXQ,            // double dCoordXQ
          dCoordYQ,            // double dCoordYQ
          (unsigned short)6,   // unsigned short nCoordSysQ  Geographic coord.
          (unsigned short)10,  // unsigned short nRefSysQ    WGS84
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          (unsigned short)6,   // unsigned short nCoordSysZ  Geographic coord.
          (unsigned short)4,   // unsigned short nRefSysZ    ETRS89
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("Geographic coord., WGS84 --> Geographic coord., ETRS89\n");
    printf("Longitude WGS84 =        %.8f\n",dCoordXQ);
    printf("Latitude WGS84 =         %.8f\n",dCoordYQ);
    printf("Longitude ETRS89 =       %.8f\n",dCoordXZ);
    printf("Latitude ETRS89 =        %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // UTM, WGS84 --> UTM, ETRS89
  dCoordXQ = 32535230.5818717;
  dCoordYQ = 5278965.0465970;
  nRet =  coordtrans4(
          dCoordXQ,            // double dCoordXQ
          dCoordYQ,            // double dCoordYQ
          (unsigned short)3,   // unsigned short nCoordSysQ  UTM
          (unsigned short)10,  // unsigned short nRefSysQ    WGS84
          &dCoordXZ,           // double *dCoordXZ
          &dCoordYZ,           // double *dCoordYZ
          (unsigned short)3,   // unsigned short nCoordSysZ  UTM
          (unsigned short)4,   // unsigned short nRefSysZ    ETRS89
          (unsigned short)0);  // unsigned short nStripZ

  // Output of the results.
  if(nRet)
  {
    printf("UTM, WGS84 --> UTM, ETRS89\n");
    printf("UTM Easting, WGS84 =     %.8f\n",dCoordXQ);
    printf("UTM Northing, WGS84 =    %.8f\n",dCoordYQ);
    printf("UTM Easting, ETRS89 =    %.8f\n",dCoordXZ);
    printf("UTM Northing, ETRS89 =   %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf("\n");

  // Wait for Key Press or Mouse Click.
  wait(60);

//------------------------------------------------------------------------------
// Coordinate Transformations with the function coordtransepsg()
//------------------------------------------------------------------------------

  // Explanation
  printf("For simplicity, it is possible to perform all required settings for the\n");
  printf("parameters Coordinate System, Reference System, Meridian Strip, Meridian\n");
  printf("Strip Suffix and 2D/3D Modus by using so-called EPSG codes. EPSG is the\n");
  printf("acronym for \"European Petroleum Survey Group Geodesy\". This is a working\n");
  printf("group of the European oil and gas exploration companies. The EPSG and\n");
  printf("their successors OGP \"International Association of Oil and Gas Producers\"\n");
  printf("have made it to their task to build a system with globally unique\n");
  printf("identifiers (EPSG codes) for geodetic data, such as Coordinate Reference\n");
  printf("Systems, Reference Ellipsoids or Map Projections.\n");
  printf("\n");
  printf("The required EPSG Codes you find in the User Manual GeoDLL_e.chm, chapter\n");
  printf("\"Coordinate Transformations\", in the Online Manual or in the EPSG database.\n");
  printf("\n");
  printf("This EPSG Codes for Coordinate Reference Systems are used:\n");
  printf("31466: EPSG code for \"DHDN / 3-deg. Gauss-Krueger zone 2\"\n");
  printf("4647: EPSG code for \"ETRS89 / UTM zone 32N (zE-N)\"\n");
  printf("\n");

  // Gauss-Kueger, DHDN --> UTM, ETRS89
  dCoordXQ = 2531418.55;
  dCoordYQ = 5695935.71;
  dEllHgtQ = 0.0;
  nRet =  coordtransepsg(
          dCoordXQ,              // double dCoordXQ
          dCoordYQ,              // double dCoordYQ
          dEllHgtQ,              // double dEllHgtQ  Ell. Height not usesed
          (unsigned short)31466, // unsigned short nEpsgQ  Epsg Code source
          &dCoordXZ,             // double *dCoordXZ
          &dCoordYZ,             // double *dCoordYZ
          &dEllHgtZ,             // double* dEllHgtZ  Ell. Height not usesed
          (unsigned short)4647); // unsigned short nEpsgZ  Epsg Code target

  // Output of the results.
  if(nRet)
  {
    printf("Gauss-Kueger, DHDN --> UTM, ETRS89\n");
    printf("Gauss-Krueger Easting =  %.8f\n",dCoordXQ);
    printf("Gauss-Krueger Northing = %.8f\n",dCoordYQ);
    printf("UTM Easting =            %.8f\n",dCoordXZ);
    printf("UTM Northing =           %.8f\n",dCoordYZ);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("GeoDLL coordinate transformation failed!\n");
    printf("Error: %s\n",ppszError);
  }

  // Wait for Key Press or Mouse Click.
  wait(60);

//------------------------------------------------------------------------------
// Time zone functions
// Activate timezone shapefile with the function settzshapefile()
// or
// activate timezone gridfile with the function settzgridile()
//------------------------------------------------------------------------------

  // Explanation
  printf("A time zone is a region that has an uniform standard time for legal,\n");
  printf("commercial and social purposes. Time zones are primarily longitude\n");
  printf("dependent, but secondary they follow the boundaries of countries or their\n");
  printf("administrative subdivisions. The time zones supported by GeoDLL are based\n");
  printf("on an uniform naming convention, designed by Paul Eggert, such as\n");
  printf("America/New_York and Europe/Paris. The time zones have offsets from\n");
  printf("Coordinated Universal Time (UTC) as a number of hours (UTC-12 to UTC+12).\n");
  printf("Many higher latitude countries use Daylight Saving Time (DST) for a part\n");
  printf(" of the year, typically by changing clocks one hour forward.\n");
  printf("\n");

  // Download the timezone shapefile or the timezone gridfile from the KilletSoft
  // internet site: http://www.killetsoft.de/p_gdlz_d.htm#download.
  // Make your changes for the path of the timezone files here.
  // You can set the shapefile or the gridfile or nothing. In the last case
  // default settings for the further timezone calculations are used.
  ppszTzFile = "c:\\programm\\geodll\\timezone\\shape\\geodlltz.shp";  // <== here
  nRet = settzshapefile(ppszTzFile);       // Path of the timezone shapefile
  nFast = 0;
  if(! nRet)
  {
    nFast = 1;
    ppszTzFile = "c:\\programm\\geodll\\timezone\\grid\\geodlltz.grd";  // <== here
    nRet = settzgridfile(ppszTzFile);      // Path of the timezone gridfile
  }

  // If no timezone file is in use, defaults are used  
  if(! nRet)
    nTzType = 5;  // 5 = international timezone if no timezone file in use
  else
    nTzType = 0;  // 5 = national timezone if timezone file in use

//------------------------------------------------------------------------------
// Get time zone index from coordinates with function gettznumbycoordfast()
//------------------------------------------------------------------------------

  dLongitude = -74.005833;
  dLatitude = 40.712778;
  if (nFast)
    nRet = gettznumbycoordfast(
           dLongitude,        // double dLongitude
           dLatitude,         // double dLatitude
           nTzType,           // unsigned short nTzType
           &nTimezone);       // unsigned short *nTimezone
  else 
    nRet = gettznumbycoordexact(
           dLongitude,        // double dLongitude
           dLatitude,         // double dLatitude
           nTzType,           // unsigned short nTzType
           &nTimezone);       // unsigned short *nTimezone

  // Output of the results.
  if(nRet)
  {
    if (nFast)
      printf("gettznumbycoordfast() - Get GeoDLL time zone index from coordinates\n");
    else
      printf("gettznumbycoordexact() - Get GeoDLL time zone index from coordinates\n");
    if (nTzType = 5)
    {
      printf("Here only an international timzone is calculated, because national timezones\n");
      printf("need a gridfile or shapefile, downloadable from the KilletSoft website.\n");
    }
    printf("Longitude = %f  Latitude = %f  Timezone index = %d\n",dLongitude,dLatitude,nTimezone);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("Calculation of time zone index failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf ("\n") ;

//------------------------------------------------------------------------------
// Get time zone name from time zone index with function gettznamebynum()
//------------------------------------------------------------------------------

  if (nTzType == 5)
    nTimezone = 8;       // 8 = Europa/Berlin if no timezone file in use
  nRet = gettznamebynum(
         nTimezone,      // unsigned short nTimezone
         &ppszTimezone); // char **pszTimezone 

  // Output of the results.
  if(nRet)
  {
    printf("gettznamebynum() - Get time zone name from time zone index.\n");
    if (nTzType = 5)
    {
      printf("Here the default national timezone index 8 of Europe/Berlin is used,\n");
      printf("because no gridfile nor shapefile is set in GeoDLL.\n");
    }
    printf("Time Zone Name =  %s\n",ppszTimezone);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("Calculation of time zone name failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf ("\n") ;

//------------------------------------------------------------------------------
// Get current tz parameters from tz index with function gettzcurrentbynum()
//------------------------------------------------------------------------------

  nRet = gettzcurrentbynum(
         nTimezone,     // unsigned short nTimezone
         &fUtc,         // float *fUtc
         &fDst,         // float *fDst
         &lIsDstActiv,  // unsigned long *lIsDstActiv
         &nDstStart,    // unsigned long *nDstStart
         &nDstEnd,      // unsigned long *nDstEnd
         &lIsSouthHemi, // unsigned long *lIsSouthHemi
         &fLocalTime);  // float *fLocalTime

  // Output of the results.
  if(nRet)
  {
    printf("gettzcurrentbynum() - Get current time zone parameters from time zone index\n");
    printf("UTC = %+3.1f   DST = %+3.1f   DST in effect = %s   Current UTC+DST = %+3.1f\n",
           fUtc,fDst,lIsDstActiv ? "yes" : "no",fLocalTime);
    printf("DST start date (yyyymmdd) = %d   DST end date (yyyymmdd) = %d\n",nDstStart,nDstEnd);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("Calculation of time zone parameters failed!\n");
    printf("Error: %s\n",ppszError);
  }

  // Wait for Key Press or Mouse Click.
  wait(60);  

//------------------------------------------------------------------------------
// Distance and bearing calculations
// Distance calculation with the function distancegeo()
//------------------------------------------------------------------------------

  // Explanation
  printf("Often it is necessary to calculate the distance between two points fast and\n");
  printf("accurate. For example this is necessary for the realization of a radial search.\n");
  printf("Here I introduce the function distancegeo(), which calculates the distance\n");
  printf("between two Geographic Coordinates on the earth ellipsoid.\n");
  printf("The point2pointgeo() function calculates the coordinates of a destination point\n");
  printf("from the coordinates of the start point, the forward bearing and the distance\n");
  printf("between the points.\n");
  printf("\n");

  dGeoLon1 = 11.55;  // Geographic longitude of the 1th point
  dGeoLat1 = 51.32;  // Geographic latitude of the 1th point
  dGeoLon2 = 14.03;  // Geographic longitude des 2nd point
  dGeoLat2 = 53.48;  // Geographic latitude of the 2nd point
  nRet = distancegeo(
         dGeoLon1,            // double dGeoLon1
         dGeoLat1,            // double dGeoLat1
         dGeoLon2,            // double dGeoLon2
         dGeoLat2,            // double dGeoLat2
         &dDistance,          // double *dDistance
         (unsigned short)10); // unsigned short nEllipsoid (10 = WGS84)

  // Output of the results.
  if(nRet)
  {
    printf("distancegeo() - Calculate distance between two coordinates\n");
    printf("Longitude of 1th point = %f  Latitude of 1th point = %.8f\n",dGeoLon1,dGeoLat1);
    printf("Longitude of 2nd point = %f  Latitude of 2nd point = %.8f\n",dGeoLon2,dGeoLat2);
    printf("Calculated distance between points = %.8f\n",dDistance);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("Distance calculation failed!\n");
    printf("Error: %s\n",ppszError);
  }
  printf ("\n") ;

//------------------------------------------------------------------------------

// Calculation of a target point coordinate with point2pointgeo()
//------------------------------------------------------------------------------

  dGeoLon1 = 11.55;   // Geographic longitude of the start point
  dGeoLat1 = 51.32;   // Geographic latitude of the start point
  dDistance = 521434; // Distance to the target point in meter
  dAzimut = 122.5;    // Forward azimutal bearing
  nRet = point2pointgeo(
         dGeoLon1,            // double dGeoLon1
         dGeoLat1,            // double dGeoLat1
         dDistance,           // double dDistance
         dAzimut,             // double dAzimut
         &dGeoLon2,           // *double dGeoLon2
         &dGeoLat2,           // *double dGeoLat2
         (unsigned short)10); // unsigned short nEllipsoid (10 = WGS84)

  // Output of the results.
  if(nRet)
  {
    printf("point2pointgeo() - Calculate target coordinate from start coordinate and distance\n");
    printf("Longitude of start point = %f  Latitude of start point = %.8f\n",dGeoLon1,dGeoLat1);
    printf("Bearing to dest. point =   %.8f\n",dAzimut);
    printf("Dist. to the dest. point = %.8f\n",dDistance);
    printf("Longitude of dest. point = %f  Latitude of target point = %.8f\n",dGeoLon2,dGeoLat2);
  }
  else
  {
    geterrorcode(&ppszError);
    printf("Coordinates and bearing calculation failed!\n");
    printf("Error: %s\n",ppszError);
  }

  // Wait for Key Press or Mouse Click.
  wait(60);
  return 0;
}


//------------------------------------------------------------------------------
// Function wait() generates a waiting time of iSeconds seconds. The waiting
// time is interrupted when a key or a mouse button has been pressed.
// Clears the screen after waiting ans sets the cursor to the screens top.
//------------------------------------------------------------------------------

void wait(int iSeconds)
{

  // Variables
  clock_t clWait;
  unsigned long nNumEvent,nWritCells,nNumCells;
  HANDLE hConsole;
  INPUT_RECORD irBuffer;
  COORD coScrPos = {0,0}; 
  CONSOLE_SCREEN_BUFFER_INFO csbInfo; 

  // Calculate waiting time
  clWait = clock() + iSeconds * CLOCKS_PER_SEC;

  // Show waiting hint
  printf("\n");
  printf("Please click mouse or press a key!");

  // Remove all still existing events from the console
  hConsole = GetStdHandle(STD_INPUT_HANDLE);
  FlushConsoleInputBuffer(hConsole);

  // Stop waiting time on mouse click or key press
  while(clock() < clWait)
  {
    nNumEvent = 0;
    if(GetNumberOfConsoleInputEvents(hConsole,&nNumEvent) && nNumEvent > 0)
    {
      nNumEvent = 0;
      if(ReadConsoleInput(hConsole,&irBuffer,1,&nNumEvent) && nNumEvent == 1)
      {
        if(irBuffer.EventType == MOUSE_EVENT)
        {
          if(irBuffer.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
            break;
          else if(irBuffer.Event.MouseEvent.dwButtonState == RIGHTMOST_BUTTON_PRESSED)
            break;
        }
        else if(irBuffer.EventType == KEY_EVENT)
        {
          if(irBuffer.Event.KeyEvent.bKeyDown)
            break;
        }
      }
    }

    // Wait 1/10 second to remain processor load low.
    Sleep(100); 
  }

  // Clear screen
  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  GetConsoleScreenBufferInfo(hConsole, &csbInfo );
  nNumCells = csbInfo.dwSize.X * csbInfo.dwSize.Y;
  FillConsoleOutputCharacter(hConsole,' ',nNumCells,coScrPos,&nWritCells);

  // Cursor at screen top
  SetConsoleCursorPosition(hConsole,coScrPos);
  return;
}
   
  
KilletSoft News In order that you are always well informed about our company, we write actual news, current information and special offers here into this column.
pur
KilletSoft Logo Geodata Germany
All georeferenced databases has been updated to the data conditions of January 1st, 2024. The database tables of "GeoData Germany" contain all German towns, municipalities and urban districts, coordinates, postal codes, dialling codes, administrative units, nature areas, landscapes, travel areas, wind and snow loads, solar irradiation, cartographies info etc.
link_in Read more...
KilletSoft Logo New work sheet
Modeling an NTv2 file under the aspect of economic efficiency.
link_in Read the work sheet...
KilletSoft Logo New work sheet
Display Formats of UTM Coordinates.
Display formats, calculation methods and the historical background of the UTM coordinate system.
Third revised edition of the popular technical article.
link_in Read the work sheet...
KilletSoft Logo New work sheet
What actually is a Coordinate Reference System?
Explanation of the Coordinate Reference System with the components Coordinate System, Reference System, Reference Definition and Reference Frame.
Second revised edition.
link_in Read the work sheet...
KilletSoft Logo Illegal software versions
The illegal use of our software got out of control!
link_in Read our Info...
KilletSoft Logo NTv2 collection
KilletSoft has brought together NTv2 files as a worldwide collection on a central website and linked for the direct download.
link_in Read the Press Release...
link_in To the NTv2 collection...
KilletSoft Logo is member of
VDV Logo
KilletSoft Logo Translators wanted!
The programs TRANSDAT, SEVENPAR, NTv2Creator, NTv2Poly and NTv2Tools support language files for the programs interface. Since the language dependent texts are managed in external files, link_in new languages can be added at any time by creating new language files. Everybody who is interested can translate a new language file into his native language for himself and all users.
Author: Dipl.-Ing. Fred Killet
Page name: p_gdls_e.htm
Page views: 98
Period: since Januar 1, 2024