MKMAPHK1.TXT  (APR rev1)    BUILDING 100K MAPS FROM USGS DATA

QBasic code to make APRS maps from USGS 100K:1 CD ROM
Initial Release Version 1.0
23 Oct 1995
Jack Cavanagh, KB4XF

   Making APRS maps from the 100k CD is a two step process.  First you must
un-zip files from the CD and put them on your hard drive.  If you want to 
obtain files from the INTERNET instead of from your own $32 CD, see the
ALTERNATE method at the end of this file...  The second step is to run the 
new code, MKMAPHK1.EXE which extracts the information from the hard disk 
files.  APRS distribution now includes two maps made using this program.  
Zoom into 3909N and 07636W below 2 miles.

APR OVERVIEW:  Since MKMAPHK came out a month ago, the best way to use it
apears to be with a little prior planning.  KE4EER used something like
the following technique to map the city of Birmingham Alabama:

   He found that 1.1 mile maps almost always come out to just under 
the 3K limit.  He then made a grid plan of the whole city starting with
the most important or central area to be mapped.  Use the coordinates of
the center of this area as a starting point.  Then make as many maps as
you need with centers every 2 minutes in latitude and longitude in all
directions.  If you are in more northern latitudes, this approach will
result in a lot of horizontal overlap since longitude minutes are less
and less than a mile the further north you go, and MKMAPHK makes maps
wider in the horizontal to match the aspect of a PC screen.  This overlap
in most cases is a desirable feature.   But if you want to reduce the
redundant coverage in your maps, then you can keep the 2 minute spacing
in Latitude, but space the longitude out every 3 minutes or so depending
on your latitude...  Remember that a 1.1 mile map is actually 2.2 miles
(minutes) from top to bottom and about 3 miles wide.

   This will give you street level maps everywhere (but not until the
user zooms into the 1 mile scale!) so next (or this could have been the
first step), build some 4 and 8 mile maps with much less detail to
give a larger scale view of the city...

STEP ZERO:  MKMAPHK1.bas requires the full QB version of QBasic, not the
smaller version QBasic provided with DOS.  You must invoke QB with the
/AH option for HUGE ARRAYS.   OR get a copy of MKMAPHK1.EXE from the 
Internet SIG @tapr.org or your local HAM BBS.

STEP ONE

  It is assummed that you have already installed the CD support software
on your hard disk following the instructions that come with the CD
readme files.  Create a blank sub-directory on your hard drive to store
the data.  I use the directory name 'dlg'.  Be sure you have enough
room as 6 Meg or more of hard disk could be required.  Now run the
program "extract.exe".  Do this from a maximum user application memory
(512k) DOS configuration.  This means no shell programs and minimum
memory resident stuff. If this is not the case the program will appear
to run but no files will be written to your hard drive.

  The extract program will present you with a map of the area of the
USA covered by the CD.  At the top of the screen are various selection
options. Use either the arrow keys and the enter keys or a mouse to
select the "SELECT GRID" option.  Move the cursor to the region of
interest and click or hit ENTER.  The screen is redrawn with the
selected grid divided into 15 minute grids.  Major rivers are shown
along with major town names.  Now pick the option "SELECT LAYERS". A
window will open and several options will be shown.  Unless you have
some special need, select only the hydrography and transportation
layers.  When you click the END SELECTION option, a "SELECT 15' GRID"
option will become active.  Select it.  Move cursor to the regions of
interest and click or hit ENTER.  A window will open up showing how
much of your hard drive space will be eaten up.  Pick enough (usually
up to four) grids that contain the area you want to make an APRS map
off.  If you like me live near a grid corner, four will be required for
a home town map. In the case of Bob Bruninga, who lives near the border
of two major grids, this process may have to be repeated to get the
four nearest 15' grids for his home town map.   Once you are satisfied
with your selections, choose the "OUTPUT" option on the top bar.  The
program will ask for a path to the directory on the hard drive to store
the data.  After you respond, the program writes the info to hard
drive.  If this appears to only take a few seconds, you probably need
more lower memory. Exit the program. This takes two steps from the 15'
menu through the main menu.

   Now check to see if the files are on your hard drive in the designated
directory.  Make a note of the path to this directory.  The mapping
program will want this information. NOTHING BUT CD MAP FILES MUST BE IN
THIS DIRECTORY.  ANY OTHER FILE GUARANTEES A PROGRAM CRASH.  There is
no way to know in advance what file names will come from the CD.  The
program must try to process all files in the sub-directory. Please do 
make any sub-sub-directory under the map file sub-directory either.

STEP TWO

  Execute the file mkmaphk1.exe
------------------------------------
For those who like to hack BASIC source code is available.  Execute
QBasic from the DOS prompt (or Windows if you must) with the large
memory option. This is done with the switch /AH. Unfortunately the
requirement to use this switch precludes the use of Quick Basic that
comes with DOS.  With all his money, Bill Gates really doesn't need to
use bait and switch marketing.

        e.g.  qb /ah

   I wrote a one line batch file map.bat:
      qb /ah mkmaphk1.bas

  Load the file MKMAPHK1.BAS. Run the BASIC code (Sh-F5).
-------------------------------------
   The program first asks for the path to the data files. I use
