# $Id: tgr2shppoly.dbfawk,v 1.15 2012/11/01 18:57:19 we7u Exp $
#
# Copyright (C) 2003-2012  The Xastir Group
#
# This dbfawk file is used to map arbitrary dbf data that accompanies
# a shapefile into Xastir canoncical values of:
#   key     - search key
#   lanes   - width of feature (usually a road but applies to rivers, etc. too)
#   color   - color to draw the road
#   name    - name of the road for labels
#   filled  - whether a polygon is drawn filled or not
#   fill_color - color to fill polygon with
#   pattern - line pattern for road, river, etc. (0 - solid; 1 - dash; 2 - double dash)
#   display_level - highest zoom level at which to display the feature
#   label_level - highest zoom level at which to display the label
#   symbol  - 3 char 'TIO': table, ID, overlay
# NOTE: This file format is modeled after awk but is nowhere near awk
#  compatible.
#
# This file is used to map US Census Tiger/Line  shapefiles which are
# converted to shapefiles using the Xastir_tigerpoly.py utility 

# BEGIN is called once per dbf file which contains multiple records.
BEGIN {
dbfinfo="MODULE:FILE:CENID:POLYID:STATECU:COUNTYCU:TRACT:BLOCK:BLOCKSUFCU:RS_A1:AIANHHFPCU:AIANHHCU:AIHHTLICU:ANRCCU:AITSCECU:AITSCU:CONCITCU:COUSUBCU:SUBMCDCU:PLACECU:SDELMCU:SDSECCU:SDUNICU:RS_A20:RS_A21:RS_A22:CDCU:ZCTA5CU:ZCTA3CU:RS_A4:RS_A5:RS_A6:RS_A7:RS_A8:RS_A9:CBSACU:CSACU:NECTACU:CNECTACU:METDIVCU:NECTADIVCU:RS_A14:RS_A15:RS_A16:RS_A17:RS_A18:RS_A19:STATE:COUNTY:BLKGRP:AIANHHFP:AIANHH:AIHHTLI:ANRC:AITSCE:AITS:CONCIT:COUSUB:SUBMCD:PLACE:SDELM:SDSEC:SDUNI:MSACMSA:PMSA:NECMA:CD106:CD108:PUMA5:PUMA1:ZCTA5:ZCTA3:TAZ:TAZCOMB:UA:UR:VTD:SLDU:SLDL:UGA:POLYLONG:POLYLAT:WATER:LAND:SOURCE:CFCC:LANAME:LALONG:LALAT:FILLER";
#dbffields is which of the above fields we actually want to look at.
# No point reading dbffields that are not looked at further.
dbffields="WATER:CFCC:LANAME";
}

# BEGIN_RECORD is called once per dbf record which contains multiple fields.
# Use this rule to re-initialize variables between records.
# use color 11 to highlight stuff that isn't properly mapped.
BEGIN_RECORD {key=""; lanes=1; color=8; fill_color=11; name=""; filled=0; pattern=0; display_level=0; label_level=32; label_color=8; font_size=0; symbol=""; fill_style=0; fill_stipple=0 }

# Name -- only features that have landmark records get names
/^LANAME=None$/ {next}
/^LANAME=(.*)$/ {name="$1"; next}

#We need this just in case there is no CFCC code to tell us we're a water
# feature
#Perennial water
/^WATER=1$/ {filled=1; fill_style=2; fill_stipple=2; color=117; fill_color=117; label_color=26; display_level=1024;}
#intermittent water
/^WATER=2$/ {filled=1; fill_style=2; fill_stipple=0; color=117; fill_color=117; label_color=26; display_level=512;pattern=1;}

# These are *all* the allowed feature classes, even those that aren't
# polygon types.  We won't actually bother testing for anything other 
# than the ones we expect to find, lest we spend too much time filtering.

