ps4
Class StreetSegment

java.lang.Object
  extended by GeoSegment
      extended by ps4.StreetSegment

public class StreetSegment
extends GeoSegment

Class overview to be written by student.


Constructor Summary
StreetSegment(GeoPoint p1, GeoPoint p2, String name, StreetNumberSet leftNumbers, StreetNumberSet rightNumbers, String leftZip, String rightZip, StreetClassification streetClass, boolean increasingAddresses)
          Creates a new StreetSegment from the given arguments.
 
Method Summary
 double fractionDist(int sn)
          This method assumes that the locations corresponding to street numbers on this street are spaced evenly apart (regardless of the arithmetic difference between two consecutive street numbers).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreetSegment

public StreetSegment(GeoPoint p1,
                     GeoPoint p2,
                     String name,
                     StreetNumberSet leftNumbers,
                     StreetNumberSet rightNumbers,
                     String leftZip,
                     String rightZip,
                     StreetClassification streetClass,
                     boolean increasingAddresses)
Creates a new StreetSegment from the given arguments.

Parameters:
p1 - one end of the StreetSegment
p2 - the other end of the StreetSegment
name - the name of the street of which this is a segment
leftNumbers - street numbers on the left side of the street
rightNumbers - street numbers on the right side of the street
leftZip - ZIP code on the left side of the street
rightZip - ZIP code on the right side of the street
streetClass - StreetClassification of this StreetSegment
increasingAddresses - true if addresses increase from p1 to p2

The left and right sides of the street are as viewed from p1 to p2.

Requires:
leftNumbers does not share any numbers with rightNumbers unless leftZip != rightZip; all arguments are non-null; leftZip and rightZip are valid zipcodes, where a valid zipcode is any 5-digit String or the empty String.
Method Detail

fractionDist

public double fractionDist(int sn)
This method assumes that the locations corresponding to street numbers on this street are spaced evenly apart (regardless of the arithmetic difference between two consecutive street numbers). It returns the fraction of the distance that the street number sn is from p1. The return value is a number from 0 to 1, exclusive.

For instance, if one side of this street contains the street numbers 1, 3, and 99, and this.increasingAddresses is true, then those numbers appear .25, .5, and .75 of the way along the street. If this.increasingAddresses is false, then the numbers appear .75, .5, and .25 of the way along the street.

If both sides of the street have the number sn (which can happen only if the two sides have different Zip codes), then this selects the address on the right-hand side of the street (as viewed from p1).

Returns:
the fraction of the length of this segment that is from p1 to the address sn
Requires:
this instance of StreetSegment must contain the street number sn