'c:\dlg'. Next you will be asked for a file name for the output.  The
code takes care of file extensions.  For example, your response could
be 'vafred' or 'mdannap'.  Next you will be asked for the latitude and
longitude of the center of the APRS map.  Enter this information in
degrees and minutes.  Having an atlas or road map with these
coordinates nearby is helpful. I have found that aeronautical charts
are great for this. Ask your pilot friend for one; he is required to
buy a new chart every six months and should have a few outdated ones.
Decimal parts of the minutes are allowed e.g. 38,56.5 is the response
for 38 degrees 56 minutes 30 seconds North latitude.  Do this
carefully. Your coordinates must fall within one of the 15 minute grids
extracted in step one.

   The final user input is the map radius in nautical miles.  This is
actually one-half the North-South span of the map. The East-West span will
be 4/3 times this value.  The level of road detail is controlled by the
value of your input.  Interstate, U.S. Routes and major state routes will
be extracted for all maps.  Secondary state routes (Class 3) will be
extracted once the radius falls below 8 miles.  Class 4 roads, real local
stuff, appear once the radius falls below 2 miles.  You have some
control over this.  If the map radius is preceeded with a minus sign (-)
then the default class of roads is decreased by one but not less than
class 2. Use this in dense urban areas.  If the map radius is preceeded
with a plus sign (+) then the default class of roads is increased by
one but not more than class 4. Use this technique in sparse rural areas
to get more cross-road landmarks.

   For the next 20 to 30 minutes the code will grind away. As map
features are found they are plotted on the screen.  A status line on
the top shows progress in the form of the total number of lines in the
data file, a rapidly changing number of lines examined thus far and 
the number of lines accumulated for the map.  As each file is
processed, the program start time and file finish time is updated.
When all files have been processed, the code tries to link as many
short segments as possible into longer segments. Progress is shown as
the maps lines change color to white (temporarily). The results are
reported on the screen as the number of line segments and map points.
Finally at the stroke of a key the display will show the map as it
would appear in APRS.  Exit BASIC at this point and the default drive
will contain two files with your file name and the extentions .dat and
.map. The raw data file .dat can be reworked with the MAPFIX program to
delete unwanted features and make a new .map file that fits APRS.
There is also a file 'temp' which was used as a working file.  This is
over written each time the program is run.

Hints and peculiarities:

   These maps have limited river and stream information. They are on
the CD but if there is no internal coding to distinguish between a
short little stream and a signifcant river unless the river had two
distinct banks on the original maps.  Single line width rivers and
streams are just not extracted.  What we are left with is every little
pond that has a "shoreline". If these are not significant to you edit
them out with MAPFIX command "Kill feature". The line attributes on the
CD do not distinguish between coast lines, river banks or lake
shoreline.  All are colored in dim cyan.

   Make your map radius about 5% larger than the standard APRS scales
of 1, 2, 4, 8, etc nautical miles.  This will cause the smaller map
to be loaded as soon as possible. E.g. use 2.1, 4.2, 8.4 miles for
your map radius.

   The code tries to reduce map size to 3000 points using a brute force
decimation scheme.  With lots of detail this may result in a mess. In 
this case delete the *.map file; rename the *.dat file as a new *.map.
Then try to reduce the oversized *.map file with MAPFIX.  This usually
required with 2 mile maps with class 4 roads in urban areas where each
block is just two points or maps with too many coastal wetlands.

   The USGS Data User's Guide implies that political boundary and public
land survey data is on the CD. This is not the case for the optional
format CD.  If city or county lines are significant to you, import them
with MAPFIX from a map made from the 2,000,000:1 CD.

   Comments, bugs and suggestions are welcome. Contact me by packet
at kb4xf@kc4asf.va.usa.na on packet or 223 N. Randolph Rd., Falmouth,
VA 22405 by snail mail.  I will be on the Internet in a few months.

Happy mapmaking and APRS operating,   Jack, KB4XF
------------------------------------------------------------------------

USING USGS 100K DATA FROM THE INTERNET:

From: Dan Reilly <72076.2270@compuserve.com>
For those not having access to all 11 USGS CD's, here is an alternate 
method of obtaining data. 

STEP ONE ALTERNATE:  On the the Internet access the following:

     URL http://edcftp.cr.usgs.gov:80/pub/data/DLG/100K/
In the index there are thousands of locations listed alphabetically.
Select your area of interest, then the feature such as transportation,etc.
Under options, Write to File, and then select the quadrant you want. Be 
sure you select the OPTIONAL format.

The data will then be copied to your hard disk with the file name you 
select.  I suggest AAnRDFnn.GZ.  The data is compressed and must be 
uncompressed with GZIP -d *.gz. You will then have AAnRDFnn.

There are no delimiters so the data must be broken in 80 character blocks  
with the CONVDLG.BAS program below.  This will produce AAnRDFnn.REV. 
Then move this into /DLG (or whatever subdirectory you are using), LESS 
the .REV.  

Then continue with STEP TWO.

CONVDLG.BAS
CLS
Print "This file takes the unblocked INTERNET USGS 100K data and moves "
print "it into 80 character blocks."
print "The output has the same name as input plus the extension .REV."
print
INPUT "Enter filename"; f$
OPEN f$ FOR RANDOM AS #1 LEN = 80
FIELD #1, 80 AS row$
OPEN f$ + ".rev" FOR OUTPUT AS #2
DO WHILE NOT EOF(1)
   GET #1
   PRINT #2, row$
LOOP
CLOSE #1
BEEP
PRINT "When finished, move the xxx.REV files to your map making directory"
print "and remove the .REV extensions.
STOP

