CB Shapedraw - Parses ESRI shapefiles and draws their contents to the Chipmunk Basic graphics window
Version: 1.0CB Shapedraw is a Chipmunk Basic program that parses ESRI shapefiles and draws their contents to the Chipmunk Basic graphics window. Multiple shapefiles can be drawn together using different line weights and colors, allowing simple map overlays to be constructed.
Operating System: Mac OS X
CB Shapedraw supports point, multipoint, polyline, and polygon shape types.
This program is intended as a Chipmunk Basic programming example. Please see the web site for additional information including usage help.
Here are some key features of "CB Shapedraw":
· unnumbered lines
· catching and handling open errors using on error (the open command's optional "else goto" error handler appears to be incompatible with labelled goto targets; it'll only go to a hard-coded line number - blah!)
· use of the fseek command to navigate around a file (not put to terribly effective use in cb-shpdraw as the shapes are drawn sequentially anyway, but in place to facilitate future modifications where particular shapes are requested but not others - possibly according to attribute values)
· use of named subroutines
· parsing of a fairly complex binary file format - in accordance with ESRI's specification, shapefiles contain a combination of "big endian" and "littleendian" byte ordering. This means that some values are stored "backwards" (most, actually, relative to the Mac's native "big endian" byte order), which is the reason for the byte-by-byte math in the Read subroutines. Otherwise, input could probably be lots faster, using get to read a typed structure directly from file. Maybe that's possible anyway. Regardless, figuring out how to read a little-endian eight-byte double with Chipmunk Basic seemed pretty tricky.