/[thuban]/branches/WIP-pyshapelib-bramz/Doc/manual/thuban-manual.xml
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Doc/manual/thuban-manual.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1533 by jonathan, Thu Jul 31 12:43:27 2003 UTC revision 2727 by bernhard, Tue Feb 20 10:44:51 2007 UTC
# Line 2  Line 2 
2  <!DOCTYPE book  <!DOCTYPE book
3          PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"          PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4          "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"          "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
5      [<!ENTITY imgscale "70">]>      [<!ENTITY imgscale "60">]>
6  <!-- $Revision$ -->  <!-- $Revision$ -->
7  <book>  <book>
8    <bookinfo>    <bookinfo>
9      <title>Thuban Manual</title>      <title>User's Manual for Thuban 1.2 (Draft)</title>
10      <author>          <authorgroup>
11        <firstname>Jonathan</firstname><surname>Coles</surname>        <author>
12      </author>          <firstname>Jonathan</firstname><surname>Coles</surname>
13      <author>        </author>
14        <firstname>Jan-Oliver</firstname><surname>Wagner</surname>        <author>
15      </author>          <firstname>Jan-Oliver</firstname><surname>Wagner</surname>
16      <author>        </author>
17        <firstname>Frank</firstname><surname>Koormann</surname>        <author>
18      </author>          <firstname>Frank</firstname><surname>Koormann</surname>
19          </author>
20            </authorgroup>
21      <copyright>      <copyright>
22        <year>2003</year>        <year>2003, 2004, 2005, 2006, 2007</year>
23        <holder>Intevation GmbH</holder>        <holder>Intevation GmbH</holder>
24      </copyright>      </copyright>
25       <revhistory>
26    <!-- comment this first revision out when releasing a real version -->
27    <!--
28         <revision>
29            <revnumber>SVN version $Id$</revnumber>
30            <date></date>
31            <revremark>Under development.</revremark>
32         </revision>
33    -->
34         <revision>
35            <revnumber>1.2.0</revnumber>
36            <date>20-Feb-2007</date>
37            <revremark>
38                            Removed all installation instructions in favor
39                            of a link to the website. It is not wise to
40                            double the README contents here.
41                    </revremark>
42         </revision>
43         <revision>
44            <revnumber>1.0.0</revnumber>
45            <date>22-Jan-2004</date>
46            <revremark>
47                            Corresponds to Thuban 1.0.0.
48                            New: Installation instructions for Win32.
49                    </revremark>
50         </revision>
51         <revision>
52            <revnumber>1.0pre3</revnumber>
53            <date>04-Dec-2003</date>
54            <revremark>
55                            Corresponds to Thuban 1.0rc1.
56                            New: I18n, right button legend menu, EPSG projectons,
57                PostGIS support.
58                    </revremark>
59         </revision>
60         <revision>
61            <revnumber>1.0pre2</revnumber>
62            <date>29-Aug-2003</date>
63            <revremark>
64                            Corresponds to Thuban development release 0.8.1.
65                            New: chapter on extensions.
66                    </revremark>
67         </revision>
68         <revision>
69            <revnumber>1.0pre1</revnumber>
70            <date>08-Aug-2003</date>
71            <revremark>Corresponds to Thuban development release 0.8.1.</revremark>
72         </revision>
73      </revhistory>
74    
75    </bookinfo>    </bookinfo>
76    
77    <chapter><title>Introduction</title>    <chapter><title>Introduction</title>
78      <para>      <para>
79      Thuban is a Free Software Geographic Information Systems (GIS) viewer.      Thuban is an interactive geographic data viewer.
80      It is being developed because there is currently no simple interactive      Its development had been started because there was no simple interactive
81      viewer for geographic information available as Free Software. Thuban is      viewer for geographic information available as Free Software. Thuban is
82      written in Python and C++ and uses the wxWindows library allowing it to      written mainly in Python and uses the wxWidgets (former wxWindows)
83        library allowing it to
84      run on many different platforms, including GNU/Linux and Windows.      run on many different platforms, including GNU/Linux and Windows.
85      </para>      </para>
86      <para>      <para>
87      GIS viewers are a necessary tool as they allow one to get a visual      Geographic data viewers are a necessary tool as they allow one to
88            get a visual
89      impression of the positional relationship of the information that may not      impression of the positional relationship of the information that may not
90      be apparent from simple inspection of the data values themselves.      be apparent from simple inspection of the data values themselves.
91      Thuban allows the user to create a session that displays      Thuban allows the user to create a session that displays
# Line 40  Line 94 
94      </para>      </para>
95      <para>      <para>
96      Thuban arranges a session in a hierarchy. A session contains a map which      Thuban arranges a session in a hierarchy. A session contains a map which
97      consists of layers. Each layer represents one kind of data set. For      consists of layers. Each layer represents a data set. For
98      instance, there may be a layer for roads and another layer for buildings.      instance, there may be a layer for roads and another layer for buildings.
99      These layers can either be vector shapes or images.      These layers can either be vector shapes or images.
100      </para>      </para>
101    
102          <section><title>Installation</title>          <section><title>Installation</title>
103          <para>          <para>
104          Thuban is actively supported under Debian Testing (sarge), RedHat 7.2,          Thuban is actively supported under Debian 4.0 (Etch)
105          and Windows 2000. Thuban depends on the following packages. These          and Windows (XP). Of course it is possible to run Thuban
106          packages can also be found on the          on a variety of other platforms.
107          <ulink url="http://thuban.intevation.org/download.html">  
108          Thuban Download site          Please check <ulink url="http://thuban.intevation.org/">
109          </ulink>.          Thuban's Website
110          <itemizedlist>          </ulink> about how to install Thuban and the lastest information
111              <listitem><para>Python 2.2.1 (<literal>http://www.python.org</literal>)</para></listitem>          about the supported platforms.
112              <listitem><para>wxWindows 2.4 (<literal>http://www.wxwindows.org</literal>)</para></listitem>          </para>
             <listitem><para>wxPython 2.4 (<literal>http://www.wxpython.org</literal>)</para></listitem>  
             <listitem><para>proj 4.4.5 Projection Library (<literal>http://www.remotesensing.org/proj/</literal>)</para></listitem>  
             <listitem><para>GDAL 1.1.8 (<literal>http://www.remotesensing.org/gdal/</literal>)</para></listitem>  
             <listitem><para>SQLite 2.8.3 (<literal>http://www.hwaci.com/sw/sqlite/</literal>)</para></listitem>  
             <listitem><para>PySQLite 0.4.3 (<literal>http://pysqlite.sourceforge.net</literal>)</para></listitem>  
             </itemizedlist>  
         </para>  
113          </section>          </section>
114    
115            <section><title>Internationalization</title>
116            <para>
117            Thuban is implemented with internationalization support. So far Thuban
118            is translated by volunteers to the following languages (apart from its
119            main language: English):
120            <itemizedlist>
121                <listitem><para>French</para></listitem>
122                <listitem><para>German</para></listitem>
123                <listitem><para>Italian</para></listitem>
124                    <listitem><para>Portuguese (Brazilian)</para></listitem>
125                <listitem><para>Russian</para></listitem>
126                <listitem><para>Spanish</para></listitem>
127            </itemizedlist>
128            </para>
129    
130            <para>
131            To use internationalization under POSIX systems (like GNU/Linux)
132            you have to set the environment variable LC_ALL accordingly (e.g.
133            LC_ALL=fr_FR for the french language support). Please check your
134            systems documentation for details and supported settings.
135            Specifiying LC_ALL on the command line while launching thuban
136            allows appication specific language settings:
137            </para>
138            <programlisting>
139            LC_ALL=fr_FR thuban.py
140            </programlisting>
141    
142            <para>
143            MS Windows users have to specify the language to be used via the control
144            bar (which effects all applications).
145            </para>
146            </section>
147    
148          <section><title>The Main Window</title>          <section><title>The Main Window</title>
149          <para>          <para>
150          <figure>          <figure>
# Line 129  Line 209 
209          If a session is already loaded and has been modified without          If a session is already loaded and has been modified without
210          being saved a prompt will ask if the current session should          being saved a prompt will ask if the current session should
211          be saved. A new session consists of an empty map with no          be saved. A new session consists of an empty map with no
212          layers and no tables.          layers, no tables and no projection.
213          </para>          </para>
214          </section>          </section>
215    
# Line 143  Line 223 
223          for a Thuban Session file. Thuban session files end with          for a Thuban Session file. Thuban session files end with
224          <varname>.thuban</varname>. Selecting a file a clicking          <varname>.thuban</varname>. Selecting a file a clicking
225          <guibutton>OK</guibutton> will load the session into Thuban.          <guibutton>OK</guibutton> will load the session into Thuban.
226                    </para>
227    
228                    <para>
229          If a session is already loaded and has been modified without          If a session is already loaded and has been modified without
230          being saved a prompt will ask if the current session should          being saved a prompt will ask if the current session should
231          be saved.          be saved.
232          </para>          </para>
233                    
234                    <para>
235                    Thuban provides a path recovery feature: If a (shape) file referenced
236                    in a Thuban session cannot be found at the specified location, the user
237                    is prompted a file dialog. Here a new location can be selected for the
238                    currents layer data source. Cancelling the dialog removes the layer
239                    from the session. If a new location has been selected, Thuban checks
240                    this again, if further layers data sources are missing. The user is
241                    informed about this and can accept or cancel the suggestion.
242            </para>
243          </section>          </section>
244    
245          <section><title>Saving a Session</title>          <section><title>Saving a Session</title>
# Line 156  Line 248 
248          <menuchoice>          <menuchoice>
249          <guimenu>File</guimenu>          <guimenu>File</guimenu>
250          <guimenuitem>Save Session</guimenuitem>          <guimenuitem>Save Session</guimenuitem>
251          </menuchoice>. A dialog box will open allowing the user to browse          </menuchoice>.
252                    In the case the session is not a new and unsaved one,
253                    the corresponding file is updated with the current session
254                    data.
255                    In the case the current session is a new one and yet unsaved
256                    a dialog box will open allowing the user to browse
257          the file system and select a place to save the session. Thuban          the file system and select a place to save the session. Thuban
258          sessions should be saved under a name ending in          sessions should be saved under a name ending in
259          <varname>.thuban</varname>. If the file already exists the user          <varname>.thuban</varname>. If the file already exists the user
# Line 215  Line 312 
312    
313          <section><title>Adding and Removing Layers</title>          <section><title>Adding and Removing Layers</title>
314          <para>          <para>
315          There are two types of layers that can be added to a map: shape layers          There are three types of layers that can be added to a map:
316            Shape layers, database layers
317          and image layers. Shape layers are stored in Shapefile format, a          and image layers. Shape layers are stored in Shapefile format, a
318          standard file format for storing geographic objects. These          widely used file format for storing geographic objects. These
319          files have the extension ``.shp''. Associated with          files have the extension ``.shp''. Associated with
320          the shape file is a database file which stores attributes for          the shape file is a database file which stores attributes for
321          each shape in the shape file. This file, in dBase format,          each shape in the Shape file. This file, in dBase format,
322          has the extension ``.dbf''. Both files must have the same base name.          has the extension ``.dbf''. Both files must have the same base name.
323          For example, if there is a shape file named roads.shp there must          For example, if there is a shape file named roads.shp there must
324          also be a file roads.dbf.          also be a file roads.dbf.
325          </para>          </para>
326          <para>          <itemizedlist>
327            <listitem>
328            <para>
329          Shape layers can be added to the map with          Shape layers can be added to the map with
330          <menuchoice>          <menuchoice>
331          <guimenu>Map</guimenu>          <guimenu>Map</guimenu>
332          <guimenuitem>Add Layer</guimenuitem>          <guimenuitem>Add Layer</guimenuitem>
333          </menuchoice>.          </menuchoice>.
334          Thuban will load all files with the same base name, so it doesn't          Initially, only the ``.shp'' files are shown which is enough for the
335          matter if the shape file or database file is selected.                  selection. However, if you switch to display all files and select one
336                    of the associated files (e.g. ``.dbf''), Thuban will recognize the base
337                    name and load the corresponding Shape file.
338            </para>
339                    <para>
340                    The file dialog for Shape files allows to select multiple files.
341                    Use the shift-button together with the left mouse button to extend
342                    the selection.
343          </para>          </para>
344            </listitem>
345    
346            <listitem>
347            <para>Database layers can be added to the map with
348            <menuchoice>
349            <guimenu>Map</guimenu>
350            <guimenuitem>Add Database Layer</guimenuitem>
351            </menuchoice>.
352            A dialog with two lists is opened. The left list displays all
353            database connections currently open for the session. You can retrieve
354            a list of available layers from the selected database which is
355            displayed on the right hand. From this list one layer can be selected,
356            the dialog is closed afterwards.
357            </para>
358            <para>
359            See appendix ``Working with PostGIS'' for details.
360            </para>
361            </listitem>
362    
363            <listitem>
364          <para>          <para>
365          Image layers can be added to the map with          Image layers can be added to the map with
366          <menuchoice>          <menuchoice>
# Line 246  Line 372 
372          or in another file. If geographic information cannot be found, Thuban          or in another file. If geographic information cannot be found, Thuban
373          will report an error.          will report an error.
374          </para>          </para>
375            </listitem>
376            </itemizedlist>
377          </section>          </section>
378    
379          <section><title>Navigation</title>          <section><title>Navigation</title>
# Line 537  Line 665 
665          </para>          </para>
666          </listitem>          </listitem>
667          </itemizedlist>          </itemizedlist>
668    
669            <para>
670            The most used layer related actions are also available from a
671            popup menu. It is raised when a layer is clicked with the right mouse
672            button.
673            </para>
674            
675            <para>
676            <figure>
677            <title>Layer Popup Menu</title>
678            <mediaobject>
679            <imageobject><imagedata fileref="../images/3_5_popup_menu.png" format="PNG" scale="&imgscale;"/></imageobject>
680            <imageobject><imagedata fileref="./images/3_5_popup_menu.eps" format="EPS" scale="&imgscale;"/></imageobject>
681            </mediaobject>
682            </figure>
683            </para>
684    
685          <para>          <para>
686          Along the bottom of the legend is the scalebar. The scalebar          Along the bottom of the legend is the scalebar. The scalebar
687          will be available if there are any layers and the  map has a          will be available if there are any layers and the  map has a
# Line 581  Line 726 
726    
727          <section><title>Types of Layers</title>          <section><title>Types of Layers</title>
728          <para>          <para>
729          There are two types of layers supported by Thuban: shape layers and          There are three types of layers supported by Thuban: shape layers,
730            database layers and
731          image layers. Shape layers consist of vector based shapes with          image layers. Shape layers consist of vector based shapes with
732          geo-referenced coordinates. There are three types of supported          geo-referenced coordinates. There are three types of supported
733          shapes: polygons, lines (arc), and points. Image layers can be any image          shapes: polygons, lines (arc), and points. Database layers are similar
734            to shape layers but loaded from a database instead of the file system.
735            Image layers can be any image
736          file format supported by the Geo-spatial Data Abstraction Library          file format supported by the Geo-spatial Data Abstraction Library
737          (GDAL). The images must have geographic          (GDAL). The images must have geographic
738          coordinate data either embedded within the file or in a separate          coordinate data either embedded within the file or in a separate
# Line 769  Line 917 
917          <section><title>Value</title>          <section><title>Value</title>
918              <para>              <para>
919              The Value column of the classification table is the value that will              The Value column of the classification table is the value that will
920              be matched when the map is being drawn. The type of data that can              be matched when the map is being drawn. The type of filter that can
921              entered into this field depends on the type of data of the              entered into this field depends on the type of data of the
922              classification field.              classification field:
923              </para>              </para>
924              <para>              <para>
925              If the field is of type Text, anything entered              If the field is of type Text, anything entered
926              into the field is valid. The text will be compared literally to the              into the field is valid. By default the text will be compared
927              value of the shape attribute, including case sensitivity.              literally to the
928                value of the shape attribute, including case sensitivity.
929                Alternatively the comparison can be based on regular experessions.
930                Right-click on the row label to open a popup menu with the options
931                <guibutton>Singleton</guibutton> (literal comparison) and  
932                <guibutton>Pattern</guibutton> (regular expressions).  
933                </para>
934                <para>
935              If the type is Integer, then any valid integer may be entered. In              If the type is Integer, then any valid integer may be entered. In
936              addition, with special syntax, a range of values can be entered.              addition, with special syntax, a range of values can be entered.
937              A range from <varname>start</varname> to <varname>end</varname>              A range from <varname>start</varname> to <varname>end</varname>
# Line 787  Line 942 
942              Decimal. They represent any rational number and can be used in              Decimal. They represent any rational number and can be used in
943              ranges as well.              ranges as well.
944              </para>              </para>
945              </section>         </section>
946              <section><title>Label</title>              <section><title>Label</title>
947              <para>              <para>
948              By default, the text that is displayed for a group in the legend              By default, the text that is displayed for a group in the legend
# Line 916  Line 1071 
1071      </figure>      </figure>
1072      </para>      </para>
1073      <para>      <para>
1074      Thuban is distributed with a sample collection of projections. The      Thuban is distributed with a sample collection of projections and the
1075        set of coordinate systems as used by the EPSG
1076        (European Petroleum Survey Group). This quite large set is only displayed
1077        if activated by the according checkbox. The set falls into two parts:
1078        deprecated lists all projections which are no longer part of the
1079        EPSG data base.
1080        </para>
1081        <para>
1082             The
1083      user can create new projections and make them available to all      user can create new projections and make them available to all
1084      future Thuban sessions. They may also be exported and imported so      future Thuban sessions. They may also be exported and imported so
1085      that custom projections can be distributed.      that custom projections can be distributed.
# Line 1196  Line 1359 
1359      </section>      </section>
1360    </chapter>    </chapter>
1361    
1362      <chapter><title>Extensions</title>
1363            <para>
1364            Thuban is designed to be extensible. The term Extension is used as a
1365            general term for anything that extends Thuban.
1366            This chapter introduces into some oppportunities how to add and
1367            handle extra functionality developed by your own or third parties.
1368            </para>
1369    
1370            <section><title>Add personal extensions via thubanstart.py</title>
1371                    <para>
1372                    After Thuban has been started for the first time, a directory
1373                    .thuban is created within your home directory.
1374                    There you can add a file thubanstart.py  which will be imported
1375                    by Thuban at start-up. It is recommended to add only import-statements
1376                    to this file to keep the actual code of extensions separate.
1377                    </para>
1378                    <para>
1379                    The modules to import must either be found through the environment
1380                    variable PYTHONPATH or directly be placed into the .thuban-directory.
1381                    </para>
1382                    <para>
1383                    As an example, copy the file examples/simple_extensions/hello_world.py
1384                    of the Thuban source code into the .thuban-directory of your home
1385                    directory. Now add add the statement import hello_world to the
1386                    file thubanstart.py and run Thuban. You will notice an additional
1387                    menu <menuchoice><guimenu>Extensions</guimenu></menuchoice> where
1388                    the new item for the Hello-World extension is placed - select it
1389                    to see the Hello-World message.
1390                    </para>
1391            </section>
1392    
1393            <section><title>Extensions included in Thuban package</title>
1394                    <para>
1395                    The extensions described in this section are part of the
1396                    Thuban package, but not activated by default.
1397                    You will find them in the Thuban installation directory
1398                    under <literal>Extensions/</literal>. Activate them as personal
1399                    extensions via PYTHONPATH as described in the previous section.
1400                    Stable extensions will appear under the menu
1401                    <menuchoice><guimenu>Extensions</guimenu></menuchoice> and
1402                    extensions which are in experimental state and therefore
1403                    not fully functional under
1404                    <menuchoice><guimenu>Experimental</guimenu></menuchoice>.
1405                    </para>
1406    
1407                    <section><title>Stable extensions</title>
1408                        <para>
1409                        These extensions provide extra-functionality to Thuban
1410                        that has not (yet) been integrated in the main application.
1411                        They are considered to be free of bugs, but may be
1412                        further polished with helpful user interactions.
1413                        </para>
1414                        <section><title>gns2shp</title>
1415                                    <para>
1416                                    This tool converts data of the Geospatial Names Server
1417                                    (GNS, see <ulink url="http://www.nima.mil/gns"/>)
1418                                    into Shapefile format.
1419                                    The above web-site offer to download named places
1420                                    information grouped by countries for all of the world
1421                                    except USA for which other data are provided.
1422                                    </para>
1423                                    <para>
1424                                    If you download and unpack a package, you will have
1425                                    a text-file with suffix .txt.
1426                                    Selecting such a file via gns2shp will create the
1427                                    corresponding Shapefile with the same basename and
1428                                    place it in the same direcory. Afterwards it
1429                                    is automatically loaded into Thuban.
1430                                    The Shapefile will not automatically be delete afterwards.
1431                                    </para>
1432                                    <para>
1433                                    The gns2shp.py module can also be executed on the
1434                                    command line for batch processing purposes.
1435                                    </para>
1436                                    <para>
1437                                    A sample (<literal>ls.txt</literal> for Liechtenstein)
1438                                    is included in the directory
1439                                    <literal>Extensions/gns2shp/test</literal>.
1440                                    </para>
1441                        </section>
1442                        <section><title>SVG Export</title>
1443                            <para>
1444                            Map and legend can be exported separately in the
1445                            Thuban-Map-SVG format.
1446                            You get files that comply with
1447                            the Scalable Vector Graphics (SVG) 1.1 Specification
1448                            and can be read by many vector drawing applications.
1449                            </para>
1450                            <para>
1451                            Goal of svgexport is to provide
1452                            the start of a printing pipeline for Thuban.
1453                            For this purpose the written Thuban-Map-SVG files
1454                            contain information that can be used in postprocessing.
1455                            Typically a general vector drawing application is
1456                            more powerful then a geographic information viewer;
1457                            e.g. having much fancier symbols and fonts.
1458                            Also users benefit much more when learning to use a
1459                            more general application they can also use for other
1460                            tasks.  So the charming idea is to enable
1461                            the drawing application to postprocess a Thuban maps.
1462                            So thee xtra information in the format will make it
1463                            possible to export from Thuban and if a few geoobjects
1464                            change, and keep the general layout and style
1465                            of the full map in the vector drawing appplication.
1466                            </para>
1467                            <para>
1468                            Markus Rechtien has developed a prototype of this
1469                            printing pipline as his Diplom thetis, showing
1470                            the feasability of Bernhard Reiter's concept.
1471                            Scripts exist for the drawing application Skencil
1472                            (<ulink url="http://www.skencil.org"/>).
1473                            </para>
1474                            <para>
1475                            Technical notes: the names of the layers are used
1476                            as base for ids within the SVG format.
1477                            If you try to export with two layers having
1478                            the same name, you will get a name clash error.
1479                            Just change one of the layer names and try again.
1480                            </para>
1481                        </section>
1482                    </section>
1483                    <section><title>Experimental extensions</title>
1484                            <para>
1485                            All all of these functions have to be handled with care,
1486                            since they are neither complete nor well tested.
1487                            They are to be seen as a proof-of-concept and may
1488                            additionally in some cases of practical help.
1489                            </para>
1490                            <para>
1491                            Any interest on further improvement of these extensions
1492                            should be communicated towards the developer and user
1493                            community.
1494                            </para>
1495    
1496                            <section><title>importAPR</title>
1497                                    <para>
1498                                    This command offer to load an ESRI� ArcView� project
1499                                    file (suffix .apr) and convert it for use within Thuban.
1500                                    After selecting a apr-file to load, a list
1501                                    will be presented that offers to select one of the views
1502                                    of the apr-file, provided there is more than one.
1503                                    Furthermore, the Session Info-Tree is extended with
1504                                    a complete representation of the parsed apr-file.
1505                                    </para>
1506                                    <para>
1507                                    The legend of Thuban does not yet cover all of the elements as
1508                                    supported by the legend of ArcView�. Therefore, the Thuban
1509                                    map will look different. Furthermore, the apr-format is
1510                                    a proprietary format, not openly documented.
1511                                    Therefore, the interpretation is
1512                                    partly based on reverse engeneering and good guessing.
1513                                    </para>
1514                                    <para>
1515                                    The file-paths within the apr-file may not fit and potentially
1516                                    are subject to fix in the apr-file. You can do this
1517                                    applying any text editor. The paths are either absolute
1518                                    or relative from where Thuban has been started.
1519                                    </para>
1520                                    <para>
1521                                    A sample for the Iceland data is included as
1522                                    <literal>Extensions/importAPR/samples/iceland.apr</literal>.
1523                                    The file-paths are relative from the Thuban main directory.
1524                                    </para>
1525                            </section>
1526                    </section>
1527            </section>
1528    
1529            <section><title>Writing simple extensions</title>
1530                    <para>
1531                    Writing an extension for Thuban basically means to
1532                    implement the extra functionality in Python with all of the
1533                    Thuban classes, methods and variables available.
1534                    </para>
1535                    <para>
1536                    All classes and their methods are documented in the source code
1537                    (see their doc-strings). Here is an example from
1538                    Thuban/Model/layer.py that describes some of the methods
1539                    of a Layer object:
1540                    </para>
1541                    <programlisting>
1542                    <![CDATA[
1543    class BaseLayer(TitledObject, Modifiable):
1544    
1545        """Base class for the layers."""
1546    
1547        def __init__(self, title, visible = True, projection = None):
1548            """Initialize the layer.
1549    
1550            title -- the title
1551            visible -- boolean. If true the layer is visible.
1552            """
1553            TitledObject.__init__(self, title)
1554            Modifiable.__init__(self)
1555            self.visible = visible
1556            self.projection = projection
1557    
1558        def Visible(self):
1559            """Return true if layer is visible"""
1560            return self.visible
1561    
1562        def SetVisible(self, visible):
1563            """Set the layer's visibility."""
1564            self.visible = visible
1565            self.issue(LAYER_VISIBILITY_CHANGED, self)
1566    
1567        def HasClassification(self):
1568            """Determine if this layer support classifications."""
1569    ...
1570                    ]]>
1571                    </programlisting>
1572                    <para>
1573                    This example intends to give you an impression of the
1574                    source-code-level documentation.
1575                    You have to make yourself familiar with
1576                    the Python programming language to understand some special
1577                    code elements.
1578                    </para>
1579                    <section><title>hello_world.py</title>
1580                      <para>
1581                      Traditionally, the first example should welcome the world.
1582                      Most of the code handles the frame for integrating a menu
1583                      item into Thuban while the actual raising of a message
1584                      is done in a single line.
1585                      </para>
1586                            <programlisting>
1587                            <![CDATA[
1588    # Copyright (C) 2003 by Intevation GmbH
1589    # Authors:
1590    # Jan-Oliver Wagner <[email protected]>
1591    #
1592    # This program is free software under the GPL (>=v2)
1593    # Read the file COPYING coming with Thuban for details.
1594    
1595    """
1596    Extend Thuban with a sample Hello World to demonstrate simple
1597    extensions.
1598    """
1599    
1600    __version__ = '$Revision$'
1601    
1602    # use _() already now for all strings that may later be translated
1603    from Thuban import _
1604    
1605    # Thuban has named commands which can be registered in the central
1606    # instance registry.
1607    from Thuban.UI.command import registry, Command
1608    
1609    # The instance of the main menu of the Thuban application
1610    # See Thuban/UI/menu.py for the API of the Menu class
1611    from Thuban.UI.mainwindow import main_menu
1612    
1613    def hello_world_dialog(context):
1614        """Just raise a simple dialog to greet the world.
1615    
1616        context -- The Thuban context.
1617        """
1618        context.mainwindow.RunMessageBox(_('Hello World'), _('Hello World!'))
1619    
1620    
1621    # create a new command and register it
1622    registry.Add(Command('hello_world', _('Hello World'), hello_world_dialog,
1623                         helptext = _('Welcome everyone on this planet')))
1624    
1625    # find the extensions menu (create it anew if not found)
1626    extensions_menu = main_menu.FindOrInsertMenu('extensions', _('E&xtensions'))
1627    
1628    # finally bind the new command with an entry in the extensions menu
1629    extensions_menu.InsertItem('hello_world')
1630                            ]]>
1631                            </programlisting>
1632                    </section>
1633                    <section><title>Registering a Command</title>
1634                      <para>
1635                      Mainly, our new function has to be registered to the Thuban
1636                      framework in order to connect it to the menu. A registered
1637                      command can also be connected to e.g. a toolbar button.
1638                      </para>
1639                      <para>
1640                      The instances and classes for this are imported at the beginning.
1641                      Any code not inside a method or class is directly executed when
1642                      the source-code module is imported. Therefore, the second
1643                      part of this example consist of the plain statements to create a new
1644                      Command and to add it to the menu.
1645                      </para>
1646                      <para>
1647                      By convention, it looks for a menu registered as ``extensions'' to
1648                      insert the new command. If it does not exist yet, it gets created.
1649                      It is advisable to copy this code for any of your extensions.
1650                      </para>
1651                    </section>
1652                    <section><title>The Thuban context</title>
1653                            <para>
1654                            A registered command that is called, always receives the
1655                            Thuban context. This instance provides our method with
1656                            hook references to all important components of the Thuban
1657                            application.
1658                            </para>
1659                            <para>
1660                    In the example hello_world.py, our function uses the
1661                            mainwindow component which offers a method to raise a
1662                            message dialog. In total there are three hooks:
1663                            <itemizedlist>
1664                            <listitem>
1665                            <para>application:
1666                            This object is the instance of the Thuban Application class.
1667                            Except maybe for loading or savinf sessions, you will not
1668                            need this object for a simple extension.
1669                            See Thuban/UI/application.py for the API.
1670                            </para>
1671                            </listitem>
1672                            <listitem>
1673                            <para>session:
1674                            The instance of the current session. It manages the sessions'
1675                            map and tables. You can set and remove the map or tables.
1676                            In may also get the map object. However, you should know that
1677                            internally it is already prepared to handle many maps.
1678                            Therfore, currently you would always receive a list with exactlty
1679                            one element. In the future, if there are more than one map,
1680                            you will not know which one is the currently display one and
1681                            therefore you should use the mainwindow as hook to find
1682                            the currently displayed map.
1683                            See Thuban/Model/session.py for the API.
1684                            </para>
1685                            </listitem>
1686                            <listitem>
1687                            <para>
1688                            mainwindow: The mainwindow object is central to manage various
1689                            GUI things such as the Legend sub-window. Most notably,
1690                            you get access to the canvas which is the window part where
1691                            the map is drawn. The canvas knows, which map it currently
1692                            draws and therefore you get the current map via
1693                            context.mainwindow.canvas.Map().
1694                            See Thuban/UI/mainwindow.py for the API.
1695                            </para>
1696                            </listitem>
1697                            </itemizedlist>
1698                </para>
1699                    </section>
1700            </section>
1701      </chapter>
1702    
1703    <chapter><title>Trouble Shooting</title>    <chapter><title>Trouble Shooting</title>
1704      <para>      <para>
1705      Here are a few problems that users have encountered when first using Thuban.      Here are a few problems that users have encountered when first using Thuban.
# Line 1291  Line 1795 
1795      </varlistentry>      </varlistentry>
1796    
1797      <varlistentry>      <varlistentry>
1798        <term>PostGIS</term>
1799        <listitem>
1800            <para>
1801            PostGIS adds support for geographic objects to the PostgreSQL
1802            object-relational database. Different layer types (as for Shapefiles)
1803            are supported. <ulink url="http://postgis.refractions.net">PostGIS
1804            Homepage</ulink>
1805            </para>
1806        </listitem>
1807        </varlistentry>
1808    
1809        <varlistentry>
1810      <term>Raster files</term>      <term>Raster files</term>
1811      <listitem>      <listitem>
1812          <para>          <para>
# Line 1301  Line 1817 
1817          <para>Most commonly used is the <emphasis>TIFF/GeoTIFF</emphasis>          <para>Most commonly used is the <emphasis>TIFF/GeoTIFF</emphasis>
1818          format: Raster maps are provided as TIFF images, with an additional          format: Raster maps are provided as TIFF images, with an additional
1819          "world file" storing the geographic reference (usually with an          "world file" storing the geographic reference (usually with an
1820          extension ".tfw".          extension ".tfw").
1821          </para>          </para>
1822      </listitem>      </listitem>
1823      </varlistentry>      </varlistentry>
# Line 1309  Line 1825 
1825      </variablelist>      </variablelist>
1826    </appendix>    </appendix>
1827    
1828      <appendix><title>Working with PostGIS</title>
1829      <para>
1830      This section focusses on the use of PostGIS in the Thuban framework. For
1831      installation and maintenance of spatial databases we refer to the  
1832      <ulink url="http://postgis.refractions.net">PostGIS Homepage</ulink>.
1833      The Thuban PostGIS support requires the
1834      <ulink url="http://initd.org/software/psycopg">psycopg module</ulink>.
1835      </para>
1836    
1837      <para>
1838            Working with PostGIS Databases is seperated into two steps:
1839            <itemizedlist>
1840            <listitem><para>Opening a Database Connection</para></listitem>
1841            <listitem><para>Loading a Data Layer</para></listitem>
1842            </itemizedlist>
1843      </para>
1844            <section><title>Opening a Database Connection</title>
1845            <para>
1846                    Before a data layer can be loaded from a PostGIS database a
1847                    connection with the database has to be established.
1848                    <menuchoice>
1849                    <guimenu>Session</guimenu>
1850                    <guimenuitem>Database Connections ...</guimenuitem>
1851                    </menuchoice> opens a dialog for database connection
1852                    management. In the dialog new connections can be added
1853                    and existing ones can be removed. Removing a database
1854                    connection is not possible if the map still displays a
1855                    layer provided by this database connection.
1856            </para>
1857        <figure>
1858        <title>Database Management Dialog</title>
1859        <mediaobject>
1860        <imageobject><imagedata fileref="../images/app_postgis_db_management.png" format="PNG" scale="&imgscale;"/></imageobject>
1861        <imageobject><imagedata fileref="./images/app_postgis_db_management.eps" format="EPS" scale="&imgscale;"/></imageobject>
1862        </mediaobject>
1863        </figure>
1864    
1865            <para>
1866                    To add a new database connection to the session a dialog is
1867                    opened to specify the relevant connection data. Enter all
1868                    data relevant for your connection. If the connection fails
1869                    the dialog remains open and provides some hints on the failure.
1870            </para>
1871            <figure>
1872            <title>Add Database Dialog</title>
1873            <mediaobject>
1874            <imageobject><imagedata fileref="../images/app_postgis_db_add.png" format="PNG" scale="&imgscale;"/></imageobject>
1875            <imageobject><imagedata fileref="./images/app_postgis_db_add.eps" format="EPS" scale="&imgscale;"/></imageobject>
1876            </mediaobject>
1877            </figure>
1878            
1879            <para>
1880            It is important to note that information on database connections are
1881            also stored with the session. Passwords are NOT stored. If you load a
1882            session with database connections you are asked to enter these
1883            passwords again where required.
1884            </para>
1885    
1886            </section>
1887    
1888            <section><title>Loading a Data Layer</title>
1889            <para>
1890            Data layers as part of a map are loaded with the
1891            <menuchoice>
1892            <guimenu>Map</guimenu>
1893            <guimenuitem>Add Database Layer ...</guimenuitem>
1894            </menuchoice> menu item. A dialog is raised displaying two choice
1895            lists. In the left list all connected databases are shown.
1896            Highlighting
1897            one of these and issuing a retrieval results in a list of available
1898            layer tables from that database. After selection of a
1899            layer the dialog is closed.
1900            </para>
1901            <figure>
1902            <title>Add Database Dialog</title>
1903            <mediaobject>
1904            <imageobject><imagedata fileref="../images/app_postgis_add_layer.png" format="PNG" scale="&imgscale;"/></imageobject>
1905            <imageobject><imagedata fileref="./images/app_postgis_add_layer.eps" format="EPS" scale="&imgscale;"/></imageobject>
1906            </mediaobject>
1907            </figure>
1908            
1909            </section>
1910    
1911      </appendix>
1912    
1913    <appendix><title>Supported Projections</title>    <appendix><title>Supported Projections</title>
1914      <para>      <para>
1915      The following types of projections are directly support by      The following types of projections are directly support by

Legend:
Removed from v.1533  
changed lines
  Added in v.2727

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26