uk.me.parabola.imgfmt.app.map
Class Map

java.lang.Object
  extended by uk.me.parabola.imgfmt.app.map.Map
All Implemented Interfaces:
InternalFiles, Configurable

public class Map
extends java.lang.Object
implements InternalFiles, Configurable

Holder for a complete map. A map is made up of several files which include at least the TRE, LBL and RGN files. It is the interface for all information about the whole map, such as the point overviews etc. Subdivision will hold the map elements.

Needless to say, it has nothing to do with java.util.Map and given how it has turned out, with all reading functionality in MapReader it would have been better named MapWriter.

Author:
Steve Ratcliffe

Method Summary
 void addCopyright(java.lang.String str)
          Add a copyright message to the map.
 void addInfo(java.lang.String info)
          There is an area after the TRE header and before its data starts that can be used to save any old junk it seems.
 void addMapObject(MapObject item)
           
protected  void addNet()
           
protected  void addNod()
           
 void addPointOverview(PointOverview ov)
           
 void addPolygonOverview(PolygonOverview ov)
           
 void addPolylineOverview(PolylineOverview ov)
           
 void close()
          Close this map by closing all the constituent files.
 void config(EnhancedProperties props)
          Used to mark that a reader needs to be configured by command line properties.
static Map createMap(java.lang.String mapname, java.lang.String outputdir, FileSystemParam params, java.lang.String mapnumber)
          Create a complete map.
 Subdivision createSubdivision(Subdivision parent, Area area, Zoom zoom)
          Create a subdivision that is beneath the top level.
 Zoom createZoom(int level, int bits)
          Create a new zoom level.
 java.lang.String getFilename()
           
 LBLFile getLblFile()
           
 NETFile getNetFile()
           
 NODFile getNodFile()
           
 RGNFile getRgnFile()
           
 TREFile getTreFile()
           
 void setBounds(Area area)
          Set the area that the map covers.
 void setLabelCharset(java.lang.String desc, boolean forceUpper)
           
 void setLabelCodePage(int cp)
           
 void setPoiDisplayFlags(int flags)
          Set the point of interest flags.
 Subdivision topLevelSubdivision(Area area, Zoom zoom)
          Create the top level division.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createMap

public static Map createMap(java.lang.String mapname,
                            java.lang.String outputdir,
                            FileSystemParam params,
                            java.lang.String mapnumber)
                     throws FileExistsException,
                            FileNotWritableException
Create a complete map. This consists of (at least) three files that all have the same basename and different extensions.

Parameters:
mapname - The name of the map. This is an 8 digit number as a string.
params - Parameters that describe the file system that the map will be created in.
Returns:
A map object that holds together all the files that make it up.
Throws:
FileExistsException - If the file already exists and we do not want to overwrite it.
FileNotWritableException - If the file cannot be opened for write.

config

public void config(EnhancedProperties props)
Description copied from interface: Configurable
Used to mark that a reader needs to be configured by command line properties. The MapReader will be given the command line properties that were set before it is asked to load the map.

Specified by:
config in interface Configurable
Parameters:
props - The input properties.

addNet

protected void addNet()
               throws FileExistsException
Throws:
FileExistsException

addNod

protected void addNod()
               throws FileExistsException
Throws:
FileExistsException

setBounds

public void setBounds(Area area)
Set the area that the map covers.

Parameters:
area - The outer bounds of the map.

addCopyright

public void addCopyright(java.lang.String str)
Add a copyright message to the map.

Parameters:
str - the copyright message. The second (last?) one set gets shown when the device starts (sometimes?).

addInfo

public void addInfo(java.lang.String info)
There is an area after the TRE header and before its data starts that can be used to save any old junk it seems.

Parameters:
info - Any string.

createZoom

public Zoom createZoom(int level,
                       int bits)
Create a new zoom level. The level 0 is the most detailed and level 15 is the most general. Most maps would just have 4 different levels or less. We are just having two to start with but will probably advance to at least 3.

Parameters:
level - The zoom level, and integer between 0 and 15. Its like a logical zoom level.
bits - The number of bits per coordinate, a measure of the actual amount of detail that will be in the level. So this is like a physical zoom level.
Returns:
The zoom object.

topLevelSubdivision

public Subdivision topLevelSubdivision(Area area,
                                       Zoom zoom)
Create the top level division. It must be empty afaik and cover the whole area of the map.

Parameters:
area - The whole map area.
zoom - The zoom level that you want the top level to be at. Its going to be at least level 1.
Returns:
The top level division.

createSubdivision

public Subdivision createSubdivision(Subdivision parent,
                                     Area area,
                                     Zoom zoom)
Create a subdivision that is beneath the top level. We have to pass the parent division.

Note that you cannot create these all up front. You must create it, fill it will its map elements and then create the next one. You must also start at the top level and work down.

Parameters:
parent - The parent subdivision.
area - The area of the new child subdiv.
zoom - The zoom level of the child.
Returns:
The new division.

addPointOverview

public void addPointOverview(PointOverview ov)

addPolylineOverview

public void addPolylineOverview(PolylineOverview ov)

addPolygonOverview

public void addPolygonOverview(PolygonOverview ov)

setPoiDisplayFlags

public void setPoiDisplayFlags(int flags)
Set the point of interest flags.

Parameters:
flags - The POI flags.

addMapObject

public void addMapObject(MapObject item)

setLabelCodePage

public void setLabelCodePage(int cp)

setLabelCharset

public void setLabelCharset(java.lang.String desc,
                            boolean forceUpper)

close

public void close()
Close this map by closing all the constituent files. Some history:


getFilename

public java.lang.String getFilename()

getRgnFile

public RGNFile getRgnFile()
Specified by:
getRgnFile in interface InternalFiles

getLblFile

public LBLFile getLblFile()
Specified by:
getLblFile in interface InternalFiles

getTreFile

public TREFile getTreFile()
Specified by:
getTreFile in interface InternalFiles

getNetFile

public NETFile getNetFile()
Specified by:
getNetFile in interface InternalFiles

getNodFile

public NODFile getNodFile()
Specified by:
getNodFile in interface InternalFiles