Documentation
Code layout
The actual IvyGIS code is in the directory $FGS_HOME/apps/ivygis_demo;
the package also includes
  • Rails
  • Ruby Mapscript
  • The following miscellaneous Ruby Gems:
    • gd2
    • ruby-postgres
Demo applications
The quickest way of approaching this code, at this point, may be to read through the implementations of the demo applications, particularly the "Interactive Map of Canada" demo, which has comments which are intended to point you in useful directions.
See also the framework code in lib/IvyGIS, which has comments on usage.

"Map of Canada"
As mentioned above, the raw data for this demo is included in db/geodata, and loaded into the database by some of the migrations in db/migrate.

A request for "/canada" is delegated to the "canada_controller", in app/controllers/canada_controller.rb; this, in turn, serves the index view, in app/views/canada/index.rhtml.

This controller also handles requests for graphics on parks and railroads. The way it works is that the Javascript sends in a request for, say, http://localhost:3000/canada/park_graphics?... (with a fairly long list of parameters). This request is handled by the "park_graphics" method of the "canada" controller. That, in turn, handles it by retrieving model objects of class "Park" (see app/model/park.rb), and feeding them to the view in app/views/canada/park_graphics.rxml

The graphical data for the demo resides in PostGIS; it gets loaded in by the scripts in db/geodata, which are the output of shp2pgsql with some very minor hand editing. (I changed the primary key from "gid" to "id" to match Rails conventions). See also migrations 12 and 13 in the directory db/migrate, which arrange to load this stuff in when you type "rake migrate" to set up the demo.

Restaurant reviews
The simplest example of the "post-it notes" code is restaurant reviews. To study:
db/migrate/007*,010*
Set up the restaurant_reviews table
app/models/restaurant_review.rb
Restaurant review objects. The most important code here is find_by_list_params, which retrieves all reviews in a specified region of the map.
app/controllers/restaurant_review_controller.rb
Controller for "restaurant review" requests. Note that this ties in to a fairly generic user-accounting and privilege system, which I'm not describing here.
app/views/restaurant_review/*
Views for restaurant reviews. HTML for display and editing. Also query_form.rhtml, which shows up on the main map page
public/javascripts/ivy_restaurants.js
Javascript support for restaurant queries; mainly handlers for the query_form.
public/stylesheets/ivy_restaurants.css
A few simple style rules. Mainly has to do with not showing editing operations to users who aren't allowed to edit reviews.
Framework code --- vendor/plugins/ivygis_engine/...
At this point, the most detailed documentation on the framework is the code itself. This code has been separated out into a Rails "plugin", to allow it to be easily reused in Rails applications other than the demos. The plugin resides in ./vendor/plugins/ivygis_engine; the following pathnames are all relative to that directory:
lib/IvyGIS/*
Ruby code implementing much of the GIS functionality. This includes interfacing to the database, SVG and VML graphics generation, and other "helpers" which generate HTML which works well with the Javascript code.
public/javascripts/ivy_*.js
The Javscript side of things. Includes code to generate tiled maps, and manage graphic and HTML overlays on top of them. A few of these are specific to the demo apps. The general ones are:
public/javascripts/ivy_map.js
Basic tiled map support.
public/javascripts/ivy_svg_overlay.js
SVG (or VML) graphical overlays.
public/javascripts/ivy_notes.js
Support for "post-it notes" on maps, keyed to specific points. Multiple types of notes are supported, and two types are included in the demo app --- restaurant reviews, and generic notes with flickr-style "folksonomy" tags. More can be added; you just need a back-end table, and a controller which supports a "list_json" request to list available notes in json format, and a "show" request to produce the text of a specific note. For more, including support for editing and composing notes, see the restaurant code, q.v. below.
public/javascripts/ivy_{tooltipper,notifier}.js
Useful infrastructure support --- mouse-following tooltips, and support for "pseudo-events" like user login/logout.
public/stylesheets
CSS required to make this stuff all display correctly. Included by map views like app/views/main/index.rhtml, etc.
app/models/{abstract,image,map}_tiler.rb
Generating map tiles. The map_tiler does it by talking to MapServer. The image_tiler does it by carving up raster images that you supply directly --- which can be handy if you want to annotate, say, the data at "http://www.mapofspringfield.com/". But beware --- this has not been tuned for really large images, and performance may be bad if you try that. Configuration for these is in config/environment.rb; for reference info, see README.config in this directory.
Other files to read
app/controllers/application.rb
This file defines methods which are available to all controllers in a Rails application. (Controllers are code which handle web requests. They work by finding or creating "model" objects, and then formatting the output by using an appropriate "view").

Of note here is the "located_items_of_class" method, which is used by several of the demo "post-it note" controllers to encapsulate logic which they all share.

db/migrate
The actual code run by "rake migrate" to set up the database. As you can see, this consists of a set of "migrations", each of which encapsulates a change to the database. The definitions included with this code set up the tables for the demo apps.
db/geodata
Source data for the railroads and parks of Canada. These are almost exactly what you get from running shp2pgsql -I on the shape files from the demo data. I've made two changes: the primary key on the tables is called "id" and not "gid", to match Rails conventions. Also, shp2pgsql mangles the names of two Quebecois railroads which include French accents; the data included here is less incorrect.