~/c/overlay/README  My map overlay program, 6/89

Last modified: 
FILES

   sq.db  Sample square db
   di.db  Sample diamond db

   ~/c/overlay-jul89 contains the version as of July 1989.  No changes were
   made after that until December, when major changes were made.  The new
   version is in ~/c/overlay.

   ~/c/overlay-dec89 contains the intermediate version as of Dec 89.  This
   is being abandoned in favor of a version which just calculates the areas
   of the output polygons.

   SCCS: -r4 4th version as listed below.


TODO:

   Handle long polygon ids.


ACTIVITY LOG:

   pnpoly.c was assembled and modded from some Venki stuff, but is no
   longer used.

   3-12-90
   After program is working, modify all routines to have SCCS flags and
   create in SCCS.

   rename scale_map -> scale_vertices

   3-16-90
   1. Create select_polygon to print and plot the chains of some polygon.

   2. Edit jul.db to remove 5 zero length chains with 0,0 polygons.  Why
      were they there??


   3-31-90
   1. Modify the slab database to be like the grid database.

   2. Start using one array for both maps' vertices (ditto edges,
   n_vertices etc) in preparation for more than 2 maps.

   6-13-90
   1. Start the next iteration.  Clean up. Faster.  Number maps 0,1.

   7-6-90
   1. Systematically renamed many variables.  
   2. Mark the maps' edges in the grid by storing the start of map #1
      edges, instead of adding an offset to each edge of map #1.

   8-9-90
   1. Don't alloc empty grid cells.
   2. Dynamically alloc fverts space and then free after scaling into
   (integer) verts.
   3. Put all database files in db/ .
   4. Some change in make now won't let it run if SCCS exists and files
   in it that make wants are writable.  Thus rename SCCS to SCCS1 when
   running make.  There is also probably a fix that could be put into
   the Makefile.

   8-13-90
   1. Start r6.
   2. Have extract_edges delete zero length edges.
   3. Delete edge field 'dd' to save space.
   4. Replace pt_pgraph and find_which_pgn by locate_vertices_in_other_map.
   5. Add code to locate_vertices_in_other_map and new routine
   start_graphics to plot the current cell to help debugging.  This
   works only on sunview, but is only needed for debugging.
   6. Correct chain 6 counting from 0 of jul by swapping the polygon
   numbers.
   7. Added assorted plotting to debug.

   8-21-90
   1. A new problem occurred where read_delta_times returned garbage.
   Maybe some clash between gcc and cc caused it, or maybe the crash and
   restore of /usr on ecse did something.  Retyping read_delta_times
   from float to double fixed that.
   2. Fix more logic errors in locate_vertices.
   3. Make intersect_edges round intersection points properly.
   4. Note on the problem of some output polygons having negative areas
   (apart from jul 999, which is ok):  overlay worked at the star of
   July, then got this problem, perhaps when I abandoned slabs, then I
   fixed it again.

   11-20-91
   1. Start looking for the error when the US is overlaid on itself.  
   2. Clean up intersect_edges by splitting out a new routine.
   3. Reduce INTERNAL_MAX etc from 22938 to 16385 since we need 8m^2<2^31,
      not 2^32.
   4. Add '=' before some prints so output can be read in emacs overlay
      mode,as set by the emacs my-overlay function.
   5. Fix 2 simulation of simplicity errors in locate_vertices.
   6. Now when I overlay US on US, the only errors are these:
       53 x   53:   -3.2563   *****
       37 x   51:    3.2873  *****
   7. Fancify select_polygon a little.
   8. Overlay does not handle cases where two edges of one polygon are
      coincident or cross.  I could do this if there were a need, but
      consider it largely a data error.  This is not completely true since
      it could be created by the scaling in overlay.
   9. In print_output_areas, zero any area that is absolutely less than
      10 in internal coords.
   10. Edit db/us into us2 to delete 2 point chain 410048 bordering 37
       0, and edit 2 point chain 480041, bordering 37 51 to border 0 51.  This
      fixed the 37x51 error above.
      Edit us2 to change point 3 of chain 1100110 from x= 3.622501E to
      3.61.  This stops a vertex of an island from being inside the mainland.
      Edit us2 to flip chain 1130113 from neighboring polygons 53 0 to 0 53.
   11. Now overlay works on us2 overlaid on us2 and gives no negative
      areas.  All cross areas are less than about 1e-5.  This seems a
      little large but not necessarily an error.  All the polygons overlaid
      on themselves give the correct area.   Therefore overlay appears
      to work.
   12. Add conditional compilation with flaf USESUNVIEW for everything
      that calls sunview graphics.


VGRIND

   setenv TROFF ptroff
   setenv PRINTER lw (or whatever)
   vgrind file.c


VERSIONS

1. 1st, slow, working version.
2. faster but non-working version.
3. working version of 2.
4. robust against numerical problems. Should be faster, but is slower so
   far.  Stored in overlay-apr90.
5. Started 6/90.  Cleaned up. faster.
6. started 8/90.  Faster.  Simpler.
   11-20-91 Froze in overlay-aug90.
7. overlay-anim, started 4-27-92 to instrument overlay for xanim.
   The only changes were to turn on debugging for debug_print_xsect and
   debug_calc_areas in overlay.c, and to compile -cg89 -O3, and to
   increase some sizes in overlay.h:

      ~/c/overlay-anim(859)$ diff {.,../overlay}/overlay.h
      29,31c29,31
      < #define MAX_CHAINS    10000
      < #define MAX_VERTS 100000
      < #define MAX_EDGES 100000
      ---
      > #define MAX_CHAINS    1000
      > #define MAX_VERTS 2000
      > #define MAX_EDGES 2000
      34c34
      < #define MAX_XSECTS 100000     /* Max number of intersections */
      ---
      > #define MAX_XSECTS 1000               /* Max number of intersections */

   so this whole directory can be deleted.  county.hydrog.out is the
   record of the big run, so keep it.

8. Redo timing tests for CAGIS paper, 1/94.  Enlarge sizes and
turn off debugging.
