Maa123.490 Programming in GIS - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Maa123.490 Programming in GIS

Description:

2. Go to the widget, where the event occurred. 3. A generic 'event' ... The widget sends the signal to the function(s) which is connected for the given signal ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 34
Provided by: Rev147
Category:

less

Transcript and Presenter's Notes

Title: Maa123.490 Programming in GIS


1
Maa-123.490 Programming in GIS
  • Lecture 3
  • Application development and GUI programming

2
Some things from prev. lectures
  • Istvans web-page ripping
  • want to rip place names and numbers
  • complicated HTML but all needed data seems to
    be on one line
  • path to solution split the complex problem into
    two simple problems
  • rip into an array all items that look like
    numbers _at_a _ /(\d\\-\.)/g
  • rip into a variable the place name if
    (/cell\gt(\w)/) n 1
  • combine and enjoy

3
OGR
  • GDALs sister, for accessing and manipulating
    vector data
  • Datasource
  • 1 Layer
  • 1 LayerDefn
  • 1 Feature
  • 1 Geometry
  • 1 Point (polygons have Rings)
  • 1 Field

4
OSR
  • SpatialReference
  • WGS84, EPSG, ...
  • CoordinateTransformation
  • GeometryTransform

5
Application development
  • Software projects
  • Files
  • program build process
  • version control systems
  • internationalization (i18n)
  • Graphics
  • Gtk2ExGeo

6
Files
  • basic documentation
  • who made this, change log, how to install, how to
    compile, general info, ...
  • for sysadmins
  • for developers
  • for those building extensions
  • for ordinary users
  • licence
  • installation scripts and templates

7
More files
  • source code
  • header files, code files
  • resource files
  • user interface
  • icons and images
  • definitions
  • Schemas, Parsers,
  • documentation
  • user manual

8
Program build process 1/2
  • from developer to distribution
  • for example generate parser code, generate
    configuration script
  • configuration
  • what is this system?
  • what is and what isnt available on this system?
  • perl Makefile.pl or ./configure
  • compilation
  • create machine instruction code and link it
    together as dynamically linkable libraries and/or
    executables
  • make

9
Program build process 2/2
  • testing
  • is the code working as supposed (on this system)?
  • make test
  • install
  • Place the library, executable, documentation, and
    development support files in their correct places
    (may have been defined in the configuration step)
  • make install

10
Distribution files
  • Source code package
  • includes all files mentioned on two previous
    slides
  • .tar.gz, .zip
  • Compiled package
  • Includes some of the files mentioned on the two
    previous slides
  • .msi, .rpm, .deb

11
Version control
  • Scenario
  • Several developers working on single software
    project
  • Code is written, bugs are found and corrected,
    new features are added, this happens continuously
  • Project needs one authoritative source tree
  • Debugging may require going back to old versions
  • Branching

12
Internationalization
  • Requiring people to learn english in order to use
    a computer is wrong and absurd
  • Internationalization is hard
  • Technical aspects
  • Character set, date format, decimal point ,
    currency, sorting,
  • Practical aspects
  • Language,
  • Cultural aspects
  • Fonts, colors,

13
Graphics issues in geoinformatics
  • Graphics display is (in practise) always to a
    raster display

14
GIS graphics pipeline, from geodata..
geodata - rasters - objects
overlay process - coordinates - order - opacity
rendering - colors - fonts - line widths ...
15
.. to display buffer and/or screen
display buffer
window on screen
16
Using graphics in your own programs
  • ..own programs with a GUI
  • GUIs
  • GUI toolkits
  • digging in

17
GUI
  • Graphical User Interface
  • a method of interacting with a computer through a
    metaphor of direct manipulation of graphical
    images and widgets in addition to text
  • pros you see what you have
  • cons the freedom that is easy to achieve in CLI
    is very hard in GUI
  • CLI command line interface