# Census Feature Class Codes are used to set lanes, color, display_level, etc.
# CFCC A..: roads
# A11 - primary limited access road or interstate highway, unseparated
# A12 - primary limited access road or interstate highway, unseparated in tunnel
# A13 - primary limited access road or interstate highway, unseparated, underpassing
# A14 - primary limited access road or interstate highway, unseparated, with rail line in center
# A15 - primary limited access road or interstate highway, separated
# A16 - primary limited access road or interstate highway, separated, in tunnel
# A17 - primary limited access road or interstate highway, separated, underpassing
# A18 - primary limited access road or interstate highway, separated, with rail line in center
# A21 - primary road without limit access, US highways, unseparated
# A22 -primary road without limit access, US highways, unseparated, in tunnel
# A23 - primary road without limit access, US highways, underpassing
# A24 - primary road without limit access, US highways, unseparated, with rail line in center
# A25 - primary road without limit access, US highways, separated
# A26 - primary road without limit access, US highways, separated, in tunnel
# A27 - primary road without limit access, US highways, separated, underpassing
# A28 - primary road without limit access, US highways, separated, with rail line in center
# A31 - secondary and connection road, state highways, unseperated
# A32 - " in tunnel
# A33 - " underpassing
# A34 - " with rail line in center
# A35 - secondary and connection road, state highways, seperated
# A36 - " in tunnel
# A37 - " underpassing
# A38 - " with rail line in center
# A41 - local, neighborhood and rural road, city street, unseparated
# A42 - " in tunnel
# A43 - " underpassing
# A44 - " with rail line in center
# A45 - local, neighborhood and rural road, city street, separated
# A46 - " in tunnel
# A47 - " underpassing
# A48 - " with rail line in center
# A51 - vehicular trail, unseparated
# A52 - " in tunnel
# A53 - " underpassing
# A61 - cul-de-sac
# A62 - traffic circle
# A63 - access ramp
# A64 - service drive
# A65 - ferry crossing
# A71 - walkway or trail
# A72 - stairway
# A73 - alley
# A74 - driveway

#Roads are not going to be polygons, don't even check

# need to implement these:
# B: railroads
# B01 - railroad track
# B02 - " in tunnel
# B03 - " underpassing
# B11 - railroad main line
# B12 - " in tunnel
# B13 - " underpassing
# B21 - railroad spur
# B22 - " in tunnel
# B23 - " underpassing
# B31 - railroad yard track
# B32 - " in tunnel
# B33 - " underpassing
# B40 - railroad ferry crossing
# B50 - other rail line
# B51 - carline (streetcars, etc.)
# B52 - cog railroad, incline railway or logging tram
# /^CFCC=B/ {lanes=1; color=8; pattern=1; display_level=128; next}

# C: transmission lines
# C00 - misc ground transportation
# C10 - pipeline
# C20 - power transmission line
# C30 - other ground transportation
# C31 - aerial tramway
# /^CFCC=C/ {display_level=0; next}
# D: landmarks
# D00 - unknown
# D10 - military installation
# color is RosyBrown2
/^CFCC=D1/ { filled=1; color=112; fill_color=112; fill_style=2; fill_stipple=0; display_level=1024; font_size=1; next}
# D20 - multihousehold or transient quarters
# D21 - apartment building or complex
# D22 - rooming or boarding house
# D23 - trailer cour or mobile home park
# D24 - marina
# D25 - crew-of-vessel area
# D26 - housing facility for workers
# D27 - hotel, motel, resort, spa, YMCA, YWCA
# D28 - campground
# D29 - shelter or mission
/^CFCC=D2/ {filled=1;  color=14; fill_color=14; fill_style=2; fill_stipple=0; display_level=128; font_size=1; next}
# D30 - custodial facility
# D31 - hospital
# D32 - halfway house
# D33 - nursing home
# D34 - county home or poor farm
# D35 - orphanage
# D36 - jail 
# D37 - federal penetentiary, state prison, or prison farm
/^CFCC=D3/ {filled=1;  color=13; fill_color=13; fill_style=2; fill_stipple=0; display_level=128; font_size=1; next}
# D40 - unknown educational or religious
# D41 - sorority or fraternity
# D42 - convent or monastery
# D43 - educational institution
# D44 - religious institution
/^CFCC=D4/ { filled=1; color=20; fill_color=20; fill_style=2; fill_stipple=0; display_level=64; font_size=1; next}
# D50 - transportation terminal
# D51 - airport
# D52 - train station
# D53 - bus terminal
# D54 - marine terminal
# D55 - seaplane anchorage
# D57 - Airport
# color is "gray81"
/^CFCC=D5/ {filled=1;  color=113; fill_color=113; fill_style=2; fill_stipple=1; display_level=512; font_size=1; next}
# D60 - Employment center
# D61 - Shopping center
# D62 - Industrial Building or Ind. park
# D63 - Office Building or office park
# D64 - Amusement Center
# D65 - Government Center
# D66 - Other emplyoment center
/^CFCC=D6/ {filled=1;  color=113; fill_color=113; fill_style=2; fill_stipple=0; display_level=256; font_size=1; next}
# D70 - tower
# D71 - lookout tower
/^CFCC=D7/ {filled=1;  color=113; fill_color=113; fill_style=2; fill_stipple=0; display_level=128; font_size=1; next}
# D80 - open space
# D81 - golf course
# D82 - cemetery
# Color is "tgr_park_1"
/^CFCC=D8[01]/ {filled=1;  color=114; fill_color=114; fill_style=2; fill_stipple=0; display_level=512; font_size=1; next}
# D83 - national park
# D84 - national forest
# D85 - state or local park or forest
# color is "tgr_forest_1"
/^CFCC=D8[3-5]/ {filled=1;  color=116; fill_color=116; fill_style=2; fill_stipple=0; display_level=1024; font_size=1; next}
# D90 - special purpose landmark
# D91 - post office box-only ZIP Code location
# D92 - urbanizacion (Puerto Rico)
/^CFCC=D9/ {filled=1;  color=101; fill_color=101; fill_style=2; fill_stipple=0; display_level=256; font_size=1; next}

