Purpose: Geocoder is a command-line application that converts street addresses into longitude/latitude pairs.
Some Contextual Information: The following design documents exist:
Definitions:
Linear Interpolation of Two Numbers: Given two numbers, a and b, and an interpolation parameter, m in [0,1], the linear interpolation of a and b is denoted by v and defined as v = (1-m) a + m b.
Linear Interpolation of Two Points: Given two points, a=(ax ,ay ) and b=(bx ,by ), and an interpolation parameter, m in [0,1], the linear interpolation of a and b is denoted by v and defined as v=(vx ,vy ) where vx = (1-m) ax + m bx and as vy = (1-m) ay + m by .
Interpolation Parameter for an Address: Given a low address, L, a high address, H, and an address, A in [L,H], the interpolation parameter for A is defined as m=(A-L)/(H-L).
The data team has created "segment" files that contain the information necessary for geocoding. They have provided the following segment file:
A segment is a portion of a street. For example, "Main Street" might consist of three segments, one from Pine Street to Elm Street, one from Elm Street to Maple Avenue, and one from Maple Avenue to Grant Road.
This file was created from the US Census Bureau's TIGER Boundary Files. It is tab-delimited and contains the following ten fields:
String
)String
)Note that the phrase "low end" refers to the end of the segment with the lowest address and the phrase "high end" refers to the end of the segment with the highest address.
The system must satisfy the following operational requirements:
OR-1 The application must be started from the command line as follows:
whete filename is the name of the geographic area (e.g., jmuarea.txt).(See Needs U-1, U-2)
OR-2 The application must repeatedly prompt the user to enter address information. (See Needs U-3)
OR-3 The application must first prompt the user to enter the street number using the prompt "Number: " (note the space).
OR-4 The application must then prompt the user to enter the street name using the prompt "Street: " (note the space). Note that valid responses may contain spaces (e.g., Buttermilk Spring Rd).
OR-5 If the user enters an invalid street number then the application must use the value 1.
OR-6 The application must terminate when the user enters an end-of-stream character in response to the "Number: " prompt.
OR-7 The application must be able to find the segment (or segments) with the given street name that contains the given street number and use linear interpolation to calculate the longitude/latitude pair (or pairs).
OR-8 The application must then output the interpolated longitude/latitude pair(s). (See Needs U-4)
OR-9 The values in a longitude/latitude pair must be separated by a comma and followed by a newline character. Each value must be formatted using a format string of "%+9.6f".
OR-10 If the application can't find a segment that contains the address, it must output the string literal "Not Found" followed by a newline character.
OR-11 If there are multiple longitude/latitude pairs for a given address, each pair must appear on its own line.
OR-12 If there are multiple longitude/latitude pairs for a given address, the longitude/latitude pairs must be sorted (in ascending order) by segment ID. (See Needs U-5)
Copyright 2011