False positive report example code - geostan_1 - 2024.01

GeoStan Geocoding Suite Reference for Windows, Linux, and z/OS

Product type
Software
Portfolio
Locate
Product family
GeoStan Geocoding Suite
Product
GeoStan Geocoding Suite > GeoStan
Version
2024.01
Language
English
Product name
GeoStan
Title
GeoStan Geocoding Suite Reference for Windows, Linux, and z/OS
Copyright
2024
First publish date
1994
Last updated
2024-07-29
Published on
2024-07-29T23:01:18.924000

The following code is an example of how to implement DPV and LACSLink false positive reporting using the C language:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define GEOSTAN_PROPERTIES
#include "geostan.h"
int main(int argc, pstr * argv)
{
   GsId gs;
   GsFunStat retcode;
   char buffer[GS_MAX_STR_LEN];
   char buffer2[GS_MAX_STR_LEN];
   FILE * DPVfalsPosOut; /* DPV false positive file pointer */
   FILE * LACSfalsPosOut; /* LACSLink false positive file pointer */
   GsFalsePosHeaderData FPheaderData; /* DPV/LACSLink false positive header record */
   GsFalsePosDetailData FPdetailData; /* DPV/LACSLink false positive detail record */
   char * mailerName = "Precisely";
   char * mailerAddress = "4750 WALNUT ST STE 200";
   char * mailerCity = "BOULDER";
   char * mailerState = "CO";
   char * mailerZip = "803012532";
   PropList initProps;
   PropList statusProps;
   PropList findProps;
   qbool bVal;
   GsPropListCreate( &initProps, GS_INIT_PROP_LIST_TYPE );
// Replace paths and keys with your installation
   GsPropSetStr( &initProps, GS_INIT_DPV_SECURITYKEY, "1237-5678-9abc-def0" );
   GsPropSetStr( &initProps, GS_INIT_DPV_DIRECTORY, "C:\\Program Files\\Precisely\\Datasets\\Current" );
   GsPropSetLong( &initProps, GS_INIT_DPV_DATA_ACCESS, DPV_DATA_FULL_FILEIO );
   GsPropSetBool( &initProps, GS_INIT_DPV, TRUE );
   GsPropSetStr( &initProps, GS_INIT_LACSLINK_SECURITY_KEY, "1237-5678-9abc-def0" );
   GsPropSetStr( &initProps, GS_INIT_LACSLINK_DIRECTORY, "C:\\Program Files\\Precisely\\Datasets\\Current" );
   GsPropSetBool( &initProps, GS_INIT_LACSLINK, TRUE );
   GsPropSetStr( &initProps, GS_INIT_SUITELINK_DIRECTORY, "C:\\Program Files\\Precisely\\Datasets\\Current" );
   GsPropSetBool( &initProps, GS_INIT_SUITELINK, TRUE );
   GsPropSetLong( &initProps, GS_INIT_GSVERSION, GS_GEOSTAN_VERSION );
   GsPropSetBool( &initProps, GS_INIT_OPTIONS_ADDR_CODE, TRUE );
   GsPropSetBool( &initProps, GS_INIT_OPTIONS_Z9_CODE, TRUE );
   GsPropSetStr( &initProps, GS_INIT_DATAPATH, "C:\\Program Files\\Precisely\\Datasets\\Current" );
   GsPropSetStr( &initProps, GS_INIT_Z4FILE, "C:\\Program Files\\Precisely\\Datasets\\Current\\us.z9" );
   GsPropSetLong( &initProps, GS_INIT_PASSWORD, 12345678 );
   GsPropSetLong( &initProps, GS_INIT_CACHESIZE, 2 );
   GsPropSetStr( &initProps, GS_INIT_LICFILENAME, "C:\\Program Files\\Precisely\\Geolib\\Geostan.lic" );
   GsPropListWrite( &initProps, "stdout", NULL, 0 );
   GsPropListCreate( &statusProps, GS_STATUS_PROP_LIST_TYPE );
/* initialize GeoStan */
   gs = GsInitWithProps( &initProps, &statusProps );
   GsPropListWrite( &statusProps, "stdout", 0, 0 );
   while ( GsErrorHas(gs) )
    {
     GsErrorGetEx (gs, buffer, buffer2);
     printf ("%s\n%s\n", buffer, buffer2);
    }
   if ( gs == 0 )
    {
     printf( "GeoStan failed to initialize.\n" ); 
     exit(1);
    }
// Verify DPV loaded correctly
   retcode = GsPropGetBool( &statusProps, GS_STATUS_DPV_FILE_SECURITY, &bVal );
   if ( GS_SUCCESS == retcode )
    {
     if ( !bVal )
      {
       printf( "DPV security key failed to verify.\n" );
      }
     else if ( GS_SUCCESS == GsPropGetBool(&statusProps, GS_STATUS_DPV_FILE_ALL, &bVal))
      {
       if ( !bVal )
       printf( "DPV data failed to initialize.\n" );
      }
    }
   retcode = GsPropGetBool( &statusProps, GS_STATUS_LACSLINK_FILE_SECUR, &bVal );
   if ( GS_SUCCESS == retcode )
    {
     if ( !bVal )
      {
       printf( "LACSLink security key failed to verify.\n" );
      }
     else if ( GS_SUCCESS == GsPropGetBool(&statusProps, GS_STATUS_LACSLINK_FILE_ALL, &bVal) )
      {
       if ( !bVal )
       printf( "LACSLink data failed to initialize.\n" );
      }
    }
   retcode = GsPropGetBool( &statusProps, GS_STATUS_SUITELINK_FILE_ALL, &bVal );
   if ( GS_SUCCESS == retcode )
    {
     if ( !bVal )
     printf( "SuiteLink data failed to initialize.\n" );
    }
   GsPropListCreate( &findProps, GS_FIND_PROP_LIST_TYPE );
   GsPropSetBool( &findProps, GS_FIND_ADDRCODE, TRUE );
   GsPropSetBool( &findProps, GS_FIND_Z9_CODE, TRUE );
   GsPropSetBool( &findProps, GS_FIND_FINANCE_SEARCH, TRUE );
   GsPropSetLong( &findProps, GS_FIND_MATCH_MODE, GS_MODE_CASS );

   GsClear( gs );
   GsDataSet( gs, GS_FIRM_NAME, "DIXIES DAISYS FLOWER SERVICE");
   GsDataSet( gs, GS_ADDRLINE, "74203 PERRANIA");
   GsDataSet( gs, GS_LASTLINE, "GRANT CO 80448");
   retcode = GsFindWithProps( gs, &findProps );
      
   GsPropListWrite( &findProps, "stdout", 0, 0 );
   while ( GsErrorHas(gs) )
    {
     GsErrorGetEx (gs, buffer, buffer2);
     printf ("%s\n%s\n", buffer, buffer2);
    }
   GsDataGet(gs, GS_OUTPUT, GS_DPV_FALSE_POS, buffer, sizeof(buffer));
   if ( *buffer == 'Y' )
    {
/* A DPV false positive occurred. Write a false positive report. */
     DPVfalsPosOut = fopen("DPVfalsePos.rpt", "w");
     if ( DPVfalsPosOut )
      {
/* Get the false positive header data */
       memset(&FPheaderData, 0, sizeof(FPheaderData));
       strcpy(FPheaderData.MailersCompanyName, mailerName);
       strcpy(FPheaderData.MailersAddressLine, mailerAddress);
       strcpy(FPheaderData.MailersCityName, mailerCity);
       strcpy(FPheaderData.MailersStateName, mailerState);
       strcpy(FPheaderData.Mailers9DigitZip, mailerZip);
       GsDpvGetFalsePosHeaderStats(gs, &FPheaderData, sizeof(FPheaderData));
/* Format the false positive header data */
       retcode = GsFormatDpvFalsePosHeader( gs,&FPheaderData, sizeof(FPheaderData), buffer, sizeof(buffer) );
/* Write the header to the false positive file */
       if (retcode == GS_SUCCESS)
        {
         fprintf( DPVfalsPosOut,"%s\n", buffer );
        }
       else
        {
         GsErrorGetEx(gs, buffer, buffer2);
         printf( "Error calling GsFormatDpvFalsePosHeader:" "\n%s\n%s\n", buffer, buffer2 );
        }
/* Get the false positive detail data */
       retcode = GsDpvGetFalsePosDetail(gs, &FPdetailData, sizeof(FPdetailData));
       if (retcode != GS_SUCCESS)
        {
         GsErrorGetEx(gs, buffer, buffer2);
         printf( "Error calling GsDpvGetFalsePosDetail:" "\n%s\n%s\n", buffer, buffer2);
        }
/* Format the false positive detail data */
       retcode = GsFormatDpvFalsePosDetail(gs, &FPdetailData, sizeof(FPdetailData), buffer, sizeof(buffer));
/* Write the detail to the false positive file */
       if (retcode == GS_SUCCESS)
        {
         fprintf( DPVfalsPosOut,"%s\n", buffer );
        }
       else
        {
         GsErrorGetEx(gs, buffer, buffer2);
         printf( "Error calling GsFormatDpvFalsePosDetail:" "\n%s\n%s\n", buffer, buffer2);
        }
       fclose(DPVfalsPosOut);
      }
     else
      {
       printf("Failed to open DPV false positive file " "(errno =%d).\n", errno);
      }
    }

   GsClear( gs );
   GsDataSet( gs, GS_ADDRLINE, "RR 1 BOX 6300"); GsDataSet( gs, GS_LASTLINE, "MOUNT SIDNEY VA 24467");
   retcode = GsFindWithProps( gs, &findProps );

   GsDataGet(gs, GS_OUTPUT, GS_LACSLINK_IND, buffer, sizeof(buffer));
   if (*buffer == 'F')
    {
/* A LACSLink false positive occurred. Write a false positive report */
     LACSfalsPosOut = fopen("LACSfalsePos.rpt", "w");
     if ( LACSfalsPosOut )
      {
/* Get the false positive header data */
       memset(&FPheaderData, 0, sizeof(FPheaderData));
       strcpy(FPheaderData.MailersCompanyName, mailerName);
       strcpy(FPheaderData.MailersAddressLine, mailerAddress);
       strcpy(FPheaderData.MailersCityName, mailerCity);
       strcpy(FPheaderData.MailersStateName, mailerState);
       strcpy(FPheaderData.Mailers9DigitZip, mailerZip);
       GsLACSGetFalsePosHeaderStats(gs, &FPheaderData, sizeof(FPheaderData));
/* Format the false positive header data */
       retcode = GsFormatLACSFalsePosHeader(gs, &FPheaderData, sizeof(FPheaderData), buffer, sizeof(buffer));
/* Write the header to the false positive file */
       if (retcode == GS_SUCCESS)
        {
         fprintf( LACSfalsPosOut,"%s\n", buffer );
        }
       else
        {
         GsErrorGetEx(gs, buffer, buffer2);
         printf("Error calling GsFormatLACSFalsePosHeader:" "\n%s\n%s\n", buffer, buffer2);
        }
/* Get the false positive detail data */
       retcode = GsLACSGetFalsePosDetail(gs, &FPdetailData, sizeof(FPdetailData));
       if (retcode != GS_SUCCESS)
       {
       GsErrorGetEx(gs, buffer, buffer2); printf("Error calling GsLACSGetFalsePosDetail:""\n%s\n%s\n", buffer, buffer2);
       }
/* Format the false positive detail data */
       retcode = GsFormatLACSFalsePosDetail(gs, &FPdetailData, sizeof(FPdetailData), buffer, sizeof(buffer));
/* Write the detail to the false positive file */
       if (retcode == GS_SUCCESS)
        {
         fprintf( LACSfalsPosOut,"%s\n", buffer );
        }
       else
        {
         GsErrorGetEx(gs, buffer, buffer2);
         printf("Error calling GsFormatDpvFalsePosDetail:" "\n%s\n%s\n", buffer, buffer2);
        }
       fclose(LACSfalsPosOut);
      }
     else
      {
       printf("Failed to open LACSLink false positive file" " (errno =%d).\n", errno);
      }
    }
   GsTerm( gs );
   GsPropListDestroy( &findProps );
   GsPropListDestroy( &initProps );
   GsPropListDestroy( &statusProps );
   return 0;
}