com.mizar.addressing.geocode
Class Geocoder

java.lang.Object
  extended by com.mizar.addressing.geocode.Geocoder

public class Geocoder
extends java.lang.Object


Nested Class Summary
static class Geocoder.LocationType
           
static class Geocoder.Status
           
 
Field Summary
static java.lang.String INTERSECTION_PATTERN
           
 
Constructor Summary
Geocoder()
           
 
Method Summary
 oracle.spatial.geometry.JGeometry fromAddress(javax.persistence.EntityManager em, java.lang.String address)
          This method search for sites, streets, or intersections for a given address.
 oracle.spatial.geometry.JGeometry fromIntersection(javax.persistence.EntityManager em, java.lang.String[] addresses)
          This method is similar to fromIntersection(EntityManager, String, String).
 oracle.spatial.geometry.JGeometry fromIntersection(javax.persistence.EntityManager em, java.lang.String address1, java.lang.String address2)
          This method search and set list of intersections of two addresses.
 double getDistanceAlong(Street street, java.lang.Long address)
          The method returns an address's prorated distance along the given street.
 double getDistanceAlong(Street street, java.lang.String address)
          The method returns an address's prorated distance along the given street.
 oracle.spatial.geometry.JGeometry getGeom()
           
 java.util.List<oracle.spatial.geometry.JGeometry> getGeoms()
           
 Geocoder.LocationType getLocationType()
           
 int getMaximumListSize()
           
 int getNumberedStreetMode()
           
 oracle.spatial.geometry.JGeometry getPointAlong(Street street)
          This method returns the address's JGeometry Point along a given Street.
 double getRelativeDistanceAlong(Street street, java.lang.Long address)
          The method returns 0 or 1 if the address is outside the range of the street addresses
 double getRelativeDistanceAlong(Street street, java.lang.String address)
          The method returns 0 or 1 if the address is outside the range of the street addresses
 double getSearchTolerance()
           
 java.lang.Class getSiteClass()
           
 java.util.List<Site> getSites()
           
 Geocoder.Status getStatus()
           
 USAddressStreet getStreetAddress()
           
 java.lang.Class getStreetClass()
           
 java.util.List<java.util.List<Street>> getStreetIntersections()
           
 java.util.List<Street> getStreets()
           
 boolean isTruncated()
           
static boolean looksLikeIntersection(java.lang.String testString)
          If the testString contains one and only one of the regex pattern "( at | and |&|\\+|-|/)" and both parts of the pattern contain something and at least one side contains something that looks like a street name and street type or street number then this method will return true.
static boolean looksLikeStreet(java.lang.String testString)
           
 void setGeom(oracle.spatial.geometry.JGeometry geom)
           
 void setLocationType(Geocoder.LocationType locationType)
           
 void setMaximumListSize(int maximumListSize)
           
 void setNumberedStreetMode(int numberedStreetMode)
           
 void setSearchTolerance(double tolerance)
           
 void setSiteClass(java.lang.Class siteClass)
           
 void setSites(java.util.List<Site> sites)
           
 void setStatus(Geocoder.Status status)
           
 void setStreetClass(java.lang.Class streetClass)
           
 void setStreetIntersections(java.util.List<java.util.List<Street>> streetIntersections)
           
 void setStreets(java.util.List<Street> streets)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERSECTION_PATTERN

public static final java.lang.String INTERSECTION_PATTERN
See Also:
Constant Field Values
Constructor Detail

Geocoder

public Geocoder()
Method Detail

looksLikeIntersection

public static boolean looksLikeIntersection(java.lang.String testString)
If the testString contains one and only one of the regex pattern "( at | and |&|\\+|-|/)" and both parts of the pattern contain something and at least one side contains something that looks like a street name and street type or street number then this method will return true.

Parameters:
testString -
Returns:
true if testString looks like an intersection

looksLikeStreet

public static boolean looksLikeStreet(java.lang.String testString)
Parameters:
testString -
Returns:
true if testString contains a name and either a U.S.P.S. street type or address number.

fromAddress

public oracle.spatial.geometry.JGeometry fromAddress(javax.persistence.EntityManager em,
                                                     java.lang.String address)
                                              throws USAddressException,
                                                     GeometryException
This method search for sites, streets, or intersections for a given address.

Parameters:
em - JPA EntityManager
address - String
Returns:
JGeometry object. Only the first matching site, street, or intersection is returned if more than one is found.
Throws:
USAddressException
GeometryException

