/[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 1570 by jan, Fri Aug 8 17:09:02 2003 UTC revision 1744 by jan, Tue Sep 23 15:37:25 2003 UTC
# Line 23  Line 23 
23        <holder>Intevation GmbH</holder>        <holder>Intevation GmbH</holder>
24      </copyright>      </copyright>
25     <revhistory>     <revhistory>
26    <!-- comment this first revision out when releasing a real version -->
27    <!--
28         <revision>
29            <revnumber>CVS version $Id$</revnumber>
30            <date></date>
31            <revremark>Under development.</revremark>
32         </revision>
33    -->
34         <revision>
35            <revnumber>1.0pre2</revnumber>
36            <date>29-Aug-2003</date>
37            <revremark>
38                            Corresponds to Thuban development release 0.8.1.
39                            New: chapter on extensions.
40                    </revremark>
41         </revision>
42       <revision>       <revision>
43          <revnumber>1.0pre1</revnumber>          <revnumber>1.0pre1</revnumber>
44          <date>08-Aug-2003</date>          <date>08-Aug-2003</date>
45          <revremark>Corresponds to Thuban development release 0.8.1</revremark>          <revremark>Corresponds to Thuban development release 0.8.1.</revremark>
46       </revision>       </revision>
47    </revhistory>    </revhistory>
48    
# Line 79  Line 95 
95                  full installation packages for Debian, Windows and RPM-based systems                  full installation packages for Debian, Windows and RPM-based systems
96                  (Mandrake, RedHat, SuSE, etc).                  (Mandrake, RedHat, SuSE, etc).
97                  </para>                  </para>
98                    <section><title>RPM-based GNU/Linux Systems</title>
99                            <section><title>Installing Binary Packages</title>
100                                    <para>
101                                    The most wide-spread RPM-based GNU/Linux Systems are RedHat,
102                                    Mandrake and SuSE. The documentation of these distributions
103                                    should contain information about how to install third-party
104                                    RPM packages. Nonetheless, a short summary is provided here.
105                                    </para>
106                                    <para>
107                                    RPM packages can be installed applying several tools.
108                                    The most basic one is the command line program "rpm".
109                                    The hardware architecture is identified in the name
110                                    of RPM packages, eg. 'i386' for most Intel/AMD architectures.
111                                    If you have a different hardware architecture, where no
112                                    binary RPM packages are provided, you must rebuild binary
113                                    packages from the RPM source packages first (see below).
114                                    Typical rpm commands look like:
115    
116                                    <programlisting>
117                                    rpm --install Thuban-0.9.0-1.i386.rpm
118                                    </programlisting>
119    
120                                    Depending on what you already have installed on your
121                                    system, you are informed that some packages are
122                                    required, but not installed. You need to install them
123                                    first. Either they are provided by your GNU/Linux distributor
124                                    or available somewhere on the Internet.
125                                    The more essential and special ones are provided together
126                                    with the Thuban package.
127                                    </para>
128    
129                                    <para>
130                                    For rpm exist some graphical user interfaces, notably
131                                    kpackage, GnoRPM and xrpm.
132                                    </para>
133    
134                                    <para>
135                                    Make yourself familiar with one of the tools and apply it
136                                    to install the packages.
137                                    Note, that you need to be administrator (root) for the system
138                                    to do that.
139                                    </para>
140                            </section>
141                            <section><title>Build Binaries from Source Packages</title>
142                                    <para>
143                                    This section describes howto build RPM install-packages
144                                    from RPM source-packages.
145                                    This adapts and optimizes an install-package specifically
146                                    to your system.
147                                    This is especially helpful to resolve version conflicts of
148                                    dependent packages. Furthermore, install-packages for other
149                                    platforms (e.g. PowerPC) can be created.
150                                    </para>
151    
152                                    <para>
153                                    Note: rpm must be at least version 4. Execute
154                                    <literal>rpm --version</literal> to find out about the version.
155                                    </para>
156    
157                                    <para>
158                                    You need to do the following preparations to be able to
159                                    build the packages as a regular user. You should now
160                                    perform the package buling as root since this
161                                    might cause damage to your system.
162                            <itemizedlist>
163                            <listitem>
164                                                    <para>
165                                                    Create RPM directory structure:
166                                                    Choose a directory (e.g. $HOME/myrpm) and create the
167                                                    subdirectories BUILD, RPM, SOURCES, SPECS and SRPMS.
168                                                    A possible command sequence for this is:
169                                                    <programlisting>
170                                                    mkdir $HOME/freegisrpm
171                                                    cd $HOME/freegisrpm
172                                                    mkdir BUILD RPMS SOURCES SPECS SRPMS
173                                                    </programlisting>
174                                                    </para>
175                                            </listitem>
176                                            <listitem>
177                                                    <para>
178                                                    Set environment variable RPM_DIR:
179                                                    <programlisting>
180                                                    export RPM_DIR=$HOME/freegisrpm
181                                                    </programlisting>
182                                                    </para>
183                                            </listitem>
184                                            <listitem>
185                                                    <para>
186                                                    Create $HOME/.rpmmacros:
187                                                    This file sets general preferences and some
188                                                    specific settings for signing packages.
189                                                    If you don't have a GnuPG-key, you can skip
190                                                    the signature settings i.e. drop the last 4 lines.
191                                                    A signature becomes important when you want to
192                                                    give away packages to third parties.
193                                                    <programlisting>
194    <![CDATA[
195    %packager Name Lastname <[email protected]>
196    
197    %_topdir /home/mylogin/myrpm
198    
199    %_signature gpg
200    %_gpg_name Name Lastname
201    %_pgp_path ~/.gnupg
202    %_pgpbin /usr/bin/gpg
203    ]]>
204                                                    </programlisting>
205                                                    </para>
206                                            </listitem>
207                            </itemizedlist>
208    
209                                    Now you can install any RPM source-package.
210                                    It's components are installed into the corresponding
211                                    subdirectories of your rpm-directory.
212                                    Essentially these are the sources (into directory SOURCES)
213                                    and the so-called spec-file which contains all build
214                                    instructions. The spec-file will go into the SPEC directory.
215                                    Example:
216                                    <literal>rpm --install Thuban-0.9.0-1.src.rpm</literal>
217                                    </para>
218    
219                                    <para>
220                                    Create install-package:
221                                    Go to the directory with the spec-files and rebuild the
222                                    package:
223                                    <programlisting>
224    cd $HOME/mypm/SPECS
225    rpm -bb thuban.spec
226                                    </programlisting>
227                                    Next, you will find the newly created package in
228                                    $HOME/myrpm/RPMS/i386.
229                                    If you build the package for another architecture than
230                                    i386, then the name of the directory has a corresponding name.
231                                    </para>
232                                    <para>
233                                    For documentation of RPM, either type
234                                    <literal>man rpm</literal> or <literal>rpm --help</literal>.
235                                    This will provide you with information on the various command
236                                    line options of RPM.
237                                    For more information see the
238                            <ulink url="http://www.rpm.org/">homepage of RPM</ulink>.
239                                    </para>
240                            </section>
241                    </section>
242          </section>          </section>
243    
244          <section><title>The Main Window</title>          <section><title>The Main Window</title>
# Line 231  Line 391 
391    
392          <section><title>Adding and Removing Layers</title>          <section><title>Adding and Removing Layers</title>
393          <para>          <para>
394          There are two types of layers that can be added to a map: shape layers          There are two types of layers that can be added to a map: Shape layers
395          and image layers. Shape layers are stored in Shapefile format, a          and image layers. Shape layers are stored in Shapefile format, a
396          standard file format for storing geographic objects. These          widely used file format for storing geographic objects. These
397          files have the extension ``.shp''. Associated with          files have the extension ``.shp''. Associated with
398          the shape file is a database file which stores attributes for          the shape file is a database file which stores attributes for
399          each shape in the shape file. This file, in dBase format,          each shape in the Shape file. This file, in dBase format,
400          has the extension ``.dbf''. Both files must have the same base name.          has the extension ``.dbf''. Both files must have the same base name.
401          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
402          also be a file roads.dbf.          also be a file roads.dbf.
# Line 247  Line 407 
407          <guimenu>Map</guimenu>          <guimenu>Map</guimenu>
408          <guimenuitem>Add Layer</guimenuitem>          <guimenuitem>Add Layer</guimenuitem>
409          </menuchoice>.          </menuchoice>.
410          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
411          matter if the shape file or database file is selected.                  selection. However, if you switch to display all files and select one
412                    of the associated files (e.g. ``.dbf''), Thuban will recognize the base
413                    name and load the corresponding Shape file.
414            </para>
415                    <para>
416                    The file dialog for Shape files allows to select multiple files.
417                    Use the shift-button together with the left mouse button to extend
418                    the selection.
419          </para>          </para>
420    
421          <para>          <para>
# Line 1212  Line 1379 
1379      </section>      </section>
1380    </chapter>    </chapter>
1381    
1382      <chapter><title>Extensions</title>
1383            <para>
1384            Thuban is designed to be extensible. The term Extension is used as a
1385            general term for anything that extends Thuban.
1386            This chapter introduces into some oppportunities how to add and
1387            handle extra functionality developed by your own or third parties.
1388            </para>
1389    
1390            <section><title>Add personal extensions via thubanstart.py</title>
1391                    <para>
1392                    After Thuban has been started for the first time, a directory
1393                    .thuban is created within your home directory.
1394                    There you can add a file thubanstart.py  which will be imported
1395                    by Thuban at start-up. It is recommended to add only import-statements
1396                    to this file to keep the actual code of extensions separate.
1397                    </para>
1398                    <para>
1399                    The modules to import must either be found through the environment
1400                    variable PYTHONPATH or directly be placed into the .thuban-directory.
1401                    </para>
1402                    <para>
1403                    As an example, copy the file examples/simple_extensions/hello_world.py
1404                    of the Thuban source code into the .thuban-directory of your home
1405                    directory. Now add add the statement import hello_world to the
1406                    file thubanstart.py and run Thuban. You will notice an additional
1407                    menu <menuchoice><guimenu>Extensions</guimenu></menuchoice> where
1408                    the new item for the Hello-World extension is placed - select it
1409                    to see the Hello-World message.
1410                    </para>
1411            </section>
1412    
1413            <section><title>Extensions included in Thuban package</title>
1414                    <para>
1415                    The extensions described in this section are part of the
1416                    Thuban package, but not activated by default.
1417                    You will find them in the Thuban installation directory
1418                    under <literal>Extensions/</literal>. Activate them as personal
1419                    extensions via PYTHONPATH as described in the previous section.
1420                    Stable extensions will appear under the menu
1421                    <menuchoice><guimenu>Extensions</guimenu></menuchoice> and
1422                    extensions which are in experimental state and therefore
1423                    not fully functional under
1424                    <menuchoice><guimenu>Experimental</guimenu></menuchoice>.
1425                    </para>
1426    
1427                    <section><title>Stable extensions</title>
1428                            <para>
1429                            These extensions provide extra-functionality to Thuban
1430                            that has not (yet) been integrated in the main application.
1431                            They are considered to be free of bugs, but may be
1432                            further polished with helpful user interactions.
1433                            </para>
1434                            <section><title>gns2shp</title>
1435                                    <para>
1436                                    This tool converts data of the Geospatial Names Server
1437                                    (GNS, see <ulink url="http://www.nima.mil/gns"/>)
1438                                    into Shapefile format.
1439                                    The above web-site offer to download named places
1440                                    information grouped by countries for all of the world
1441                                    except USA for which other data are provided.
1442                                    </para>
1443                                    <para>
1444                                    If you download and unpack a package, you will have
1445                                    a text-file with suffix .txt.
1446                                    Selecting such a file via gns2shp will create the
1447                                    corresponding Shapefile with the same basename and
1448                                    place it in the same direcory. Afterwards it
1449                                    is automatically loaded into Thuban.
1450                                    The Shapefile will not automatically be delete afterwards.
1451                                    </para>
1452                                    <para>
1453                                    The gns2shp.py module can also be executed on the
1454                                    command line for batch processing purposes.
1455                                    </para>
1456                                    <para>
1457                                    A sample (<literal>ls.txt</literal> for Liechtenstein)
1458                                    is included in the directory
1459                                    <literal>Extensions/gns2shp/test</literal>.
1460                                    </para>
1461                            </section>
1462                    </section>
1463                    <section><title>Experimental extensions</title>
1464                            <para>
1465                            All all of these functions have to be handled with care,
1466                            since they are neither complete nor well tested.
1467                            They are to be seen as a proof-of-concept and may
1468                            additionally in some cases of practical help.
1469                            </para>
1470                            <para>
1471                            Any interest on further improvement of these extensions
1472                            should be communicated towards the developer and user
1473                            community.
1474                            </para>
1475    
1476                            <section><title>importAPR</title>
1477                                    <para>
1478                                    This command offer to load an ESRI� ArcView� project
1479                                    file (suffix .apr) and convert it for use within Thuban.
1480                                    After selecting a apr-file to load, a list
1481                                    will be presented that offers to select one of the views
1482                                    of the apr-file, provided there is more than one.
1483                                    Furthermore, the Session Info-Tree is extended with
1484                                    a complete representation of the parsed apr-file.
1485                                    </para>
1486                                    <para>
1487                                    The legend of Thuban does not yet cover all of the elements as
1488                                    supported by the legend of ArcView�. Therefore, the Thuban
1489                                    map will look different. Furthermore, the apr-format is
1490                                    a proprietary format, not openly documented.
1491                                    Therefore, the interpretation is
1492                                    partly based on reverse engeneering and good guessing.
1493                                    </para>
1494                                    <para>
1495                                    The file-paths within the apr-file may not fit and potentially
1496                                    are subject to fix in the apr-file. You can do this
1497                                    applying any text editor. The paths are either absolute
1498                                    or relative from where Thuban has been started.
1499                                    </para>
1500                                    <para>
1501                                    A sample for the Iceland data is included as
1502                                    <literal>Extensions/importAPR/samples/iceland.apr</literal>.
1503                                    The file-paths are relative from the Thuban main directory.
1504                                    </para>
1505                            </section>
1506                    </section>
1507            </section>
1508    
1509            <section><title>Writing simple extensions</title>
1510                    <para>
1511                    Writing an extension for Thuban basically means to
1512                    implement the extra functionality in Python with all of the
1513                    Thuban classes, methods and variables available.
1514                    </para>
1515                    <para>
1516                    All classes and their methods are documented in the source code
1517                    (see their doc-strings). Here is an example from
1518                    Thuban/Model/layer.py that describes some of the methods
1519                    of a Layer object:
1520                    </para>
1521                    <programlisting>
1522                    <![CDATA[
1523    class BaseLayer(TitledObject, Modifiable):
1524    
1525        """Base class for the layers."""
1526    
1527        def __init__(self, title, visible = True, projection = None):
1528            """Initialize the layer.
1529    
1530            title -- the title
1531            visible -- boolean. If true the layer is visible.
1532            """
1533            TitledObject.__init__(self, title)
1534            Modifiable.__init__(self)
1535            self.visible = visible
1536            self.projection = projection
1537    
1538        def Visible(self):
1539            """Return true if layer is visible"""
1540            return self.visible
1541    
1542        def SetVisible(self, visible):
1543            """Set the layer's visibility."""
1544            self.visible = visible
1545            self.issue(LAYER_VISIBILITY_CHANGED, self)
1546    
1547        def HasClassification(self):
1548            """Determine if this layer support classifications."""
1549    ...
1550                    ]]>
1551                    </programlisting>
1552                    <para>
1553                    This example intends to give you an impression of the
1554                    source-code-level documentation.
1555                    You have to make yourself familiar with
1556                    the Python programming language to understand some special
1557                    code elements.
1558                    </para>
1559                    <section><title>hello_world.py</title>
1560                      <para>
1561                      Traditionally, the first example should welcome the world.
1562                      Most of the code handles the frame for integrating a menu
1563                      item into Thuban while the actual raising of a message
1564                      is done in a single line.
1565                      </para>
1566                            <programlisting>
1567                            <![CDATA[
1568    # Copyright (C) 2003 by Intevation GmbH
1569    # Authors:
1570    # Jan-Oliver Wagner <[email protected]>
1571    #
1572    # This program is free software under the GPL (>=v2)
1573    # Read the file COPYING coming with Thuban for details.
1574    
1575    """
1576    Extend Thuban with a sample Hello World to demonstrate simple
1577    extensions.
1578    """
1579    
1580    __version__ = '$Revision$'
1581    
1582    # use _() already now for all strings that may later be translated
1583    from Thuban import _
1584    
1585    # Thuban has named commands which can be registered in the central
1586    # instance registry.
1587    from Thuban.UI.command import registry, Command
1588    
1589    # The instance of the main menu of the Thuban application
1590    # See Thuban/UI/menu.py for the API of the Menu class
1591    from Thuban.UI.mainwindow import main_menu
1592    
1593    def hello_world_dialog(context):
1594        """Just raise a simple dialog to greet the world.
1595    
1596        context -- The Thuban context.
1597        """
1598        context.mainwindow.RunMessageBox(_('Hello World'), _('Hello World!'))
1599    
1600    
1601    # create a new command and register it
1602    registry.Add(Command('hello_world', _('Hello World'), hello_world_dialog,
1603                         helptext = _('Welcome everyone on this planet')))
1604    
1605    # find the extensions menu (create it anew if not found)
1606    extensions_menu = main_menu.find_menu('extensions')
1607    if extensions_menu is None:
1608        extensions_menu = main_menu.InsertMenu('extensions', _('E&xtensions'))
1609    
1610    # finally bind the new command with an entry in the extensions menu
1611    extensions_menu.InsertItem('hello_world')
1612                            ]]>
1613                            </programlisting>
1614                    </section>
1615                    <section><title>Registering a Command</title>
1616                      <para>
1617                      Mainly, our new function has to be registered to the Thuban
1618                      framework in order to connect it to the menu. A registered
1619                      command can also be connected to e.g. a toolbar button.
1620                      </para>
1621                      <para>
1622                      The instances and classes for this are imported at the beginning.
1623                      Any code not inside a method or class is directly executed when
1624                      the source-code module is imported. Therefore, the second
1625                      part of this example consist of the plain statements to create a new
1626                      Command and to add it to the menu.
1627                      </para>
1628                      <para>
1629                      By convention, it looks for a menu registered as ``extensions'' to
1630                      insert the new command. If it does not exist yet, it gets created.
1631                      It is advisable to copy this code for any of your extensions.
1632                      </para>
1633                    </section>
1634                    <section><title>The Thuban context</title>
1635                            <para>
1636                            A registered command that is called, always receives the
1637                            Thuban context. This instance provides our method with
1638                            hook references to all important components of the Thuban
1639                            application.
1640                            </para>
1641                            <para>
1642                    In the example hello_world.py, our function uses the
1643                            mainwindow component which offers a method to raise a
1644                            message dialog. In total there are three hooks:
1645                            <itemizedlist>
1646                            <listitem>
1647                            <para>application:
1648                            This object is the instance of the Thuban Application class.
1649                            Except maybe for loading or savinf sessions, you will not
1650                            need this object for a simple extension.
1651                            See Thuban/UI/application.py for the API.
1652                            </para>
1653                            </listitem>
1654                            <listitem>
1655                            <para>session:
1656                            The instance of the current session. It manages the sessions'
1657                            map and tables. You can set and remove the map or tables.
1658                            In may also get the map object. However, you should know that
1659                            internally it is already prepared to handle many maps.
1660                            Therfore, currently you would always receive a list with exactlty
1661                            one element. In the future, if there are more than one map,
1662                            you will not know which one is the currently display one and
1663                            therefore you should use the mainwindow as hook to find
1664                            the currently displayed map.
1665                            See Thuban/Model/session.py for the API.
1666                            </para>
1667                            </listitem>
1668                            <listitem>
1669                            <para>
1670                            mainwindow: The mainwindow object is central to manage various
1671                            GUI things such as the Legend sub-window. Most notably,
1672                            you get access to the canvas which is the window part where
1673                            the map is drawn. The canvas knows, which map it currently
1674                            draws and therefore you get the current map via
1675                            context.mainwindow.canvas.Map().
1676                            See Thuban/UI/mainwindow.py for the API.
1677                            </para>
1678                            </listitem>
1679                            </itemizedlist>
1680                </para>
1681                    </section>
1682            </section>
1683      </chapter>
1684    
1685    <chapter><title>Trouble Shooting</title>    <chapter><title>Trouble Shooting</title>
1686      <para>      <para>
1687      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.

Legend:
Removed from v.1570  
changed lines
  Added in v.1744

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26