Skip to content
  • Russ Fish's avatar
    Add MapQuest-style pan and zoom controls to the floormap.php3 page, and · aa7d57a9
    Russ Fish authored
    generally improve the clarity and appearance of the maps.  The scale factor
    buttons numbered 1-5 actually correspond to scale factors of 1, 1.5, 2, 2.5,
    and 3.
    
    Notice that the floorimages table in the database now has an integer "scale"
    column to distinguish the cached zoomed-in images with a suffix "-[1-5].jpg" .
    
    I use jpeg files instead of the png files that were used before.  They look as
    good or better, and are a third the size.  Panning around at a given zoom
    factor just involves cropping out a different rectangle of the scaled-up
    images.
    
    The 0311X064_[1-4]fl.pdf floor map files we got from Michael Kay started
    out life in Adobe Illustrator.  Although GhostScript/gv crash while
    trying to draw the pdf files, extracting them into PostScript files in
    Acrobat on Coke allows GhostScript to render them flawlessly.
    
    I started out using gs to render jpeg files in the shell, and then
    found that ImageMagick uses the same GhostScript renderer, and nicely
    handles cropping, drawing and annotations, and format conversion as well.
    
    The PostScript rendering gets slow at higher zoom factors.  So I cache the
    zoomed floor images, scaled up by rendering the PostScript files at a finer
    dot-pitch (density) in GhostScript, and then cropping out the right rectangle
    to register them properly.
    
    For readability, and to avoid having the thin lines and bitmap fonts used in
    some parts of the PostScript map from falling between the pixel cracks, I
    actually render at twice the pixel density and filter down to the final image
    with a gaussian -sharpen option to keep it from looking blurry.
    
    ImageMagick is callable from both the shell and as the Image::Magick package
    in Perl.  I converted the Perl logic in floormap.in to use Image::Magick
    instead of the GD graphics library, resulting in anti-aliased (smoothed)
    drawing of the wireless node dots and labels on floor maps for a better
    appearance.  Then I added optional scaling and centering arguments which
    select the proper cached zoomed-in image, and drive the logic for cropping and
    drawing.
    
    I modified the floormap.php3 file to wrap an input form around a set of zoom
    control buttons and the floormap image.  The zoom buttons set the scale
    argument to the Perl floormap script called on the server.  The floor map
    image itself is wrapped in a graphical submit button, so clicking on it
    returns the mouse coordinates within the image, which are then sent to the
    centering argument of the Perl script.
    aa7d57a9