GsSetSelection - 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

Allows you to select a match from a set of match candidates.

Syntax

GsFunStat GsSetSelection(GsId gs, ints index);

Arguments

GsIdgs   ID returned by GsInitWithProps() for the current instance of GeoStan. Input.

intsindex   Index number (0-based) of the possible match. Input.

Return Values

GS_SUCCESS

GS_ERROR   Selection is out of range.

Prerequisites

GsMultipleGet()

Notes

After GsFindWithProps() returns GS_ADDRESS_NOT_RESOLVED, use GsNumMulitple() and GsMultipleGet() to determine which possible match is the correct match. Then use GsSetSelection() to load that possible match into the data retrieval buffers and retrieve it using GsDataGet().

Note: GsSetSelection() and GsSetSelectionRange() functions should only be called once per address find (i.e. GsFindWithProps). Also, these functions should only be called if the find resulted in a match candidate (match code = E023).

Example

/* This example prints information about possible matches. It assumes that GsFind 
returned GS_ADDRESS_NOT_RESOLVED. */
                 
char buffer[60];
int bInter;
printf( "Possibles:\n" );
/* Test for match candidate and set bInter to non-zero if true. */
GsMultipleGet( gs, GS_INTERSECTION, 0, buffer,sizeof(buffer) );
bInter = *buffer == 'T';
/* Get the number of multiples and print them as we loop through each one. */
int n = GsNumMultiple( gs );
for ( int i = 0; i < n; ++i )
{
printf( "%d: ", i );
/* If we don't have an intersection, print the ranges. */
if ( !bInter )
{
GsMultipleGet( gs, GS_LORANGE, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
GsMultipleGet( gs, GS_HIRANGE, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
}
/* Print the street name for both intersections and nonintersections. */
GsMultipleGet( gs, GS_PREDIR, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
GsMultipleGet( gs, GS_NAME, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
GsMultipleGet( gs, GS_TYPE, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
GsMultipleGet( gs, GS_POSTDIR, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
/* If an intersection match, print the second street name. */
if ( bInter )
{
printf( " AT " );
GsMultipleGet( gs, GS_PREDIR2, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
GsMultipleGet( gs, GS_NAME2, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
GsMultipleGet( gs, GS_TYPE2, i, buffer, sizeof(buffer) );
printf("%s", buffer );
GsMultipleGet( gs, GS_POSTDIR2, i, buffer, sizeof(buffer) );
printf( "%s ", buffer );
}
/* Print each possible on a new line. */
printf( "(%s)\n", buffer );
}
                                  
int index = 0;
GsFunStat funStat;
printf(" Please enter selection number.");
scanf("%i", &index);
                 
funStat = GsSetSelection(gs, index);
                 
if (funStat == GS_SUCCESS)
{
GsDataGet( gs, GS_OUTPUT, GS_FIRM_NAME, firm, sizeof(firm) );
GsDataGet( gs, GS_OUTPUT, GS_ADDRLINE, address, sizeof(address) );
GsDataGet( gs, GS_OUTPUT, GS_LASTLINE, lastline, sizeof(lastline) );
GsDataGet( gs, GS_OUTPUT, GS_LON, longitude, sizeof(longitude) );
GsDataGet( gs, GS_OUTPUT, GS_LAT, latitude, sizeof(latitude) );
                 
printf( "%s\n"
"%s\n"
"%s\n"
"longitude: %lf\n"
"latitude: %lf\n", firm, address, lastline, /* ascii data */
(double)(atof(longitude)/1000000.0), /* normalize longitude */
(double)(atof(latitude)/1000000.0) ); /* normalize latitude */
}
else
printf("Address information not found.");