getPointAlong

public oracle.spatial.geometry.JGeometry getPointAlong(Street street)
                                                throws GeometryException
This method returns the address's JGeometry Point along a given Street. TODO Need to add how it handle street segment that don't contain address.

Parameters:
street - object
Returns:
JGeometry Point object
Throws:
GeometryException

getRelativeDistanceAlong

public double getRelativeDistanceAlong(Street street,
                                       java.lang.String address)
The method returns 0 or 1 if the address is outside the range of the street addresses

Parameters:
street - a Street with valid left and right to and from addresses
address - an address that falls between the minimum and maximum values of street address range
Returns:
a value between 0.0d and 1.0d
See Also:
MathUtils.getLongPart(String)

getRelativeDistanceAlong

public double getRelativeDistanceAlong(Street street,
                                       java.lang.Long address)
The method returns 0 or 1 if the address is outside the range of the street addresses

Parameters:
street - a Street with valid left and right to and from addresses
address - an address that falls between the minimum and maximum values of street address range
Returns:
a value between 0.0d and 1.0d

getDistanceAlong

public double getDistanceAlong(Street street,
                               java.lang.String address)
The method returns an address's prorated distance along the given street. Returns 0 if Street length is 0 or address less than street's min address. Returns Street's length if address more than street's max address. Returns Street's middle address if given address String is empty.

Parameters:
street - a valid Street object
address - String
Returns:
address's prorated distance along given street

getDistanceAlong

public double getDistanceAlong(Street street,
                               java.lang.Long address)
The method returns an address's prorated distance along the given street. Returns 0 if Street length is 0 or address less than street's min address. Returns street's length if address more than street's max address.

Parameters:
street -
address -
Returns:
address's prorated distance along given street

fromIntersection

public oracle.spatial.geometry.JGeometry fromIntersection(javax.persistence.EntityManager em,
                                                          java.lang.String address1,
                                                          java.lang.String address2)
                                                   throws USAddressException,
                                                          GeometryException
This method search and set list of intersections of two addresses. Returns JGeometry of last matching intersection or null if no intersections are found.

Parameters:
em -
address1 -
address2 -
Returns:
JGeometry of Intersection
Throws:
USAddressException
GeometryException

fromIntersection

public oracle.spatial.geometry.JGeometry fromIntersection(javax.persistence.EntityManager em,
                                                          java.lang.String[] addresses)
                                                   throws USAddressException,
                                                          GeometryException
This method is similar to fromIntersection(EntityManager, String, String). It will only process first two element of addresses in String[].

Parameters:
em -
addresses -
Returns:
JGeometry of intersection. Null if no intersections found.
Throws:
USAddressException
GeometryException

setStreetClass

public void setStreetClass(java.lang.Class streetClass)

getStreetClass

public java.lang.Class getStreetClass()

setSiteClass

public void setSiteClass(java.lang.Class siteClass)

getSiteClass

public java.lang.Class getSiteClass()

setStatus

public void setStatus(Geocoder.Status status)

getStatus

public Geocoder.Status getStatus()

setLocationType

public void setLocationType(Geocoder.LocationType locationType)

getLocationType

public Geocoder.LocationType getLocationType()

setSites

public void setSites(java.util.List<Site> sites)

getSites

public java.util.List<Site> getSites()

setStreets

public void setStreets(java.util.List<Street> streets)

getStreets

public java.util.List<Street> getStreets()

setGeom

public void setGeom(oracle.spatial.geometry.JGeometry geom)

getGeom

public oracle.spatial.geometry.JGeometry getGeom()

getGeoms

public java.util.List<oracle.spatial.geometry.JGeometry> getGeoms()

getStreetAddress

public USAddressStreet getStreetAddress()

setMaximumListSize

public void setMaximumListSize(int maximumListSize)

getMaximumListSize

public int getMaximumListSize()

isTruncated

public boolean isTruncated()

setNumberedStreetMode

public void setNumberedStreetMode(int numberedStreetMode)

getNumberedStreetMode

public int getNumberedStreetMode()

setStreetIntersections

public void setStreetIntersections(java.util.List<java.util.List<Street>> streetIntersections)

getStreetIntersections

public java.util.List<java.util.List<Street>> getStreetIntersections()

setSearchTolerance

public void setSearchTolerance(double tolerance)

getSearchTolerance

public double getSearchTolerance()