18
Widgets
  • Graphical component or control
  • button, check-box, radio button, combo box, icon,
    input field, tooltip, scrollbar, status bar,
    toolbar, menu (different types), window
    (different types)
  • widget toolkits
  • application ? its graphical appearance

19
Architecture
Look feel, inter- operability
Desktop environment window manager
Mac OS X, GNOME, KDE
Widget toolkit(s)
functionality
MacApp, MFC, Motif, GTK
Graphics/Window system
hardware abstraction
Windows
X
OS kernel
GNU
processing
Linux
devices
20
GTK
  • A multi-platform toolkit for GUIs (widget
    toolkit)
  • basis of GNOME
  • used by, e.g., Dia and GIMP
  • based on
  • Glib low-level core library
  • Pango library for layout and rendering of text
  • ATK accessibility library
  • written in C/C but with, e.g., Perl and Python
    in mind
  • Glade GUI for developing GUIs with GTK

21
Simplest possible GTK-Perl application
  • use Gtk2 '-init'
  • my window Gtk2Window-gtnew
  • window-gtshow_all
  • Gtk2-gtmain

make the window visible
go into the event loop
22
Events, signals
  • 1. User interacts with the application
  • 2. Go to the widget, where the event occurred
  • 3. A generic event signal is sent
  • if that signal handler returns TRUE, stop
  • 4. A specific event, e.g., button_press_event is
    sent
  • if that signal handler returns TRUE, stop
  • 5. Go to the widgets parent widget and repeat
    from 3. or give up if this is the top level widget

23
Notes, callbacks
  • Not all widgets can receive events
  • Parent is the widget in which the child is placed
  • The widget sends the signal to the function(s)
    which is connected for the given signal
  • user supplied callback possibly a default
    handler

24
our first callback
the widget to which we connect this callback
  • window-gt
  • signal_connect (
  • "destroy",
  • sub exit(0)
  • )

the method, common to all widgets
the signal
the callback anonymous function
25
our second callback
  • my event_box Gtk2EventBox-gtnew
  • event_box-gtsignal_connect(
  • button_press_event gt \button_press_event)
  • event_box-gtadd(image)
  • sub button_press_event
  • my (widget,event) _at__
  • print event-gtx," ",event-gty,"\n"

image cannot receive events
26
GUI design
  • Glade
  • glade-2
  • use Gtk2 '-init'
  • use Gtk2GladeXML
  • Gtk2GladeXML-gtnew("gui4.glade")
  • Gtk2-gtmain

27
Gtk2ExGeo project
  • Put geodata to a GTK widget
  • Current design (next page)
  • Gtk2ExGeoGlue
  • implement simple basic functionality with other
    Gtk2ExGeo modules other Gtk2 widgets
  • basic functionality comes from libral, which is a
    C library

28
Gtk2ScrolledWindow
Gtk2GdkPixbuf
Gtk2ExGeoOverlay
Gtk2ExGeoRenderer
Layer (abstract)
GeoRaster
GeoVector
Gtk2ExGeoComposite
ogr
gdal
29
libral
  • code for simple in-memory vector data
  • simple rendering
  • import from ogr (one feature at a time)
  • code for simple in-memory raster data
  • integer and real rasters
  • raster algebra
  • import from gdal (a viewport)
  • code for rendering vector and raster data onto a
    GDK style pixbuf

30
GeoRaster
  • Perl interface to a libral raster
  • raster algebra overlayed
  • a b is a raster if a and/or b is a raster
  • implements the abstract class / interface Layer
  • does not inherit from gdal, may contain a gdal
    object

31
GeoVector
  • implements the abstract class / interface Layer
  • contains an ogr object
  • has a rasterize method, which returns a
    GeoRaster

32
Gtk2ExGeoComposite
  • Three GeoRasters for colored images other than
    by color palettes

33
Exercise
  • to be decided on lecture
  • use some widget?
  • implement better open vector data dialog box?
  • implement an analysis tool?
Write a Comment
User Comments (0)
About PowerShow.com