RoadFinder (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.tools.roads
Class RoadFinder

    java.lang.Object
      com.bbn.openmap.tools.roads.RoadFinder

All Implemented Interfaces:
  ProjectionListener, RoadLayer, RoadServices, java.util.EventListener

    public class RoadFinder

extends java.lang.Object
implements RoadServices, ProjectionListener, RoadLayer

Gives road access to a shape or vpf layer.

Nested Class Summary
`protected class` | `RoadFinder.BlueLine` a blue line to indicate the found route
`static class` | `RoadFinder.Intersections`
`protected class` | `RoadFinder.RedPoint` a red point for displaying when we can't find a route between two points
`static class` | `RoadFinder.RoadClasses`
`protected class` | `RoadFinder.YellowLine` a yellow line for display routes between intersections
`protected class` | `RoadFinder.YellowPoint` a yellow point for displaying intersections

Field Summary
`protected RoadClass` | `defaultRoadClass`
`protected java.util.Map` | `graphicToRoad`
`protected float` | `halo` how far (in lat-lon space) from lat,lon point to look in quad tree for nearest road *
`protected QuadTree` | `interQuadTree`
`protected RoadFinder.Intersections` | `intersections`
`protected LayerView` | `layer`
`protected java.util.Vector` | `removedRoads`
`protected RoadFinder.RoadClasses` | `roadClasses`
`protected com.bbn.openmap.tools.roads.RoadFinder.RoadVector` | `roads`

Constructor Summary
`RoadFinder(LayerView layer, boolean drawIntersections, boolean drawResults)`

Method Summary
`protected void` | `checkIntegrity()` Check the integrity of our data structures.
`protected LatLonPoint` | `createLatLonPoint(int x, int y)`
`protected java.awt.Point` | `createPoint(java.awt.Point pt)` Allows subclasses to redefine points returned
`Road` | `createRoad(Intersection from)` called from Intersection Implemented for RoadLayer interface
`protected Road` | `createRoad(int id, java.lang.String name, Intersection from, Intersection to, RoadClass cl_ss)`
`protected RoadObject` | `createRoadFromPoints(int id, int[] xpoints, int[] ypoints, int nPoints)` Makes a road object given the points on the shape that are within the visible box
`protected Segment` | `createSegment(java.util.List newPoints)` Allows subclasses to redefine segments
`protected void` | `deleteIntersection(Intersection intersection)`
`void` | `deleteRoad(Road road)`
`java.util.List` | `displayPathOnRoad(java.awt.Point start, java.awt.Point end, Route route, java.util.List segments)` Displays a Route between two points on the map.
`protected Intersection` | `findClosestIntersection(int x, int y)` Look in intersection Quad Tree for closest intersection to point x,y
`protected Intersection` | `findClosestIntersection(LatLonPoint latLon)` Look in intersection Quad Tree for closest intersection to point at specified latitude and longitude.
`protected Intersection` | `findIntersection(int x, int y)`
`protected Intersection` | `findIntersection(LatLonPoint loc)`
`protected Intersection` | `findIntersection(LatLonPoint loc, java.lang.String name)`
`RoadClass` | `findRoadClass(java.lang.Object className)`
`int` | `findUnusedRoadID()`
`protected void` | `getData()` Take the shape data on the layer and use it to populate our roads and intersections.
`Route` | `getPathOnRoad(LatLonPoint start, LatLonPoint end)` Returns best Route between two points specified by latitude and longitude.
`java.util.List` | `getPathOnRoad(java.awt.Point start, java.awt.Point end, java.util.List segments)` Finds closest intersection to start and end find path from start intersection to end intersection
`protected Segment` | `getPathSegment(Projection proj, Road road, boolean reverse)` Converts a road into a path segment - reverse parameter guarantees the ordering of the points is consistent across multiple path segments in the whole route.
`Projection` | `getProjection()`
`protected void` | `getRoads()` Take the shape data on the layer and use it to populate our roads and intersections.
`Route` | `getRouteBetweenPoints(java.awt.Point start, java.awt.Point end)` Returns best Route between two points This method works on latitude/longitude coordinates.
`protected void` | `initRoadClasses()`
`protected java.awt.Point` | `interp(double x1, double y1, double x2, double y2, int width, int height)` find a point between x1,y1 and x2, y2 that is within the visible map
`boolean` | `isEditing()` BOZO remove me
`void` | `joinRoads(Intersection intersection)` Join two roads into one.
`protected void` | `makeRoad(java.awt.Shape shape, OMGeometry graphic, int num, int[] xPoints, int[] yPoints, int segment)` Makes a road object given the points on the shape that are within the visible box Stores it in a quadTree
`protected java.lang.String` | `mergeRoadNames(java.lang.String name0, java.lang.String name1)`
`protected void` | `populatePointsAndSegments(Route bestRoute, java.util.List newPoints, java.util.List segments)` Iterates over route, populating points and segments lists.
`void` | `projectionChanged(ProjectionEvent e)` Implemented for ProtectionListener
`Intersection` | `splitRoad(Road road, RoadPoint rp)` Split a road into two roads at one of its corners.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### roadClasses

    protected RoadFinder.RoadClasses roadClasses

### defaultRoadClass

    protected RoadClass defaultRoadClass

### layer

    protected LayerView layer

### intersections

    protected RoadFinder.Intersections intersections

### roads

    protected com.bbn.openmap.tools.roads.RoadFinder.RoadVector roads

### removedRoads

    protected java.util.Vector removedRoads

### halo

    protected float halo

  how far (in lat-lon space) from lat,lon point to look in quad tree for nearest road *

### interQuadTree

    protected QuadTree interQuadTree

### graphicToRoad

    protected java.util.Map graphicToRoad

Constructor Detail

### RoadFinder

    public RoadFinder(LayerView layer,
                      boolean drawIntersections,
                      boolean drawResults)

Method Detail

### initRoadClasses

    protected void initRoadClasses()

### projectionChanged

    public void projectionChanged(ProjectionEvent e)

  Implemented for ProtectionListener

  Specified by:
    `projectionChanged` in interface `ProjectionListener`
  Parameters:
    `e` - ProjectionEvent

### getData

    protected void getData()
                    throws java.lang.Exception

  Take the shape data on the layer and use it to populate our roads and intersections. Clears lists of roads and intersections first, and after calculating the roads, tells the RoadLayer what extra graphics to display, if any.

  Throws:
    `java.lang.Exception`

### getRoads

    protected void getRoads()
                     throws java.lang.Exception

  Take the shape data on the layer and use it to populate our roads and intersections.

  Throws:
    `java.lang.Exception`

### interp

    protected java.awt.Point interp(double x1,
                                    double y1,
                                    double x2,
                                    double y2,
                                    int width,
                                    int height)

  find a point between x1,y1 and x2, y2 that is within the visible map

  Parameters:
    `width` - of visible map
    `height` - of visible map
  Returns:
    Point between x1,y1 and x2, y2

### makeRoad

    protected void makeRoad(java.awt.Shape shape,
                            OMGeometry graphic,
                            int num,
                            int[] xPoints,
                            int[] yPoints,
                            int segment)

  Makes a road object given the points on the shape that are within the visible box Stores it in a quadTree

### createRoadFromPoints

    protected RoadObject createRoadFromPoints(int id,
                                              int[] xpoints,
                                              int[] ypoints,
                                              int nPoints)

  Makes a road object given the points on the shape that are within the visible box

  Parameters:
    `nPoints` - in the xpoints and ypoints arrays

### createLatLonPoint

    protected LatLonPoint createLatLonPoint(int x,
                                            int y)

### findIntersection

    protected Intersection findIntersection(LatLonPoint loc,
                                            java.lang.String name)

### findIntersection

    protected Intersection findIntersection(int x,
                                            int y)

### findIntersection

    protected Intersection findIntersection(LatLonPoint loc)

### deleteIntersection

    protected void deleteIntersection(Intersection intersection)

### createRoad

    public Road createRoad(Intersection from)

  called from Intersection Implemented for RoadLayer interface

  Specified by:
    `createRoad` in interface `RoadLayer`

### createRoad

    protected Road createRoad(int id,
                              java.lang.String name,
                              Intersection from,
                              Intersection to,
                              RoadClass cl_ss)

### deleteRoad

    public void deleteRoad(Road road)

### splitRoad

    public Intersection splitRoad(Road road,
                                  RoadPoint rp)

  Split a road into two roads at one of its corners. An intersection is created where the corner was and the segments before the corner become the segments of the original road. The segments after the corner become the segments of a new road between the new intersection and the

### joinRoads

    public void joinRoads(Intersection intersection)

  Join two roads into one. The roads must be the only two roads at the intersection and must be of the same class. If the roads are not distinct, then we quietly delete the road and remove the intersection. The roads might not be distinct if they form an isolated loop (such as a racetrack). Thus situation is particularly problematic if the road has no inner points. The RoadPoints of both roads are concatenated with a new RoadPoint where the intersection was between them. This code is a little complicated because the RoadPoints must be assembled in a valid order. The order used is to start from the other intersection of the first road to the given intersection and from the given intersection of the second road to the other intersection of the second road.

### mergeRoadNames

    protected java.lang.String mergeRoadNames(java.lang.String name0,
                                              java.lang.String name1)

### findRoadClass

    public RoadClass findRoadClass(java.lang.Object className)

### findUnusedRoadID

    public int findUnusedRoadID()

### displayPathOnRoad

    public java.util.List displayPathOnRoad(java.awt.Point start,
                                            java.awt.Point end,
                                            Route route,
                                            java.util.List segments)

  Displays a Route between two points on the map.

  Specified by:
    `displayPathOnRoad` in interface `RoadServices`
  Parameters:
    `start` - start from start point on map
    `end` - to end point on map
    `route` - the Route to travel from start to end
    `segments` - as side effect, populated with PathSegments between returned WayPoints
  Returns:
    List of WayPoints

### getPathOnRoad

    public java.util.List getPathOnRoad(java.awt.Point start,
                                        java.awt.Point end,
                                        java.util.List segments)

  Finds closest intersection to start and end find path from start intersection to end intersection

  This method works on screen coordinates.

  Specified by:
    `getPathOnRoad` in interface `RoadServices`
  Parameters:
    `start` - from start point on map
    `end` - to end point on map
    `segments` - as side effect, populated with PathSegments between returned WayPoints
  Returns:
    List of WayPoints

### getPathOnRoad

    public Route getPathOnRoad(LatLonPoint start,
                               LatLonPoint end)

  Returns best Route between two points specified by latitude and longitude.

  This method works on latitude/longitude coordinates.

  Specified by:
    `getPathOnRoad` in interface `RoadServices`
  Parameters:
    `start` - - Start point in latitude/longitude coordinates.
    `end` - - End point in latitude/longitude coordinates.
  Returns:
    Route between two points

### getRouteBetweenPoints

    public Route getRouteBetweenPoints(java.awt.Point start,
                                       java.awt.Point end)

  Returns best Route between two points This method works on latitude/longitude coordinates.

  Returns:
    Route between two points

### findClosestIntersection

    protected Intersection findClosestIntersection(int x,
                                                   int y)

  Look in intersection Quad Tree for closest intersection to point x,y

  Returns:
    Intersection closest

### findClosestIntersection

    protected Intersection findClosestIntersection(LatLonPoint latLon)

  Look in intersection Quad Tree for closest intersection to point at specified latitude and longitude.

  Returns:
    Intersection closest

### populatePointsAndSegments

    protected void populatePointsAndSegments(Route bestRoute,
                                             java.util.List newPoints,
                                             java.util.List segments)

  Iterates over route, populating points and segments lists. Worries about sequence order of from and to points, i.e. end of one road should be the start of the next. This is not guaranteed by the route, so we have to check.

  Parameters:
    `bestRoute` - route to iterate over.
    `newPoints` - populated with points on the route.
    `segments` - populated with Segments.

### getPathSegment

    protected Segment getPathSegment(Projection proj,
                                     Road road,
                                     boolean reverse)

  Converts a road into a path segment - reverse parameter guarantees the ordering of the points is consistent across multiple path segments in the whole route.

  Returns:
    PathSegment converted from a road

### createSegment

    protected Segment createSegment(java.util.List newPoints)

  Allows subclasses to redefine segments

### createPoint

    protected java.awt.Point createPoint(java.awt.Point pt)

  Allows subclasses to redefine points returned

### getProjection

    public Projection getProjection()

  Specified by:
    `getProjection` in interface `RoadLayer`

### checkIntegrity

    protected void checkIntegrity()

  Check the integrity of our data structures. Scan the known intersections. Note intersections with no roads. Scan the roads of the intersection: Each road has two intersections. If the road has already been encountered, then we recorded its "other" intersection and that must match this intersection. If it doesn't match, record an error. If it does match reset its recorded other intersection to be a special marker indicating that both ends of the road have been accounted for. If the road has not already been encountered, then record its "other" intersection. Scan the known roads. Every road should accounted for in the "other" intersection table and should be marked as having both intersections accounted for. Note the roads which were not found in the first scan and the roads which were found, but for which both intersections were not found. Remark every road. Finally scan the other intersection table for entries which were not marked as being in the roads vector.

### isEditing

    public boolean isEditing()

  BOZO remove me

  Specified by:
    `isEditing` in interface `RoadLayer`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details