uk.me.parabola.mkgmap.build
Class MapArea

java.lang.Object
  extended by uk.me.parabola.mkgmap.build.MapArea
All Implemented Interfaces:
MapDataSource

public class MapArea
extends java.lang.Object
implements MapDataSource

A sub area of the map. We have to divide the map up into areas to meet the format of the Garmin map. This class holds all the map elements that belong to a particular area and provides a way of splitting areas into smaller ones. It also acts as a map data source so that we can derive lower level areas from it.

Author:
Steve Ratcliffe

Field Summary
static int LINE_KIND
           
static int NUM_KINDS
           
static int POINT_KIND
           
static int SHAPE_KIND
           
static int XT_LINE_KIND
           
static int XT_POINT_KIND
           
static int XT_SHAPE_KIND
           
 
Constructor Summary
MapArea(MapDataSource src, int resolution)
          Create a map area from the given map data source.
 
Method Summary
 Area getBounds()
          Get the initial bounds of this area.
 int[] getEstimatedSizes()
          Get an estimate of the size of the RGN space that will be required to hold the elements
 Area getFullBounds()
          Get the full bounds of this area.
 java.util.List<MapLine> getLines()
          Get a list of all the lines.
 int getNumLines()
          Return number of lines in this area.
 int getNumPoints()
          Return number of points in this area.
 int getNumShapes()
          Return number of shapes in this area.
 java.util.List<Overview> getOverviews()
          This is not used for areas.
 java.util.List<MapPoint> getPoints()
          Get a list of all the points.
 RoadNetwork getRoadNetwork()
          Get the high level view of the road network.
 java.util.List<MapShape> getShapes()
          Get a list of all the shapes.
 boolean hasIndPoints()
          True if there are active indexed points in the area.
 boolean hasLines()
          True if there are any 'active' points in this area.
 boolean hasPoints()
          True if there are any 'active' points in this area.
 boolean hasShapes()
          True if there are any 'active' points in this area.
 MapArea[] split(int nx, int ny, int resolution)
          Split this area into several pieces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POINT_KIND

public static final int POINT_KIND
See Also:
Constant Field Values

LINE_KIND

public static final int LINE_KIND
See Also:
Constant Field Values

SHAPE_KIND

public static final int SHAPE_KIND
See Also:
Constant Field Values

XT_POINT_KIND

public static final int XT_POINT_KIND
See Also:
Constant Field Values

XT_LINE_KIND

public static final int XT_LINE_KIND
See Also:
Constant Field Values

XT_SHAPE_KIND

public static final int XT_SHAPE_KIND
See Also:
Constant Field Values

NUM_KINDS

public static final int NUM_KINDS
See Also:
Constant Field Values
Constructor Detail

MapArea

public MapArea(MapDataSource src,
               int resolution)
Create a map area from the given map data source. This map area will have the same bounds as the map data source and will contain all the same map elements.

Parameters:
src - The map data source to initialise this area with.
resolution - The resolution of this area.
Method Detail

split

public MapArea[] split(int nx,
                       int ny,
                       int resolution)
Split this area into several pieces. All the map elements are reallocated to the appropriate subarea. Usually this instance would now be thrown away and the new sub areas used instead.

Parameters:
nx - The number of pieces in the x (longitude) direction.
ny - The number of pieces in the y direction.
resolution - The resolution of the level.
Returns:
An array of the new MapArea's.

getFullBounds

public Area getFullBounds()
Get the full bounds of this area. As lines and polylines are added then may go outside of the initial area. Whe this happens we need to increase the size of the area.

Returns:
The full size required to hold all the included elements.

getEstimatedSizes

public int[] getEstimatedSizes()
Get an estimate of the size of the RGN space that will be required to hold the elements

Returns:
Estimates of the max size that will be needed in the RGN file for the points/lines/shapes in this sub-division.

getBounds

public Area getBounds()
Get the initial bounds of this area. That is the initial bounds before anything was added.

Specified by:
getBounds in interface MapDataSource
Returns:
The initial bounds as when it was created.
See Also:
getFullBounds()

getPoints

public java.util.List<MapPoint> getPoints()
Get a list of all the points.

Specified by:
getPoints in interface MapDataSource
Returns:
The points.

getLines

public java.util.List<MapLine> getLines()
Get a list of all the lines.

Specified by:
getLines in interface MapDataSource
Returns:
The lines.

getShapes

public java.util.List<MapShape> getShapes()
Get a list of all the shapes.

Specified by:
getShapes in interface MapDataSource
Returns:
The shapes.

getRoadNetwork

public RoadNetwork getRoadNetwork()
Description copied from interface: MapDataSource
Get the high level view of the road network. This is used to write the net and nod sections. Note that information from the net section is needed to write the RGN section if routing is wanted.

Specified by:
getRoadNetwork in interface MapDataSource
Returns:
A RoadNetwork object with all the connections between roads. If this returns null, then the NET and NOD sections should not be written.

getOverviews

public java.util.List<Overview> getOverviews()
This is not used for areas.

Specified by:
getOverviews in interface MapDataSource
Returns:
Always returns null.

hasPoints

public boolean hasPoints()
True if there are any 'active' points in this area. Ie ones that will be shown because their resolution is at least as high as that of the area.

Returns:
True if any active points in this area.

hasIndPoints

public boolean hasIndPoints()
True if there are active indexed points in the area.

Returns:
True if any active indexed points in the area.

hasLines

public boolean hasLines()
True if there are any 'active' points in this area. Ie ones that will be shown because their resolution is at least as high as that of the area.

Returns:
True if any active points in this area.

getNumLines

public int getNumLines()
Return number of lines in this area.


getNumShapes

public int getNumShapes()
Return number of shapes in this area.


getNumPoints

public int getNumPoints()
Return number of points in this area.


hasShapes

public boolean hasShapes()
True if there are any 'active' points in this area. Ie ones that will be shown because their resolution is at least as high as that of the area.

Returns:
True if any active points in this area.