Code example - 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 example searches ZIP Code 80301 for all streets beginning with "A." Note how you can convert a street or segment handle to a range handle for use with GsHandleGet to return Street or Segment information.

/* This example searches ZIP Code 80301 for streets beginning
 with "A" and no specific house number. */

char             tempstr[60];
GsStreetHandle   hStreet;
GsSegmentHandle  hSegment;
GsRangeHandle    hRange;

/* Use GsFindFirstStreet to get the first street handle that matches the criteria. */
int iStat = GsFindFirstStreet( gs, &hStreet, GS_ZIP_SEARCH, "80301", "A", "" );
while( iStat == GS_SUCCESS )
{
/* We got a valid street handle which we convert to a range handle so that we can use GsHandleGet retrieve 
information to show the user. Even though we converted to a range handle, it really is still just a street 
handle, so we can only access those elements that are valid at the street level. See 'Deprecated Functions' 
section for a complete list of valid elements for each handle type. */
hSegment.hStreet = hStreet;
hRange.hSegment = hSegment;
GsHandleGet( gs, GS_PREDIR, &hRange, tempstr, sizeof(tempstr) );
printf( "Street: %s ", tempstr );
GsHandleGet( gs, GS_NAME, &hRange, tempstr, sizeof(tempstr) );
printf( "%s ", tempstr );
GsHandleGet( gs, GS_TYPE, &hRange, tempstr, sizeof(tempstr) );
printf( "%s ", tempstr );
GsHandleGet( gs, GS_POSTDIR, &hRange, tempstr, sizeof(tempstr) );
printf( "%s\n", tempstr );

/* Find the first valid segment for the current street. */
iStat = GsFindFirstSegment( gs, &hSegment );
while( iStat == GS_SUCCESS )
{
/* We've got a valid segment, convert to a range handle to get information to display. */
hRange.hSegment = hSegment;
printf( "   Segment: " );
GsHandleGet( gs, GS_BLOCK_LEFT, &hRange, tempstr, sizeof(tempstr) );
   printf( "%s ", tempstr );
GsHandleGet( gs, GS_BLOCK_RIGHT, &hRange, tempstr, sizeof(tempstr) );
   printf( "%s ", tempstr );
GsHandleGet( gs, GS_SEGMENT_PARITY, &hRange, tempstr, sizeof(tempstr) );
printf( "%s ", tempstr );
GsHandleGet( gs, GS_SEGMENT_DIRECTION, &hRange, tempstr, sizeof(tempstr) );
printf( "%s \n", tempstr );

/* Get the first valid range for the current segment. */
iStat = GsFindFirstRange( gs, &hRange );
while( iStat == GS_SUCCESS )
   {
   GsHandleGet( gs, GS_LORANGE, &hRange, tempstr, sizeof(tempstr) );
   printf( "      Range: %s ", tempstr );
   GsHandleGet( gs, GS_HIRANGE, &hRange, tempstr, sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_BLOCK_LEFT, &hRange, tempstr,sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_PREDIR, &hRange, tempstr,sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_NAME, &hRange, tempstr,sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_TYPE, &hRange, tempstr, sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_POSTDIR, &hRange, tempstr, sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_ZIP, &hRange, tempstr, sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_LOUNIT, &hRange, tempstr,sizeof(tempstr) );
   printf( "%s ", tempstr );
   GsHandleGet( gs, GS_HIUNIT, &hRange, tempstr,   sizeof(tempstr) );
   printf( "%s\n", tempstr );

   /* Get the next valid range for this segment.*/
   iStat = GsFindNextRange( gs, &hRange );
   }
if ( iStat == GS_ERROR ) break;

/* Get the next valid segment for this street. */
iStat = GsFindNextSegment( gs, &hSegment );
}
if ( iStat == GS_ERROR ) break;

/* Get the next street that meets the initial criteria. */
iStat = GsFindNextStreet( gs, &hStreet );
}