# E: physical featuers
# E00 - unknown physical feature
# E10 - fence line
# E20 - topgraphic feature
# E21 - ridge line
# E22 - mountain peak
# E23 - island
# Don't display the E's
# F: legal boundaries
# F00 - nonvisible boundary
# F10 - jurisdictional boundary
# F11 - offset boundary
# F12 - corridor boundary
# F13 - interpolate boundary across water
# F14 - superseded boundary
# F15 - superseded boundary, corrected
# F20 - data base topology
# F21 - automated feature extension to lenghten physical feature
# F22 - irregular feature extension, determined manually
# F23 - closure extension
# F24 - separation line
# F25 - centerline
# F30 - point-to-point line
# F40 - property line
# F50 - Zip Code boundary
# F60 - map edge
# F70 - statistical boundardy
# F71 - 1980 "
# F72 - 1990 "
# F73 - internal use
# F74 - 1990 " ...
# F80 - other tabulation boundary
# F81 - internal use
# F82 - internal use
/^CFCC=F/{filled=1; color=115; fill_color=115; fill_style=0; label_level=32; display_level=512; pattern=0; next}
#/^CFCC=F/{display_level=0; next}
# Don't bother with the F's either for now
# (G not used by census;  tig2aprs uses for special maps)
# H: hydrography
# Color is "tgr_water_1"
/^CFCC=H/ {filled=1; color=117; fill_color=3; label_color=26; display_level=512;}
# H00 - water feature
# H01 - shoreline of perennial water feature
# H02 - shoreline of intermittent "
/^CFCC=H0/ {filled=1; fill_style=2; fill_stipple=2; display_level=4096; label_level=16; lanes=1}
/^CFCC=H02/ {filled=1;  fill_stipple=0; pattern=1; next}
# H10 - stream
# H11 - perennial stream
# H12 - intermittent stream
# H13 - braided stream or river
# H20 - canal, ditch or aqueduct
# H21 - perennial "
# H22 - intermittent "
# H30 - lake or pond
# H31 - perennial "
# H32 - intermittent "
# H40 - reservoir
# H41 - perennial "
# H42 - intermittent "
# H50 - bay, estuary, gulf, sound, sea, ocean
# H51 - bay, estuary, gulf or sound
# H52 - sea or ocean
/^CFCC=H[1-5]/ {filled=1; fill_style=2; fill_stipple=2;display_level=256; label_level=16; lanes=1}
/^CFCC=H[1-4]2/ {filled=1; fill_stipple=0; pattern=1; next}
# H60 - gravel pit or quarry filled with water
/^CFCC=H6/ {filled=1; fill_style=2; fill_stipple=2;display_level=256; label_level=16; lanes=1}
# H70 - nonvisibile....
# H80 - special water features
# H81 - glacier
/^CFCC=H81/ {filled=1; color=15; fill_color=15; fill_style=2; fill_stipple=2;display_level=256; label_level=16; lanes=1}
