cGPSmapper (Shapefile capable version) Tips & Tricks
Version 1.2 (12 Feb 2005)
Tips & Tricks for cGPSmapper
This
document focuses on the ESRI shapefile capable versions of
cGPSmapper.
It is not intended to be a cGPSmapper “A …
Z” guide.

This document is a work in progress. If you have a tip that you’d like to share please put it on the newsgroup and ask for it to be added to Tips & Tricks. As several people may make the same or similar suggestions the document will not acknowledge individual contributors.
Overview
This Tips & Tricks document is intended to assist you with the process involved in using the ESRI shapefile capable versions of cGPSmapper.
This may seem more difficult at first than other methods (such as using GPSmapedit) if you only have a couple of tiles to make but if you have a lot of data it will definitely be both easier & faster to use the shapefile method.
Most of the basic concepts remain unchanged but with the shapefile capable versions you go direct from shapefiles to IMG file(s). GPSmapEdit is not used at all except it is very useful for a quick review of the img output prior to creating the preview files.
A high level view of the process is:
Prepare your base data in three of four large master shapefiles
Use intersect to create individual shapefiles, e.g. one line shapefile for each map tile.
Run cGPSmapper with a batch file to create the detail IMG files
Run cGPSmapper
with a batch file to create the preview files
General Requirements & Procedures
You will need some competence with Arcview but there are plenty of Arcview tutorials on the net. The sketchy Arcview notes below may help but Arcview help is outside the scope of this document. (We say Arcview but there are alternative programs to create & manipulate shapefiles.)
Using Arcview, prepare your master polygon, line & point themes. Pay attention to:
If you start with third party shapefiles the chances are they have many extraneous fields. Eliminate these if you are ABSOLUTELY sure you will never need them as they do slow you down, BUT, they may be very difficult to add back later on.
You need a numeric field that is used to store the type data (1 = principal highways, 2 = major roads etc) and a string field that is used for the name of the poly/line/point
Create these in the master shapefile so that it will be consistent in all individual files.
When you are completely happy that your master files have the appropriate fields including those for Name & Type you then divide your master shapefiles into individual shapefiles, one for each eventual map tile. (When you do this DO NOT discard your master file as you will go back to it whenever you need to edit your base data. )
One way to divide the data is using the batch overlay function in the Arcview extension Xtools. Undoubtedly there are others.
You should end up with a structure like this:
Polys_1.shp The polygon theme for map tile #1
Ponts_1.shp The point theme for map tile #1
Lines_1.shp The line theme for map tile #1
Misc_1.shp Additional line theme for map tile #1 (Optional)
Pt_1.shp Additional point them for map tile#1 (Optional)
Polys_2.shp The polygon theme for map tile #2
Ponts_2.shp The point theme for map tile #2
Lines_2.shp The line theme for map tile #2
Misc_2.shp Additional line theme for map tile #2 (Optional)
Pt_2.shp Additional
point them for map tile#2 (Optional)
. . . . . .
. .
Polys_n.shp The polygon theme for map tile #n
Ponts_n.shp The point theme for map tile #n
Lines_n.shp The line theme for map tile #n
Misc_n.shp Additional line theme for map tile #n (Optional)
Pt_n.shp Additional
point them for map tile#n (Optional)
ADDITIONAL
NOTES:
Each theme can include many features, for instance the lines theme could include several class of roads, political boundaries etc. However, sometimes it is more convenient to separate them such as for instance one line theme for roads and a second for administrative boundaries, a third for rivers etc.
Some themes may have only polys but no points and only a portion of the tiles may have a misc theme etc. This will not cause any problems
The ESRI capable
version of cGPSmapper can be used in batch mode, using the following
syntax:
cGPSmapper
ac default.mp -d 12345678 “Easy tile name”
NOTES:
To see the full range of cGPSmapper options run cGPSmapper without any of the parameters.
In the example above the map tile number is 12345678 and the easy map name is Easy tile name. Note the use of the “quote marks” around the name. These are optional IF there are no spaces in the tile name.
The text file default.mp specifies the options, dictionary settings and names of the shapefiles etc.
Each section of Default.mp has a line such as “Name=templine” which specifies the name of the shapefile to be used in that section. Note that you must not use the extension portion of the shapefile name.
Each section has a line to specify which field carries the name of the element, e.g. “LabelField=Name”
Each section has a line to specify which field designates the type of line / point / poly etc, e.g. “TypeField=type”
The Dictionary section is unchanged but in this example some comment lines have been added for easier reading.
The sample
Default.mp looks like this:
Default.mp
[IMG
ID]
PreProcess=F
TreSize=2000
;RgnLimit=500
Levels=5
Level0=24
Level1=21
Level2=19
Level3=16
Level4=14
Zoom0=0
Zoom1=1
Zoom2=3
Zoom3=4
Zoom4=6
[END-IMG
ID]
;=========== DICTIONARY ========================
;
RGN 20 = points
; RGN 40 = lines
; RGN 80 =
polys
[DICTIONARY]
;
NOTE
; If there is no LevelxRGNn= statement for a given
level then it
; defaults to all “ones”. Hence you
could have had the same impact ; by adding a
Level0RGNn=111111111111111111111111 line with to
; each of
the three dictionary sections below.
; Type
10 20 30 40
; |
| | |
;-----------123456789 123456789
123456789
123456789
Level1RGN20=00010101010000000000000000000000000000000000
Level2RGN20=00010101000000000000000000000000000000000000
Level3RGN20=00010100000000000000000000000000000000000000
Level4RGN20=00010000010000000000000000000000000000000000
;
Level5RGN20=00010000000000000000000000000000000000000000
;
Type 10 20 30 40
;
| | | |
;-----------123456789
123456789 123456789 123456789
Level1RGN40=11111000000000000000000000010000000000000000
Level2RGN40=11111000000000000000000000010000000000000000
Level3RGN40=11110000000000000000000000010000000000000000
Level4RGN40=11100000000000000000000000010000000000000000
;
Level5RGN40=11000000000000000000000000010000000000000000
;
Type 10 20 30 40
;
| | | |
;-----------123456789
123456789 123456789
123456789
Level1RGN80=00000000000000000000000000000000000000010000
Level2RGN80=00000000000000000000000000000000000000010000
Level3RGN80=00000000000000000000000000000000000000010000
Level4RGN80=00000000000000000000000000000000000000010000
;Level5RGN80=00000000000000000000000000000000000000010000
;
All polys filtered out except Sea (Poly type
40)
[END-DICTIONARY]
;============= LINES
==========================
[SHP]
Name=templine
;Type 64
for lines, 16-POI, 32-points and
128-regions
Type=64
LabelField=Name
TypeField=Class
Level=0
EndLevel=5
[END-SHP]
;=============
LINES #2 =======================
[SHP]
Name=tempstat
Type=64
LabelField=Name
TypeField=Class
Level=0
EndLevel=5
[END-SHP]
;=============
POLYS ==========================
[SHP]
Name=temppoly
Type=128
;LabelField=Name
;DefaultType=40
TypeField=type
Level=0
EndLevel=5
[END-SHP]
;==========
POPULATION CENTRES (POINTS)
=======
[SHP]
Name=temppopn
Type=32
LabelField=Name
TypeField=Locality
Level=0
EndLevel=5
[END-SHP]
;=============
MISC POINTS
====================
[SHP]
Name=tempmisc
Type=32
LabelField=Name
TypeField=Locality
Level=0
EndLevel=5
[END-SHP]
;
***********************************
The ESRI capable version is very well setup for batch operation. That is, you control it with a very simple batch file.
If you are new to batch files take a look at http://www.computerhope.com/batch.htm Note that some batch commands are specific to the flavour of DOS. The batch files included here run under Win XP, others may vary slightly.
There are two basic alternatives for creating lots of detail IMG files, i.e.
The traditional way is to create a folder for each map tile and then use identical names for the shape files, i.e. all point themes will have the same name but they will be in separate folders. This should not be too difficult.
The method preferred method by the author is:
Use the name convention as in point four above, that is four or five characters common to all point themes etc then a number at the end to distinguish them.
The master
batch file “calls” a second batch file (like a
sub-routine) which renames the files in turn and returns control
to the master batch file which runs cGPSmapper. Sounds complex
but in reality very straight forward.
Sample batch files
are:
Batch_create_img.bat
ECHO
OFF
ECHO Parameters file is called default.mp
ECHO
Question - must it be ".mp"
ECHO Simple Excel
spread sheet used to generate the batch lines
ECHO My IMG
file numbers are generated from the Map names
ECHO Need to
fill in the easy name map name in my Excel spreadsheet.
ECHO
Tile index names are valuable when editing/looking for problems
etc
ECHO
REM
Note that in the next line there is a space between
“copy_files.bat” and “_1” and the same in
all subsequent lines.
Call copy_files.bat
_1
cGPSmapper ac default.mp -d 88005111 “Cape York
1”
DEL TEMP*.*
Call copy_files.bat _2
cGPSmapper
ac default.mp -d 88003131 “Lake Mackay 2”
DEL
TEMP*.*
Call copy_files.bat _3
cGPSmapper ac default.mp -d
88002131 “Telfer 3”
DEL TEMP*.*
. . . . . . .
Call copy_files.bat n
cGPSmapper ac default.mp -d
88009999 ”Last tile 99”
DEL
TEMP*.*
Copy_files.bat
COPY
polys%1.* temppoly.*
COPY points%1.* temppont.*
COPY
lines%1.* templine.*
COPY popn%1.* temppopn.*
COPY
misc%1.* tempmisc.*
COPY state%1.* tempstat.*
ECHO
Have now copied shapefile %1 to TEMPxxxx.*
NOTES:
The master batch file “passes” the map tile reference to the copy_files.bat as a variable so that it only copys one set of shapefiles in each pass.
In the first line the variable is “_1” and the %1 in copy_files.bat is replaced by “_1” on the first pass and next time it is ”_2” etc. You don’t have to understand it, because it works!!
An Excel
spreadsheet is an easy way to create and maintain the master
batch file. It will take a little time first time around but you
will use it very often.
A spreadsheet can include
formulae to create map tile numbers, reference the original tile
numbers to the 8 digit img name and the corresponding easy tile
name etc. Very quick & easy using simple text arithmetic and
a few other functions.
When you make a change, copy the
output column in the spreadsheet straight into the (batch) text
file.
You’ll want to understand some Excel
functions such as:
The ampersand (&) for joining two text strings
The formula =left(a,b) and =right (a,b) for selecting portions of a string
If statements, sometimes nesting them makes it quicker.
Vlookup is
also very useful.
The preview files are created in the traditional way as if you had manually created your detail IMG files. To quickly recap on that process:
Create a simple
batch file:
Create_preview.bat
c:\gps-mapper\cGPSmapper
pv -l C:\MapSet\Finished_IMG\Mapset_pv.txt > preview.log
REM
C:\MapSet\Finished_IMG\ is the full path to the completed detail
IMG files.
Mapset_pv.txt is the file that provides the settings for preview file creation. No change in this area.
My
Mapset_pv.txt file looks like:
;
Sample file accepted by cGPSmapper to create new map
data-set
[Map]
FileName=Mapset
; Above determines name
of preview img & tdb
files
MapVersion=100
ProductCode=6600
Levels=2
Level0=14
Level1=12
Zoom0=5
Zoom1=6
;
==============================
MapsourceName=Mapset
MapSetName=Mapset
CDSetName=Mapset
[End-Map]
[Files]
img=C:\Mapset\Finished_IMG\66001131.img
img=C:\Mapset\Finished_IMG\66001141.img
img=C:\Mapset\Finished_IMG\66001151.img
img=C:\Mapset\Finished_IMG\66002131.img
img=C:\Mapset\Finished_IMG\66002141.img
img=C:\Mapset\Finished_IMG\66004131.img
img=C:\Mapset\Finished_IMG\66004141.img
img=C:\Mapset\Finished_IMG\66004151.img
img=C:\Mapset\Finished_IMG\66004161.img
img=C:\Mapset\Finished_IMG\66005111.img
img=C:\Mapset\Finished_IMG\66005121.img
.
. . . .
img=C:\Mapset\Finished_IMG\66005131.img
[END-Files]
Arcview Extensions
You will undoubtedly need a few Arcview extensions. If you don’t already have your own favourites try these:
Xtools.
Perhaps the most used extension. Useful for all sorts of file
manipulation and its batch capability is a true winner when you need
to divide a large shapefile into individual shapefiles for map
tiles. (We suggest Intersect)
Examples where we use
Xtools:
Intersecting a master shapefile to create lots of smaller shapefiles
Merging themes
Renaming themes
Convert graphics to shapes & vice versa
Convert polygons to polylines
Managing
shapefiles (renaming, deleting, copying etc)
Edit
Tools
Also useful for various purposes but in particular:
Splitting lines
Manipulating donuts (islands etc)
AV Tools
Splitting polygons
Etc
Memo Tools
Create theme of the outer extents of another theme (MemoTheme/ Theme Extent To Polygon shape)
Split a polygon theme into individual shapefiles, one file for each record. (You can use this to create shape files for individual map tiles, i.e.
Create a polygon theme that has a record for each eventual map tile
Use Memo Tools to split this index shapefile into n shapefiles where n is the number of map tiles that you want.
You can split an existing polygon with a polyline. To keep your polylines square, draw rectangles as graphics, convert to shapefiles, convert polygons to polylines and delete unwanted lines.
Use the batch capability of Xtools to intersect the master shapefiles and create individual shapefiles for each tile
Geoprocessing tools
To join two or more polys into one (dissolve lines between them)
MemoTools extension
MemoTheme/ Theme Extent To
Polygon shape
General cGPSmapper Tips
If you omit a
Dictionary line it is by default filled with 1.
Therefore
Level1RGN40=11111000000
Level2RGN40=11111000000
Level3RGN40=11110000000
is
equivalent
to
Level0RGN40=1111111111111111111111111111111111111111111111111111111
etc
Level1RGN40=11111000000000000000000000000000000000000000000
Level2RGN40=11111000000000000000000000000000000000000000000
Level3RGN40=11110000000000000000000000000000000000000000000
Keys LevelX (from [IMG ID]) defines BOTH :
data resolution
visibility of the data for different zoom ranges
The number of
levels in your detail maps is defined in your [IMG ID] section:
[IMG ID]
PreProcess=F
TreSize=2000
;RgnLimit=500
Levels=5
Level0=24
Level1=21
Level2=19
Level3=16
Level4=14
Zoom0=0
Zoom1=1
Zoom2=3
Zoom3=4
Zoom4=6
[END-IMG ID]
and
the content is filtered with the Dictionary settings, e.g.
; Type 10 20 30 40
; | | | |
;-----------123456789 123456789 123456789 123456789
Level1RGN40=11111000000000000000000000010000000000000000
Level2RGN40=11110000000000000000000000010000000000000000
Level3RGN40=11100000000000000000000000010000000000000000
Level4RGN40=11100000000000000000000000010000000000000000
The Level 4 dictionary line adds no value as the last level will always be empty, regardless of the Dictionary settings. (Open one of your completed IMG in GPSmapedit and check the statistics for each level.)
The preview file will take on the detail that is included in the most detailed level, i.e. Level 3 in this example.
Adding an
additional Dictionary statement, e.g. Level5RGN40=1111111111
Will
make no impact at all
The levels must
be defined in declining order AND there must be a Zoom defined for
each level. If either of these rules is not observed you’ll
get an error message along the lines of:
default.mp(18)
: Error E021: Grid definition for layers must be
descending (check LevelX keys in [IMG ID])
“When cGPSMApper runs, the x000 or so
polygons I started with are split into 60k =very small= squares.
Which take a long time to compile…..”
- This is a typical TreSize related issue
- If you make
larger value for TreSize - then you got larger objects, smaller
TreSize - smaller objects.
- Play with this value in
range 5000 - 500 to find best value.
Re finished IMG map sizes
Limit of 1MB is good ONLY if we are talking about quite old devices – like GPS III+ or GPS12Map
If we talk about modern receivers - sizes around 2Mb - 3Mb seems reasonable - but remember - not the size is most important but performance.
Re name of the
input parameters file for detail IMG files.
- Called Default.mp
in my example above
- When you are using 'ac' command - you
are not obligated to use .mp
extenstion (mp extension is
required when there is no 'ac' command)
“I receive the following error when trying
to open my newly created map in mapsource v4 v4.09”
“There is a problem with this GARMIN
application…….”
Typically
this is a registry problem. Duplicating a file name in the preview
parameters file (Mapset_pv.txt in my example above) will always
result in a crash. To fix:
- Correct Mapset_pv.txt
- If neccesary reedo registry entries
General idea of the registry :
LOC is pointing to the DIRECTORY where you store DETAIL IMG FILE (or FILES) - the real maps
BMAP is pointing to the preview IMG file - the one created after 'pv' or 'pvx' command
TDB is pointing
to the TDB file
IF MapSource is unable to start (you made
something wrong in the file) - you can either re-edit the reg file
and again add it to registry (since the names of keys are the same
- it will replace old values) - OR start 'regedit' ( Start->Run
and type 'regedit' ) go to path
HKEY_LOCAL_MACHINE\SOFTWARE\Garmin\MapSource\Products\66 and fix
your errors or even delete whole branch and start again.
Other Tips
This will probably sound strange if you didn’t grow up with the DOS command line but besides the three or four major batch operations (create IMG files & create preview files) you will find it very useful to create several small batch files for all sorts of repetitive operations. These might include:
Creating
directory listings to get a list of shapefile names, e.g.
DIR
*.dbf /b > directory.txt
Unzipping a
sub-set of files from a group of storage zip files, e.g.
unzip.exe
*.zip *f_r.*
Deleting files
of a certain type, e.g.
DEL
*f_r.*
Excel is very useful for creating batch files. Using the text arithmetic character (&) you can very quickly create a long batch file and vastly reduce the potential for typographical errors.
Be disciplined about your folder & file names, where you keep the various files etc. Much easier in the long run.
Back up your shapefiles regularly . . . you will make mistakes and corrupt files occasionly.
Make notes about your process. Takes a little time but very useful if you get back into the project after a few weeks away.
Delete any land background elements from your shapefiles or use the Dictionary to filter them out. For instance, the only background polygons that you want are those that designate ocean. Islands are only holes in the sea and large land masses don’t need to be individually defined either.
Use Excel if you
need to enter large amounts of numbers to designate line type or
road names etc. Use nested IF statements to create a unique number
from a line description such as Highway, residential street
etc.
======================================================
Other Arcview Tips
To simplify themes with many islands. . . . . . .
Copy frame theme twice
Open one them and remove mainland & island records
Using extension Edit Tools remove all donut holes from sea
Open theme with all islands & remove excess records
Save theme with only required islands
Merge remaining island theme with sea theme
Use Donut extension to remove donuts
Save new sea theme
Merge sea them with original
mainland & required islands theme
To create theme of full extent . . . .
Use MemoTools extension
MemoTheme/ Theme Extent To
Polygon shape
To split extent theme into individual shapefiles
Use extension Memo Tools
“MemoThm / Split Shapefile By Attribute”
To split lines at vertices etc . . . .
Use extension Edit Tools
Put lines in edit mode
To split one polygon to two or more for index theme
Draw graphic rectangles to create polygons with lines at desired places “square” lines
Use XT Tools to convert graphics to shapes
Use XT Tools to convert polygons to polylines
Use Edit Tools to split poly lines at vertices
Delete unrequired lines
Use extension AV Tools (“Poly split”)
To transfer features from one theme to another . . . .
Use MemoTheme or Xtools ??
To join polys into one
Use extension Geoprocessing tools to join polys into one (dissolve)
View / Geoprocessing
= = = = = = = = = = = = = =