Several functions are included in PC*MILER Rail-Connect that support looking up places and railroads.


HRESULT PCRSGeoLookup(Trip trip, char *geoName, char *geoChar, char *rrIn, int *numMatches)


PCRSGeoLookup() finds a list of matching places and returns how many match your input. You can then check each item in the list yourself for a matching name, or pop up the list in your own list box. Input names can contain the meta-character ‘*’ to force the server to do partial matches. For example, ‘HOU* TX’ will return a list of all places that match the partial string ‘HOU’ in the state of Texas.  The railroad (rrIn) is an optional field to allow users to further narrow the search to stations on that specific rail carrier. The DLL will ignore this field if it is NULL.


Input names can be any of the geocode types (station name/state, SPLC, FSAC, ERPC, Rule260). The argument geoChar denotes which of these types is being given (S=SPLC, E=ERPC, C=City/State (station name), F=FSAC, R=Rule260). The number of matches found is returned in the given pointer numMatches. Note that these input places can be ‘mapped’ to other places in the PC*MILER Rail network via overrides, should this be necessary based on the input data.



HRESULT PCRSGetGeoMatch(Trip trip, int which, char *buffer, int bufSize,int *pNumChars)

HRESULT PCRSGetNumGeoMatches(Trip trip, int *numMatches)


Once you’ve seeded the trip with matching cities, use PCRSGetGeoMatch() to retrieve each matching place. Pass the index of the desired match and a buffer to store the information in. The name stored in the buffer (first 22 chars) is the place name as PC*MILER Rail knows it and should be the name passed to PCRSAddStop()


PC*MILER Rail names are the 22-character station/state names, including the NULL terminator. Note that the buffer should be long enough to contain the entire name. Additional information will be included in the buffer (such as SPLC and FSAC) where possible.


The following is a code sample for Geocode lookups:


#define BUFLEN 25
char buffer[BUFLEN];
int matches, numChars;
HRESULT srvRet;

/* Lookup all cities that match */

srvRet = PCRSGeoLookup(myTrip, "HOU* TX", "C", NULL, &matches);
printf ("%d matching cities to 'HOU* TX'\n", matches);

/* Show all the matching cities. Note: You could use variable*/

for (i = 0; i < matches; i++)
{
  PCRSGetGeoMatch(trip, i, buffer, BUFLEN, &numChars);
  printf ("[%s]\n", buffer);
}



HRESULT PCRSRRLookup(Trip trip, char *geoName, char *geoChar, int *numMatches)

HRESULT PCRSJunctionLookup(Trip tripID, char *rrin, char *rrOut, int *numMatches)

HRESULT PCRSGetRRMatch(Trip trip, int which, char *buffer, int bufSize, int *pNumChars)

HRESULT PCRSGetJunctionMatch(Trip tripID, int which, char *buffer, int bufSize, int *pNumChars)


The Lookup functions work like the Geocoding functions described above. PCRSRRLookup()and PCRSJunctionLookup() return lists of matching railroads and junctions respectively, and return how many match your input. The number of matches found is returned in the given pointer numMatches. Then, you can use PCRSGetRRMatch() or PCRSGetJunctionMatch() to retrieve each matching railroad or junction. Pass the index of the desired match and a buffer to store the information.



HRESULT PCRSConvertGeoCode(char *geoName, char *geoCharFrom, char *geoCharTo, char *rr, char *buffer, int bufsize, int *pNumChars)


PCRSConvertGeoCode() is a geocode conversion function.  The argument geoCharFrom and geoCharTo are one of the following: (S=SPLC, E=ERPC, C=City/State (station name), F=FSAC, R=Rule260).


The following is a code sample of PCRSConvertGeoCode().  Note that RR information is required to and from the FSAC code conversion.


#define BUFLEN 256
char buffer[BUFLEN];
if (0 == (srvRet = PCRSConvertGeoCode("384188", "S", "C", "", buffer, BUFLEN, NULL)))
{
   printf (buf, "Conversion: \"384188\" (SPLC --> Station/ST)\n");
   printf (buf, "Result: %s\n", buffer);
}

/* ERPC code needs to be followed by state code with or without a blank */
if (0 == (srvRet = PCRSConvertGeoCode("GRUMBLER NT", "E", "C", "", buffer, BUFLEN, NULL)))
{
   printf (buf, "Conversion: \"GRUMBLER NT\" (ERPC --> Station/ST)\n");
   printf (buf, "   Result : %s\n", buffer);
}

/* RR is required to and from the FSAC code conversion */
if (0 == (srvRet = PCRSConvertGeoCode("ABEE IN", "C", "F", "EVWR", buffer, BUFLEN, NULL)))
{
   printf (buf, "Conversion: \"ABEE IN\" (Station/ST --> FSAC, RR: EVWR)\n");
   printf (buf, "Result: %s\n", buffer);
}

if (0 == (srvRet = PCRSConvertGeoCode("ADA", "R", "S", "", buffer, BUFLEN, NULL)))
{
   printf (buf, "Conversion: \"ADA\" (R260 --> SPLC)\n");
   printf (buf, "Result: %s\n", buffer);
}


The output from this program is:


Conversion: "384188" (SPLC --> Station/ST)
Result: LORENZO             IL
Conversion: "GRUMBLER NT" (ERPC --> Station/ST)
Result: GRUMBLER            NT
Conversion: "ABEE IN" (Station/ST --> FSAC, RR: EVWR)
Result: 70328
Conversion: "ADA" (R260 --> SPLC)
Result: 628240