taxisrus.implementation
Class Mapper

java.lang.Object
  |
  +--taxisrus.implementation.Mapper
All Implemented Interfaces:
MapperInterface

public class Mapper
extends Object
implements MapperInterface


Constructor Summary
Mapper()
          Default constructor, used for testing.
Mapper(DataStoreConnection dataStore)
          Constructor for creating a connection to a database.
Mapper(GPS upper, GPS lower, ArrayList polygonlist)
          Another constructor for testing
 
Method Summary
 GPS address2gps(String convaddress)
          Convert address to GPS coordinate by calling HornerHash() and then hash2GPS() Conversion is repeatable for any given address.
 int address2zone(String convaddress)
          Convert address to zone, via two function calls
 ArrayList createzonelist()
          For unit testing only.
 ArrayList getNeighboringZones(int zoneID)
          Return a list of neighboring zone indices for a given zone index
 int getNumZones()
          Return the number of zones.
 ArrayList getZones()
          Return an address.
 int gps2zone(GPS g)
          Convert GPS to zone, if the GPS coordinate is not in any zone, will return nearest zone.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mapper

public Mapper()
Default constructor, used for testing.

Mapper

public Mapper(DataStoreConnection dataStore)
Constructor for creating a connection to a database.
Parameters:
initialized - DataStoreConnection object

Mapper

public Mapper(GPS upper,
              GPS lower,
              ArrayList polygonlist)
Another constructor for testing
Method Detail

address2gps

public GPS address2gps(String convaddress)
Convert address to GPS coordinate by calling HornerHash() and then hash2GPS() Conversion is repeatable for any given address. GPS coordinate generated is within the rectangle bounded by upperGPSlim and lowerGPSlim
Specified by:
address2gps in interface MapperInterface
Parameters:
address - to be converted
Returns:
gps coordinate

address2zone

public int address2zone(String convaddress)
Convert address to zone, via two function calls
Specified by:
address2zone in interface MapperInterface
Parameters:
String - - Address to be converted
Returns:
int - Zone id

gps2zone

public int gps2zone(GPS g)
Convert GPS to zone, if the GPS coordinate is not in any zone, will return nearest zone.
Specified by:
gps2zone in interface MapperInterface
Parameters:
GPS - to be converted
Returns:
zone

getZones

public ArrayList getZones()
Return an address.
Specified by:
getZones in interface MapperInterface
Returns:
A list of the zones

getNumZones

public int getNumZones()
Return the number of zones.
Specified by:
getNumZones in interface MapperInterface
Returns:
int Number of zones

getNeighboringZones

public ArrayList getNeighboringZones(int zoneID)
Return a list of neighboring zone indices for a given zone index
Specified by:
getNeighboringZones in interface MapperInterface
Parameters:
int - zoneID
Returns:
ArrayList a list of neighboring zone IDs

createzonelist

public ArrayList createzonelist()
For unit testing only. To create two equal area zones for testing. Bounding rectangle is (10, 10) and (-10, -10). The zones are split along the x axis.
Returns:
zonelist with two rectangular zones


API documentation for build 958